Why node.js is fast when it's single threaded?

前端 未结 3 1111
伪装坚强ぢ
伪装坚强ぢ 2020-12-30 03:51

Despite being single threaded, how is node.js is faster? I haven\'t run any tests to find statistics, but while digging in the node.js forums, I find everyone says it\'s fa

3条回答
  •  心在旅途
    2020-12-30 04:35

    Because nodejs won't wait for the response, instead it follows event-driven programming with callbacks i.e Once a request is submitted it will be pushed in an event queue and each request is handled by a single thread but this thread will just submit the request and move to the next request and so on and never waits for the response. Once the request is processed the respective callback function of the request will be executed.

提交回复
热议问题