Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how many requests a node http server can handle per second without queueing any requests?

Tags:

http

node.js

Does anyone know how many requests a basic single instance of node http server can handle per second without queueing any requests?

Actually, i need to write a nodejs app, that should be able to respond to about thousand incoming requests within 100ms consistently. I'm trying to test it in a 4 cpus server and running 4 instances in cluster mode. but currently it only able to handle less than 1000 requests per second consistently within 100ms

like image 331
Prakash GPz Avatar asked Apr 06 '17 15:04

Prakash GPz


People also ask

How many requests can node handle per second?

They handle 40K requests per second having Node. js (mostly) for the backend.

How many HTTP requests can a server handle per second?

By default, the limits are 1024 for soft limits and 4096 for hard limits. The open files limit is a common limitation where the RPS cannot arise even though the server still have CPU and memory usage room. Higher the open files limit means more requests can be received and made resulting higher RPS.

CAN node server handle multiple requests?

How NodeJS handle multiple client requests? NodeJS receives multiple client requests and places them into EventQueue. NodeJS is built with the concept of event-driven architecture. NodeJS has its own EventLoop which is an infinite loop that receives requests and processes them.

How many concurrent requests can node handle?

To address these issues, Node. JS uses a single thread with an event-loop. In this way, Node can handle 1000s of concurrent connections without any of the traditional detriments associated with threads.


1 Answers

See this answer:

  • How many clients can an http-server can handle?

It's not about queuing but about how many concurrent requests Node can handle at the same time. It contains example benchmarks that you can use and tweak to your needs.

Now, about queuing: in a sense, every request is queued because only one thing can run at the same time in one Node process. So you can say that the answer to how many requests a Node http server can handle without queuing any requests is: one. Just like for Nginx for example.

Now, the time to respond is an entirely different matter and depends on many factors like what you actually do in those requests handlers.

For example a mean time per request that I got in my experiments here for 10000 concurrent connections was less than 2 milliseconds. If it does more then it can take more of course but there is no one number for all Node servers. It depends how efficient is your implementation.

Now, a big no-no for handling concurrency in Node are:

  • Never use any "Sync" function
  • Never use long running for and while loops
  • Never do any CPU-intensive work in your process that handles the reqests
like image 166
rsp Avatar answered Sep 30 '22 16:09

rsp