TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Explain “Event-Driven” Web Servers to Your Grandma

88 pointsby daverecyclesover 14 years ago

12 comments

jasonkesterover 14 years ago
Terrible analogy, especially when there exists a better one within the food service industry. How about rewriting that article from the perspective of a coffee shop?<p>We've all been to the neighborhood coffee place where the girl will take your order, turn around and make your entire drink, hand it to you and ask for payment. We've all stood in that line.<p>We've also all been to Starbucks, where the girl takes your order, writes it on a cup, takes your money, then moves on to the next customer. And by the time you walk to the other end of the counter the guy in front of you already has coffee in his hand.<p>It still doesn't fit web servers exactly, but at least it fits the real world.
gibersonover 14 years ago
Grandma, "Event-Driven" is just a fancy word for magic. Don't worry about it.
评论 #2180028 未加载
amalconover 14 years ago
"Event-driven" architecture doesn't imply a fundamentally different way of handling requests than thread-based. The only difference is that in an event-driven architecture, the scheduling is handled in the userspace code. In a thread-based architecture, it's done in the kernel. The advantage of doing it in the userspace code is that it can be done in a simpler, more specialized way.<p>The hardware is doing fundamentally the same thing either way, but in the threaded model, it's also doing a lot of other stuff that you probably don't care about.<p>So, to explain it to my grandma: It's just a simpler way to think about it. There isn't really a big difference.
评论 #2180053 未加载
bartlover 14 years ago
Explain "web server" to your grandma. Oopsie.
评论 #2180830 未加载
jlewover 14 years ago
While a great attempt at an analogy, I don't think that it really helps things. I've never misunderstood THAT part of event-based asynchronicity (is that even a word?) The part that is confusing to me is HOW it works and eventually to the point of WHY and/or HOW it is supposedly better than traditional threading (other than cleaner-looking code). I've never seen a good explanation in non-OS programmer terms.<p>To me, it seems that no matter how you take the "messages" to do work, that work still has to be done. It surely doesn't magically use less resources because you told the OS that it could just call you back when it is done, as opposed to you having to hang around? Something has to be hanging around on one side or the other, and the "call back" takes resources as well, surely? It seems that you are just trading tit for tat. Maybe the reason is to not utilize some specific resource in the meantime?
sophaclesover 14 years ago
What a terrible analogy. I mean, there is a pizza-shop or other food service analogy in there, I've made it plenty of times. The problem is that when you make the phone call = request in the analogy, you make the phone connection analogous to the socket. At least have the operator put the caller on hold!<p>Of course then Grandma, not being an idiot, will say "why not just have driver bring the pizza and not have the phone all tied up to begin with?" and she is <i>absolutely correct</i>. It is better to just set up a scenario where you have waiters, and customers show up a the shop, and in blocking your waiter doubles as the cook, so you need one waiter per meal... and so on. This analogy passes a slightly closer examination.
Jinyoungover 14 years ago
Hmm, perhaps a closer analogy:<p>Traditional Web Server:<p>The pizza shop receives a call for the initial order and starts the pie. Then the customer calls back periodically to check if the pie is done because the pizza shop cannot call back or deliver.
评论 #2179744 未加载
评论 #2180088 未加载
评论 #2179902 未加载
评论 #2179740 未加载
newhousebover 14 years ago
Oh hey, I came up with the exact same analogy about 6 months ago in explaining Tornado and epoll on quora with a bit more technical detail, just replace pizza with pies:<p><a href="http://www.quora.com/Can-someone-explain-poll-epoll-in-Laymans-terms-How-is-Tornado-taking-advantage-of-this-technology/answer/Ben-Newhouse" rel="nofollow">http://www.quora.com/Can-someone-explain-poll-epoll-in-Layma...</a>
sambeauover 14 years ago
What is being described here is blocking and non-blocking IO. The analogy is pretty good.<p>However, the pizza company can probably still only cook 256 pizzas at the same time (due to running out of pan-handles).
kqueueover 14 years ago
event driven development should be avoided whenever possible. coroutines exist for a reason.<p>Writing event-driven applications is very prone to errors and invalid(impossible) states.
vyrotekover 14 years ago
I feel that this analogy seems to overlook the work that goes into having a 'customer' being available for, listening and receiving the call back.
contextfreeover 14 years ago
No! I refuse to explain event-driven web servers to my grandma. You can't make me! I am a free man!