Just Another Friday Night Chat: Scaling, Node.js and the Event Loop

You know how it is. You get some code-happy people together after work on a Friday evening. There’s talk of some cool trailer that is making the rounds online, someone wonders if this is the best place for chicken wings, and someone asks that question again:

“How do I know when to scale my Node.js server?”

As always, someone chimes in with the answer: “That’s easy. When your Event Loop shows signs of blockage gets behind.” There is a sip of a drink and the answer continues. “Just monitor your Event Loop. If it starts to back up more than 200ms on a regular basis, you’ll need to scale.”

The question morphs into how you should watch that Event Loop. The answers don’t always fly as fast and furiously here, so we thought we’d contribute some ideas.

Monitoring the Event Loop is where NodeFly enters the picture. In addition to a myriad of other monitoring capabilities, the NodeFly agent also provides timing data for the Event Loop by patching the nextTick function.  And it displays block frequency and block time average (in ms) on graphs that are easy on the eyes.

Now you know there is a problem keeping the Event Loop on track and you have used NodeFly to help figure out what the problem is.  Congrats – time to scale up.

So there you have it.  The next time the topic of Node.js comes up on a Friday night, you are armed and ready for response.

Be sure to enjoy a drink and some wings while you are at it.