how node.js server is better than thread based server

前端 未结 5 1171
长发绾君心
长发绾君心 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

    When having a lot of threads you are going to have a lot of context switching which is going to be expensive. You want have this overhead when using node.js's Event loop

    Context Switch

    A context switch is the computing process of storing and restoring state (context) of a CPU so that execution can be resumed from the same point at a later time.

    Event loop

    In computer science, the event loop, message dispatcher, message loop or message pump is a programming construct that waits for and dispatches events or messages in a program.

提交回复
热议问题