Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I've been reading about the C10K Problem, and of particular note is the part that refers to asynchronous server I/O. http://www.kegel.com/c10k.html#aio

I believe this pretty much summarises what Node.js does on the server, by allowing threads to process user requests whilst relying on I/O interrupts (events) to notify threads of jobs that are completed, rather than have the thread be responsible for the full CPU job. The thread can get on with other things (non-blocking), and be notified of when a job is done (e.g. a file is found or a video is compressed).

This subsequently means that a thread is more 'available' to sockets and therefore to users on the server.

Then I found this: http://teddziuba.com/2011/10/straight-talk-on-event-loops.html

The writer here claims that although the event driven framework (interrupted threading), may free up threads, it doesn't actually reduce the amount of work a CPU has to do! The rationale here is that if, say, a user requests to compress a video they uploaded, the CPU still has to actually do this job, and will be blocking while it does it (for simplicity's sake, lets forget about parallelism here - unless you know better!).

I'm a straightforward coder, not a server admin or anything like that. I'm just interested to know: is Node.js a gift from the gods of 'cloud computing' or is it all hot air, and won't actually save companies time and/or money by improving scalability?

Many thanks.

share|improve this question
10  
Firstly ted is a troll, secondly node.js is meant for IO-bound applications not CPU-bound applications. What you want is a combination of the two. Anything CPU-bound goes into a new thread/process. Anything IO-bound goes in a event loop. –  Raynos Oct 25 '11 at 16:41
1  
+! That guy is definitely a troll. –  Patrick Hughes Oct 25 '11 at 17:42
    
It depends with what you compare - if you still use Apache (for some reason) - then Node is gift from gods, but if you compare it to Nginx - improvements are much less drastic, and Node is even slower. (ten times slower, 2ms vs 20ms to generate a responce, BUT in our tests, Nginx was giving 504 under moderately heavy load, and Node was giving normal responses). –  c69 Oct 25 '11 at 18:09
    
Now you mention it guys, the troll guy is clearly a troll. @c69 that's good info, thanks a lot. –  AlexW Oct 25 '11 at 21:02
add comment

2 Answers

up vote 13 down vote accepted

Of course any CPU bound work is going to utilize the CPU. It's going to block the CPU in whatever language or framework you write it in.

Node.js is great for when you have I/O bound work, not CPU bound. I wouldn't do heavy lifting in Node, though it can be done. Node.js solves real problems, not fictional or imagined ones like fibonacci number servers. It's not “hot air”.

share|improve this answer
    
Just checking some benchmarks and indeed it does seem way faster at serving pages: zgadzaj.com/… .. I guess this is what I was after... –  AlexW Oct 25 '11 at 14:48
2  
@AlexW: Good point about those benchmarks is that you're essentially serving static content. See my Millions of Hits a Day piece. Spinning up the PHP interpreter for that is waste. Look at something like node-static for serving file directories. –  Josh K Oct 25 '11 at 15:55
    
@AlexW, Just to remind that zgadzaj.com/… uses node.js 0.1.103, which is old now !! –  Samyak Bhuta Oct 30 '11 at 10:06
add comment

While the C10K paper is somewhat out of date with regards to implementation details, event-based concurrency (the reactor model) is still in some ways superior to preemptive scheduling. For example, a preemptive scheduling model may schedule threads while they are IO blocked. This allows node (and other tools like Ruby's Event Machine and Python's Twisted) to better use available cycles by spending more time doing real work and less time blocking.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.