how node.js server is better than thread based server

前端 未结 5 1173
长发绾君心
长发绾君心 2020-12-21 05:39

Node.js server is works on event based models where callback functions are supported. But I am not able to understand how is it better than traditional thread based servers

5条回答
  •  感动是毒
    2020-12-21 06:12

    Threads are relatively heavy-weight objects that have a resource footprint extending all the way into the kernel. When you park a thread in a blocking syscall or on a mutex or condition variable, you are tying up all those resources but doing nothing. Now the OS has to find more resources so your program can create another thread... Then you idle them too. It doesn't take long before the OS is struggling to scavenge more resources for your program to waste.

    CPU time is just one small part of he bigger picture. :-)

提交回复
热议问题