News for hackers. Stuff that matters.
Re:An open question (rant) about Node.js by bascule on Friday March 14, 2014 @11:56AM (#7399656)
> In a synchronous language, you HAVE TO go to one shard, then another, then another, and the time is 10x longer.

Have you ever heard of threads?

Re:An open question (rant) about Node.js by dharbin on Friday March 14, 2014 @12:21PM (#7399854)
Threads are more difficult than writing event-loop based code IMO
Re:An open question (rant) about Node.js by EGreg on Friday March 14, 2014 @12:40PM (#7400025)
Not just more difficult. Threads are really wasteful to spawn just so you can hit 10 shards. Even if you have a thread pool. Evented I/O is much better than threads.

When NGiNX launched, it was the evented web server in a sea of threaded servers. Guess which paradigm won.

Re:An open question (rant) about Node.js by bascule on Friday March 14, 2014 @01:05PM (#7400199)
It's not a dichotomy. The answer is that both models are useful, and most systems support hybrid threaded and evented modes. Node.js only supports one model, which is a huge drawback.
Re:An open question (rant) about Node.js by pswenson on Saturday March 15, 2014 @02:45PM (#7405697)
threads don't have to be more difficult. check out actors.

Meteor seems to think threads are the way to go (Fibers)

Re:An open question (rant) about Node.js by EGreg on Friday March 14, 2014 @12:39PM (#7400010)
In PHP and other scripted web server languages? Please show me how it's done.

PHP does preforking first of all. You have about 30 "threads" sitting around, able to handle 30 clients. This is STILL not the same as evented programming, which lets you send out these requests and wait.

Speaking of -- have you ever heard of evented i/o?

Let me put it this way ... threads and workers are good for handling incoming requests (one worker per request). But for outgoing requests, it's nice to have evented i/o!

Re:An open question (rant) about Node.js by bascule on Friday March 14, 2014 @01:00PM (#7400148)
http://celluloid.io/

https://github.com/jruby/jruby/wiki/Concurrency-in-jruby

> Speaking of -- have you ever heard of evented i/o?

Yes, I wrote a Ruby wrapper to libev before Ry wrote Node, and this coroutine abstraction to get rid of the async gunk, but Ry left that part out:

http://revactor.github.io/philosophy/

Re:An open question (rant) about Node.js by EGreg on Friday March 14, 2014 @04:13PM (#7401508)
Got anything for PHP?
Re:An open question (rant) about Node.js by bascule on Friday March 14, 2014 @04:46PM (#7401743)
I don't care about PHP
Re:An open question (rant) about Node.js by nickfargo on Friday March 14, 2014 @12:37PM (#7399995)
Referencing C10k implies yes. Threads cost.
Re:An open question (rant) about Node.js by bascule on Friday March 14, 2014 @01:01PM (#7400163)
Do you know what threads cost? Probably not.

Linux has an O(1) scheduler.

Threads do have a cost in terms of virtual memory, but on 64-bit architectures, this is a non-issue.

Optimizing for "C10K" (which, btw, was a big number in 1999, not today) by using an event loop will actually harm latency and performance in the case that you are dealing with a small number of highly active connections. Believe it or not the kernel can do just as good (or better) a job of scheduling than Node's event loop.