Node.js test for 1M HTTP Comet connections
This is the server part of my test of 1M concurrent connections on Node.js server. Client part is ec2-fleet and uses Amazon Web Services.
If you can read Russian, see habrahabr article for more details.
See some graphs below.
How it looks like
Reproducing the test
- Dedicated server on your favorite hosting with >=16Gb RAM and >=8 cores, external IP.
- AWS account with 1 dollar. We will use 40 micro instances ($0.02/hr) for 1 hour.
- Prepare server.
- Install fresh Ubuntu 12.04.
- Increase limit on open file descriptors: write
* - nofile 1048576to
git clone git://github.com/ashtuchkin/node-millenium.gitand run
node server.js. Leave this terminal open.
- Set up AWS and ec2-fleet.
- Open EC2 control panel of your AWS account https://console.aws.amazon.com/ec2/home
- Choose 3 regions where you will launch client instances in. In each of them, go to Security Groups,
choose 'default', go to tab 'Inbound' at the bottom, add custom TCP rule: port
0.0.0.0/0. Dont forget to 'Apply Rule Changes'.
- On your laptop,
git clone git://github.com/ashtuchkin/ec2-fleet.git. Edit file
aws-config.jsonto add your AWS security keys and regions you've chosen.
- Start test.
- In separate terminal, issue
./aws.js status. This will give you an overview of all instances in all regions. Leave this open too.
- Start 40 instances in AWS:
./aws.js start 40. Wait ~2 minutes while they are starting.
- Target them to your server:
./aws.js set ip <ip of your server>.
- Gradually increase (in steps of ~2500-5000) the number of connections each instance makes to the server
./aws.js set n <number of connections>until you reach maximum of
- Go have a beer. You have a server with 1 million connections (40*25k).
- Gradually decrease the number of connections (same steps).
- Terminate all aws instances that we started (if you had other instances running, they are not touched):
./aws.js stop all
- Get log from server to make pretty graphs.
Test: node server.js
Dotted line - connection count, with maximum at 1 million.