5

I created test with JMeter to test performance of Ghost blogging platform. Ghost written in Node.js and was installed in cloud server with 1Gb RAM, 1 CPU.

I noticed after 400 concurrent users JMeter getting errors. Till 400 concurrent users load is normal. I decide increase CPU and added 1 CPU.

But errors reproduced and added 2 CPUs, totally 4 CPUs. The problem is occuring after 400 concurrent users.

I don't understand why 1 CPU can handle 400 users and the same results with 4 CPUs.

During monitoring I noticed that only one CPU is busy and 3 other CPUs idle. When I check JMeter summary in console there were errors, about 5% of request. See screenshot.

CPU Utilisation

I would like to know is it possible to balance load between CPUs?

pradyunsg
  • 18,287
  • 11
  • 43
  • 96
Bob Meliev
  • 1,198
  • 12
  • 17
  • 4
    you might also want to check your open file limit with `ulimit -n`. That constrains the number of concurrent requests node can handle. You can increase it (for local session) using `ulimit -n 10000`. To create a cluster of your ghost server processes, you can try pm2. Just install pm2 with `npm install pm2 -g` and `pm2 start .js` – Mukesh Soni Feb 18 '14 at 05:49
  • The problem is solved partially. Here are steps and results I got: 1. Changed ulimit to 10000. Result: no changes. 2. Enabled Node cluster module. Result: +200 concurrent users 3. Tuned up Nginx worker processe. Result: +2k concurrent users I can assume that problem was with Nginx. When I tested server without cluster module, server handled 2000 users. I will try to enable cluster module when I reach the limit. – Bob Meliev Feb 19 '14 at 07:34

3 Answers3

4

Are you using cluster module to load-balance and Node 0.10.x?

If that's so, please update your node.js to 0.11.x.

Node 0.10.x was using balancing algorithm provided by an operating system. In 0.11.x the algorithm was changed, so it will be more evenly distributed from now on.

alex
  • 11,935
  • 3
  • 30
  • 42
3

Node.js is famously single-threaded (see this answer): a single node process will only use one core (see this answer for a more in-depth look), which is why you see that your program fully uses one core, and that all other cores are idle.

The usual solution is to use the cluster core module of Node, which helps you launch a cluster of Node processes to handle the load, by allowing you to create child processes that all share the same server ports.

However, you can't really use this without fixing Ghost's code. An option is to use pm2, which can wrap a node program, by using the cluster module for you. For instance, with four cores:

$ pm2 start app.js -i 4

In theory this should work, except if Ghost relies on some global variables (that can't be shared by every process).

Community
  • 1
  • 1
Paul Mougel
  • 16,728
  • 6
  • 57
  • 64
  • An alternative to pm2 for automagically utilizing more cores is running the node app via Phusion Passenger - https://github.com/phusion/passenger/wiki/Phusion-Passenger%3A-Node.js-tutorial#wiki-maximum-number-of-processes – Karolis Feb 18 '14 at 10:41
  • is passenger free or paid ? – Rizwan Patel Feb 29 '16 at 12:07
2

Use cluster core and for load balancing nginx. Thats bad part about node.js. Fantastic framework, but developer has to enter into load balancing mess. While java and other runtimes makes is seamless. Anyway, nothing is perfect.

navaltiger
  • 884
  • 12
  • 27