"Nodejs Development Guide" study notes

Source: Internet
Author: User

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

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.