Created
August 8, 2012 02:35
-
-
Save maxenglander/3291567 to your computer and use it in GitHub Desktop.
Node.js metaphor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A traditional request handling model works like this: | |
1. Browser makes a connection (think of it as dialing a restaurant) | |
1. Server accepts the connection (restaurant employee answers phone) | |
1. Browser sends a request (think of this as saying "I'd like to make a dinner reservation") | |
1. Server processes the request and sends the response ("Got it, your reservation is made") | |
1. 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. | |
1. Browser makes a connection | |
1. Server places the connection in a queue (puts the caller on hold) | |
1. Server process takes connection off queue, an accepts it (employee takes caller off hold) | |
1. Browser sends the request | |
1. Server processes request and sends response | |
1. The connection is closed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment