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.

Why Events Are a Bad Idea (for high-concurrency servers) (2003) [pdf]

72 pointsby relyioalmost 8 years ago

5 comments

mjevansalmost 8 years ago
Modern processors are much faster than the outlying memory and persistent storage devices. They and compilers in combination are relatively good at optimizing for predictable patterns of using sequential blocks of the outlying memory. Context switches between tasks are expensive, because the state of the processor must be (at least partially) serialized and stored as well as the loss of the implicit context of the caches.<p>Thus it makes &#x2F;far&#x2F; more sense to have a number of threads (dependent on the hardware capacity and how readily the problem can be divided to independent or very loosely coupled tasks) which poll message queues than it does to have a completely independent thread for every event.<p>Languages based around message passing are thus the obvious choice for this type of programming.
评论 #14549407 未加载
评论 #14549114 未加载
EGregalmost 8 years ago
A few years later, Igor Sysoev will make NGinX which will blow Apache away in speed, and Apache 2 will adopt the paradigm.
评论 #14549962 未加载
CodeWriter23almost 8 years ago
Threads vs. events is a false dichotomy to me. Currently writing an event-driven finite state machine dispatcher that fires up threaded processes to perform long-running tasks that do not modify state. The FSM brings order and structure to chaotic event interactions, while threading enables full utilization of CPU cores. All the better to drain your battery, lol. Seriously though, I made this choice to balance reliability with responsivenes.<p>Choose the right tool for the job.
评论 #14552292 未加载
metalliqazalmost 8 years ago
Modern version of &quot;considered harmful.&quot;
geezerjayalmost 8 years ago
here&#x27;s a link to a related discussion on HN entitled Why Threads are a Bad Idea (for most purposes) (1995)&quot;<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=14547063" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=14547063</a>