I didn't say that threads are immune to saturation. I said Node.JS's event loop is way to easy to over saturate because it pulls one event down and while that's working all other events are blocked.
Try running the exact same test against a threaded web framework and I guarantee you that simple example bombs on Node harder than any other. If you think the event loop is competitive to threads then it's clear you have yet to be bitten by it.
You say it's "apple to oranges" but I'm not sure you understand most of what you're talking about.
a more accurate comparison would be to a cluster of node processes
It's built using node, with clusters of processes.
At no point did we need threads
(emphasis mine)
First you declare that a multi-threaded process should be compared to multiple Node processes. Makes sense, Node's cluster library is the best way to achieve a "threaded" Node system. That would be more fair.
Then you say you built some massive system without threads, but needed clustered processes and then declare you never needed threads?
Either clustered Node processes hosting the same program equate to a single threaded process running a program or it doesn't. You either think they're equivalent or you don't.
I don't care what you've built. We're not here comparing résumés. Whatever you've built, whatever the community has built with Node doesn't change the fact that it's very easy to flood the event loop. So easy that you'd be insane to run a deployment for a lightweight service (several thousand hits/second) on a single Node process. The reason is because the event loop is out of your control, and as soon as one event queued up backs up you have a waterfall effect from there on out. So yea, of course you want to cluster. Eight, or sixteen event loops are better than one.
Threaded systems max out on requests too, but they suffer in different way. Some threaded systems mix both concepts. Go's concurrency model uses OS threads for goroutines but will swap out goroutines or pass them between thread contexts when one blocks and another can run. This allows you to have, some small number of threads with large numbers of goroutines as the runtime tries to maximize processor time.
Other solutions are more straightforward, in most languages there is a threading concept and you simply leverage threads for work. Most web servers (which you'd run in front of Node for static content and as a gateway) like Apache and Nginx are threaded applications.
The whole point of my comment was exactly as I stated it:
The problem with Node is ... when you flood the event loop.
Which is a perfectly valid point. It can't be refuted because it is a problem. It's the reason the cluster library came to be! Boy running a Node server before then was not a pleasure, you had to dig around for node services to provide the feature, then make sure your master process is running behind a forever application which is then, most likely, watched by an upstart job -- at least that's what you used to do. There are more fancy tools now so you can run your Node applications with some peace of mind.
In the meantime, there are plenty of other platforms that don't suffer from the issues that a single threaded event-loop system create for itself and with those platforms one doesn't have to find additional tools to combat those issues.
As a final note, I'm not here to deliver to you benchmarks galore. I provided a sample that demonstrated my point and that's sufficient. You started in with the argument about how wrong I was and so the burden of proof is now yours. I'd advise you do some research on further understanding about Node's event loop.
I'm having a really hard time finding the article I really want to reference. I saw it on /r/golang a while back. It was post from an engineering team (or engineer?) from a company that would receive daily spikes of requests.
Each of these requests required multiple fetches from S3, and given that AWS has no bulk fetch from S3 API the files had to be requested individually. So millions of incoming requests, each fetching multiple S3 files each they ran into a problem. Before I explain, the bottleneck was S3, not their system. But this bottleneck created a unique issue since their system was built in Node.
They ran multiple node servers and each of those were clustered of course but the sheer volume pretty much meant that traffic was hitting every single process they ran. The S3 bottleneck meant that requests hit the event loop and clogged them which led to timeouts, long wait times and an overall poor experience.
Their solution was re-engineer this piece in Go (obviously if it was posted to /r/golang) which handled the load quite gracefully with fewer resources (servers/processes/memory/CPU) overall.
The moral, and my point is, Node's event loop is a huge bottleneck that seems to be widely ignored or passed off. I acknowledge that it doesn't fail for all use cases. But node supporters defend it as a genius solution.
I didn't say I didn't need concurrency, I said I didn't need threads. I used processes instead.
The reason why I took issue, and of course caused you to comment about it is quite simple. Node as a single process was designed (originally) to function as a single process. You weren't supposed to need threads because it's amazing. Threaded programming is concurrent programming. So if you're eschewing threads in favor of the event loop you're declaring no need for concurring programming. It became quite clear over time that having no concurrency model was never going to work and thus entered the cluster utilities in the standard library. So I compare Node to a platform that supports threads (or concurrency models, since Erlang uses processes too) because the event loop creates unique problems that these other systems are immune to by their very nature of not having one. I'm including the ability to cluster, and host on various servers as well. I'm not attack Node so much as I'm expressing a distaste for the weaknesses that the event loop creates.
If it makes you feel any better I dislike EventMachine for Ruby for the exact same reasons. Although Ruby has threading it's standard implementation has a GIL which is a whole 'nother thread.
As a side note, I first started building applications with Node in 2011 when it was really young. I've watched it grow over the years and I occasionally test it against that "simple benchmark" to see if they've been able to combat floods like that but it's always prone to the same problem and that's not something I'm interested in when using a platform. I get that clustering alleviates this.
0
u/[deleted] Apr 27 '16
[deleted]