A traditional request handling model works like this:
- Browser makes a connection (think of it as dialing a restaurant)
- Server accepts the connection (restaurant employee answers phone)
- Browser sends a request (think of this as saying "I'd like to make a dinner reservation")
- Server processes the request and sends the response ("Got it, your reservation is made")
- The connection is closed (both sides hang up)
This is great, except that each employee is expensive, and the restaurant can only afford to pay N employees. If there are more people calling in a given moment than their are employees to respond to a call, callers will get frustrated that nobody has picked up, hang up, and try again later (or try another restaurant).
Node.js does things a little differently.
- Browser makes a connection
- Server places the connection in a queue (puts the caller on hold)
- Server process takes connection off queue, an accepts it (employee takes caller off hold)
- Browser sends the request
- Server processes request and sends response
- The connection is closed