I would find it much easier to follow the article if the author used traditional mathematical notation instead of Clojure. Which do you prefer? (* t (/ 1000 w)) or (perhaps typeset properly) t * 1000 / w
Threaded vs Evented Servers
21–30 of 32 posts
Re: Threaded vs Evented Servers
#22The examples given seem to indicate that evented servers are as fast or faster than threaded servers. If that's the case, why doesn't everyone just use evented servers?
This Usenix article argues that threaded servers are a better programming model, though it admits that evented servers with current setups may be more efficient (e.g. if there's no compiler support for minimizing per-thread stack overhead): http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.5.58...
Re: Threaded vs Evented Servers
#23This article seems to focus on fairly heavy weight threads, but what about green threads? It seems like green threads with proper nonblocking libraries could behave performance-wise just like evented servers.
Re: Threaded vs Evented Servers
#24I would find it much easier to follow the article if the author used traditional mathematical notation instead of Clojure. Which do you prefer? (* t (/ 1000 w)) or (perhaps typeset properly) t * 1000 / w
Many programmers dislike math notation; they have bad experiences of school, and gloss over anything which reminds them of dull homework and tests. On the other hand, programming notation symbolizes a feeling of freedom.
It helps that I'm more used to Clojure's notation than traditional math notation. Also it's easily executable for me. No need to execute precise arithmetic mentally; the computer can do it.
Re: Threaded vs Evented Servers
#25I find it unrealistic that threaded vs evented (or blocking vs non-blocking I/O) comparisons always use a slow database server as the prototypical thing to wait for.
I get that this is not the point but to a newcomer it must seem like "oh.. database servers are super slow, I must first and foremost worry about optimizing access to them".
If your queries regularly take more then 10ms to complete, something is wrong with the database (do caching, put database closer to querying server - maybe even on the same machine).
Re: Threaded vs Evented Servers
#26Re: Threaded vs Evented Servers
#27Not specific to this article: I find it unrealistic that threaded vs evented (or blocking vs non-blocking I/O) comparisons always use a slow database server as the prototypical thing to wait for. I get that this is not the point but to a newcomer it must seem like "oh.. database servers are super slow, I must first and foremost worry about optimizing access to them". If your queries regularly take more then 10ms to c…
Re: Threaded vs Evented Servers
#28I would find it much easier to follow the article if the author used traditional mathematical notation instead of Clojure. Which do you prefer? (* t (/ 1000 w)) or (perhaps typeset properly) t * 1000 / w
Re: Threaded vs Evented Servers
#29The examples given seem to indicate that evented servers are as fast or faster than threaded servers. If that's the case, why doesn't everyone just use evented servers?
I think the answer is actually pretty straightforward. It's trivial to go from a serial to a threaded server. It's way harder to write an event-based server using poll or select. Serially: int handle_connection(int fd) { ... } int loop() { ... while(1) { fd = accept(listener); handle_connection(fd); } } Threaded: int handle_connection(int fd) { ... } int loop() { ... while(1) { fd = accept(listener); thread_start(han…
Evented:
int handle_connection(int fd) {
...
}
int doaccept() {
put_on_event_loop(accept(listener));
}Re: Threaded vs Evented Servers
#30"Finally, we’ll assume single-core servers"... isn't that rather like working out mathematically that the best gait for horses is hopping, provided you assume a one legged horse?
No, while this is a wonderful analogy, I don't think this is actually a problem. It's more like assuming horses weigh 1000 kg --- wrong for all but the biggest draft horses, but a nice round number to work with. For the level of analysis in the article, there's really no difference between a 4 core machine and a processor with a 4x clock speed. His point is that the threaded model makes the most sense when each reque…
An evented server (at least, until they get a lot fancier and make you program with locks and such) only gets to use one of the cores, while a threaded server gets all four.
Using a single core just means that the threaded server doesn't get any advantage from being threaded, while the evented server gets everything it can use.
This "model" is worthless for comparison.