Explain “Event-Driven” Web Servers to Your Grandma
You’ve heard the term event-driven, event-based, or evented when it comes to web servers. Node.js is based on evented I/O. nginx is an asynchronous event-driven web server.
But what does the term mean? Here’s an easy way to think about it.
Let’s think of a web server as a pizza shop that needs to take orders over the phone (requests for web pages).
Traditional Web Server
The pizza shop hires operators (processes/threads) to take orders over the phone. Each operator has one phone line. After the operator is done taking the order, the operator keeps the customer on the line until the pizza (response web page) is done baking and then tells them it’s ready to pick up.
So the pizza shop needs to hire as many operators as the number of pizzas that may be baked at once in order to serve all customers who call in.
Event-Driven Web Server
The pizza shop only hires one operator, but has trained the operator to hang up after taking the order, and call the customer back when the pizza is ready to be picked up.
Now one operator can serve many customers.
Thanks to dierken for providing this example via ReadWriteWeb comments.