Welcome everyone to guide and discuss:)
Note: This note is based on the Nodejs Development Guide, not the original.
Chapter--nodejs Introduction
Nodejs is a platform that allows JavaScript to run on the server side, and it is developed for real-time Web applications (real-time web). The scalability of the architecture with real-time response and ultra-large data requirements. It uses a single-threaded, asynchronous I/O, event-driven program design model. Javscript is made up of ECMA, DOM, and BOM.
Nodejs uses a single-threaded model, which uses asynchronous requests for all I/O and avoids frequent context switching. Nodejs maintains an event queue during execution, the program enters the event loop at execution time, waits for the next event to arrive, and each asynchronous i/0 request is pushed to the event to sleep, waiting for the program to process.
Nodejs is a non-blocking request through an event-based asynchronous callback mechanism. For example, disk I/O, network traffic, database queries, and other events that require time overhead. A vivid example can be understood Nodejs mechanism: a production of chicken legs factory, there is only one line, worker a at the top of this line, he is responsible for the chicken leg plastic packaging, and he can only operate a awuawu at the same time (an event queue, The NODEJS process will only handle one event at a time). Workers A is very efficient, often see the process has been perfect chicken legs will not hesitate to carry out packaging, but whenever he saw some have not completed the process of chicken legs into the assembly line, he will and chicken legs said: "hey! Dude, you're not on soy sauce yet! I'll take you to the next door on the soy sauce line, but you can rest assured that after you finish the soy sauce, that line will send you back to deal with, wait for us to see again! I'll take care of the chicken leg after you. "(The process does not wait, but proceeds directly to the subsequent statement, blocking events into the event loop, and when it is finished, it is re-entered into the event queue and waits to be processed before the thread calls the previous callback function to proceed with the subsequent logic).
"Nodejs Development Guide" study notes