I did a test with ab -n 10000 -c 1000
against node.js with different configurations, each returning the string Hello World!
. Results seems odd to me.
X axis is the number of requests, y is the response time in milliseconds.
- Node is the server alone
- Node (cluster) is a server using the
cluster
module (two cores) - Nginx (balancer) is acting as a balancer in front of (two) node instances running the same code
The first thing is nginx is too slow as balancer, it has the worst result among the three. It's better than node alone only until 1000 requests (but slower than cluster). Another strange thing is that node alone has a constant response time until ~7000 (?). Starting from ~7000 requests, the cluster has a response time greater than node, and this seems too odd.
How would you interpret these results? Am I'm doing it wrong (bench or plotting errors)?
ApacheBench 2.3 (1430300), Node.js 0.10.5, nginx 1.4.1. Running on Xubuntu 13.04 x64.
It is a matter of interpretation. You are not doing anything wrong. Here is how i interpret the graph. It is a distribution plot of x vs y where :
Statements based on distribution of request for node(alone) would be :
But when analysing cumulatively it would be :
Cluster configuration will show faster results than single node as expected.
For the nginx results there will be a fixed amount of delay in processing/load balancing. Looking at the figure it would be about 9-10 ms delay, which is as expected. This does not mean that nginx configuration is a bad performer. It does returns most requests within 30 ms (small difference from other configurations).
You gave concurrent requests as 1000 in Apache Bench, which does not require much load balancing to do as even single node is handling that much load easily. Giving more concurrent connections/heavier processing per request will blow up the graph for single node(it will rise early for lesser number of requests). Nginx sacrifices small processing time to allow more concurrent requests to be handled while still keeping response time reasonable.