4

As the title suggested, I need nodejs and mongodb to handle 5000 requests per second. Right off the bat that is. We'll grow to many times that eventually.

My initial thoughts are to put each on separate machines, though I'm not sure if I should start with small machines and prepare to scale out soon, or start with larger machines and scale out later.

Either way I fully expect to eventually scale these two out, but Im wondering what the upscale trigger would be. Would I scale on CPU or memory usage? If on CPU what should I try to keep average CPU usage under?

Oh and yes I will be buying support from 10gen so they can review my document model and ensure that I'm storing data in the most efficient way.

Jonas
  • 1,187
  • 5
  • 19
  • 33
talentedmrjones
  • 235
  • 3
  • 8
  • 2
    You set your scale trigger on whatever your bottleneck is, or will likely be. None of us can tell you what that will be - you need to profile your application, do in-depth load testing, and see what shakes out. – EEAA Sep 28 '11 at 02:35
  • 2
    Also, you say you need "nodejs and mongodb to handle 5000 requests per second". Which one of those gets those requests? Split evenly between the two? That would assume that each node.js request spawns only one mongodb request. – EEAA Sep 28 '11 at 02:52
  • @ErikA I understand what you're saying about the unknown bottleneck, thanks for that. We have been doing some load testing but have not yet pushed our current architecture to a bottleneck. Generally speaking though what would be a good percentage to keep CPU usage under? – talentedmrjones Sep 28 '11 at 04:19
  • Oh and both node and mongo will get each request. In some cases 1 node request may in turn incur 2 or 3 mongo requests. But for this particular case, each gets 5000. – talentedmrjones Sep 28 '11 at 04:22
  • 1
    "Generally speaking", there is no number you should keep your CPU under. If you have a quad-core system and your application is performing well at a load average of 12, then more power to you. You really need to test and determine these things yourself. Much more is reflected in CPU load averages than just what the CPU is doing. – EEAA Sep 28 '11 at 04:28
  • Thanks for the input ErikA that does indeed help. If you would post your comments as an answer I'll be happy to accept it and we'll both get a few more points :) – talentedmrjones Sep 28 '11 at 17:36

2 Answers2

4

"Generally speaking", there is no number you should keep your CPU under. If you have a quad-core system and your application is performing well at a load average of 12, then more power to you. You really need to test and determine these things yourself. Much more is reflected in CPU load averages than just what the CPU is doing.

EEAA
  • 109,363
  • 18
  • 175
  • 245
1

I'll leave basic performance tweaks like client-side-rendering, parallelism, caching, nginx etc. to your googling skills and skip to some exclusive ones,

1. Disable Nagle's Algorithm: If you’re familiar at all with real-time network programming, you’ll recognize this algorithm as a common socket tweak. This makes each response leave the server much quicker.

The tweak is available through the node.js API socket.setNoDelay, which is set on each long-poll COMET connection’s socket.

2. Mongodb Connection Pooling: Creating new authenticated connections to the database is expensive. So, instead of creating and destroying connections for each request to the database, you want to re-use existing connections as much as possible.

You can find a lot of other performance tweaks on airpair or medium but in your case, these two will affect the most.

Note: You deployment topology and load balancing strategy will also make a real difference. I'd say, use a NGINX as RP in front of your node-server and let it handle all the load-balancing between your multiple node instances!

  • Hi, I have a single mongodb connection on my node webserver that connects on server initialization and I am reusing that connection in all Express routes. Could that lead to issues when number of concurrent requests increase? – Kunok Jul 25 '17 at 14:57