LEARNNode CLI Automation

Node.js: Backend JavaScript

You can easily run JavaScript on your backend with Node.js. Node.js along with Express.js lets you create everything you need for your backend, from server to routes to data models.

The best server is the one that can easily handle huge surges of traffic. So there might be some doubts about whether the server built with Node.js can handle such amount of traffic. To clear this out, I am going to do a Node.js server test with a load testing library to determine what kind of surges it can easily handle.

Testing Node.js Server

To do all this, I am going to copy-paste this code from the Nodejs.org website. This code allows me to create a Node.js server. So let’s do that.

Create Server

I am also going to add a count that will let me know the number of requests/visits my server is receiving.

Now I am going to use a load testing library called loadtest that you can easily find on npm. And with this, I am going to send 10 concurrent requests with 100 requests per second.

loadtest Requests

As you can see in the image below that I am getting 100 requests per second. Among all these requests, 10 of them are concurrent.

Receiving Requests

Now I am going to use Postman to send a request to our server while also getting all these requests behind the scene.

And as you can see that I am still getting a decent response time even during huge traffic.

Postman testing

Wrapping Up

This might not be the best way to do this server testing but it still gives the generic idea that Node.js server can handle traffic easily. You should definitely try it out and test your Node server as well if you have any doubts. You can use the library I used or you can easily use some testing libraries.

Posted by Saad (It's a work in progress: Needs copy editing review by Awais.)