Since Nodejs is single-threaded, how does it handle multiple requests for high concurrency?

Source: Internet
Author: User

The idea of single thread solving high concurrency is to adopt the idea of non-blocking, asynchronous programming. The simple generalization is that when encountering very time-consuming IO operations, the subsequent code is executed in a non-blocking manner, and the event loop is entered, and when the IO operation is complete, the program is notified that the IO operation is complete. The main use of JavaScript callback function to achieve.

Although multithreading can also solve high concurrency, but is to build multiple threads to implement, the disadvantage is that when encountering time-consuming IO operations, the current thread will be blocked, and the control of the CPU to other threads, the problem is to be very frequent thread context switch.

Since Nodejs is single-threaded, how does it handle multiple requests for high concurrency?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.