Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node.js concurrency

I'm new in node.js. I'm testing socket.io for real time messaging. I love it and I want to use. I have a question. How many concurrency can run in Node.js server ? Our program will be approximately 100 concurrency. So, I'm worry about that.

I found another real time messaging server , APE. Which one is better ? I love node.js because it's easy to learn and easy to write. But I couldn't find discussion about concurrency in node.js server. My friend company is using APE and it can control around 2000. So, I want to know about node.js server.

like image 422
saturngod Avatar asked Nov 18 '10 14:11

saturngod


People also ask

Does NodeJS support concurrency?

Node js uses an event loop to maintain concurrency and perform non-blocking I/O operations. As soon as Node js starts, it initializes an event loop. The event loop works on a queue (which is called an event queue) and performs tasks in FIFO(First In First Out) order.

Is NodeJS concurrent or parallel?

At a high level, Node. js falls into the category of concurrent computation. This is a direct result of the single-threaded event loop being the backbone of a Node. js application.

What is mean by concurrency in NodeJS?

Concurrency means that a program is able to run more than one task at a time — this is not to be confused with parallelism. During concurrency, different tasks with differing goals of the program can be performed at the same time, while in parallelism, different parts of the program execute one task.

Is NodeJS multithreaded?

You can achieve multithreading by generating multiple nodes or Node. js V8 engines which in isolation are single-threaded. It is still correct to say Node. js is not multi-threaded.


1 Answers

Without having any benchmarks to back this up--since both are event-driven (i.e. epoll on Linux), I would imagine that you'll see comparable results for both (at least 10K concurrent users). That being said, performance is likely to be much more affected by the frequency of messages than the number of concurrent connections, since that's where the implementations really differ.

For a real-world example and discussion about node.js Comet performance, see Amir Salihefendic's excellent blog post here: http://amix.dk/blog/post/19577 (you can follow the links in that post to other posts that are fantastic as well).

Notice that one of the versions he wrote was in C using libevent (epoll) which is what APE uses as well. Also, note that APE's website claims that it can handle over 100,000 concurrent users.

If you really want to understand the problems associated, you might find the famous "C10K problem" article interesting (do a google search for "C10K problem").

In the end, it probably comes down to how many requests per second you expect, and how many machines you have, and which language you prefer to code in. If you're only expecting around 100 concurrent users, I think you'll be just fine using any platform you want. That being said, I highly recommend using node.js--just for sheer enjoyment if nothing else. :-)

like image 85
bitdrift Avatar answered Oct 18 '22 06:10

bitdrift