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.
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.
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.
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.
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.
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.