First review the elementary school Chinese text, Hua's "overall method".
For example, want to brew pot of tea to drink. At that time, there was no boiling water, the kettle was washed, the teapot was washed, the fire was born, and the tea was there. What to do?
Method A: Wash the kettle, pour cold water, put on the fire, in waiting for the time to open, wash the teapot, wash the cup, take tea, and so the water opened, tea and drink.
Method B: Do some preparatory work first, wash the kettle, wash the teapot cup, take tea; everything is ready, water is boiled; wait for the tea and drank it.
Method C: Wash the kettle, pour cold water, put on the fire, wait for open, the water opened, hurriedly find tea, wash teapot cup, tea and drink.
Which way to save time? We can see the first way, the latter two methods are in the nest.
...
From this figure can be seen at a glance, a total of 16 minutes (and the method B, C need 20 minutes).
...
It seems to be a "fuss", but it is necessary to do so in too many parts of the job.
...
Source: Hua Hua co-ordination method _ Baidu Library
node. JS is a bunch of Hua, helping us make tea faster and making tea to a bunch of people faster.
When we use the browser to access the server, it is like going to tea shop to buy tea and drink. We can buy it back and brew it, or we can take a seat in the shop and drink it out of the box.
If we buy back to drink, referring to teacher Hua's text, he said this is "fuss", because 16 minutes and 20 minutes not too much, on our own and family, slow life 4 minutes also nothing wrong.
But if we drink in the shop, it's not our family waiting. Compared to 16 minutes of the minimum waiting time, the first table more than 4 minutes, the second table to come at the same time more than 24 minutes, the third table stood up and walked, more than 20 tables are idle. Busy for half a day, drinkers impatient, tea shop not make money.
Therefore, the tea shop must learn the primary school text, not only for the same table of different requests to co-ordinate arrangements, do not Rensili one thing not to start the next , and even for the different requests do not have to try to parallel processing, such as boiling water can help a few table order, take tea, wash teacup teapot, before the water open, don't idle, water to each table tea , so that every table guests feel swish fast.
In this story, the tea shop is a Web server. We ourselves are the browser.
If we do not want the browser hands, then throw the job to the server dry ; When the server suddenly service a lot of browsers can not rensili do not want to serial operation, to be flexible co-ordination, at the same time to start a few things, which is closed which piece.
These three features are called by the river-Lake incision:
- server-side JavaScript processing:server-side JavaScript execution
- non-blocking/asynchronous I/O: non-blocking or asynchronous I/O
- Event driver : Event-driven
node. JS is such a server-side, non-blocking I/O, event-driven JavaScript runtime environment.
From the understanding of the great God's image of node. js