Created
June 1, 2015 17:34
-
-
Save kazeburo/71603b4bc0994e2222b4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Server | |
EC2 c4.8xlarge | |
Amazon Linux | |
## Software | |
``` | |
sudo yum install -y make gcc git curl tar bzip2 patch nginx openssl-devel strace | |
git clone https://github.com/tagomoris/xbuild.git | |
./xbuild/perl-install 5.22.0-RC2 ~/local/perl-5.22 -j30 | |
export PATH=/home/ec2-user/local/perl-5.22/bin:$PATH | |
cpanm -n Gazelle Starlet HTTP::Parser::XS Starman Cache::Memcached::Fast JSON::XS | |
``` | |
### wrk | |
``` | |
git clone https://github.com/wg/wrk.git | |
cd wrk | |
make | |
``` | |
## tune kernel | |
``` | |
sudo sysctl -w net.core.netdev_max_backlog=8192 | |
sudo sysctl -w net.core.somaxconn=32768 | |
sudo sysctl -w net.ipv4.tcp_tw_recycle=1 | |
sudo sysctl -w net.ipv4.tcp_tw_reuse=1 | |
sudo sysctl -w net.ipv4.tcp_fin_timeout=2 | |
``` | |
# benchmark | |
## Hello world | |
### Gazelle | |
``` | |
[ec2-user@ip- ~]$ start_server --backlog=16384 --path=/dev/shm/app.sock -- plackup -s Gazelle --max-workers 8 --max-reqs-per-child 500000 -E prod -e 'sub{[200,[],["hello world\n"]]}' | |
[ec2-user@ip- wrk]$ ./wrk -t 4 -c 500 -d 30 http://localhost/ | |
Running 30s test @ http://localhost/ | |
4 threads and 500 connections | |
Thread Stats Avg Stdev Max +/- Stdev | |
Latency 2.89ms 18.07ms 393.39ms 99.24% | |
Req/Sec 84.15k 11.76k 102.21k 89.42% | |
10045243 requests in 30.01s, 1.41GB read | |
Requests/sec: 334752.37 | |
Transfer/sec: 48.19MB | |
``` | |
### Starlet | |
``` | |
[ec2-user@ip- ~]$ start_server --backlog=16384 --path=/dev/shm/app.sock -- plackup -s Starlet --max-workers 8 --max-reqs-per-child 500000 -E prod -e 'sub{[200,[],["hello world\n"]]}' | |
[ec2-user@ip- wrk]$ ./wrk -t 4 -c 500 -d 30 http://localhost/ | |
Running 30s test @ http://localhost/ | |
4 threads and 500 connections | |
Thread Stats Avg Stdev Max +/- Stdev | |
Latency 6.00ms 9.34ms 230.74ms 99.46% | |
Req/Sec 23.13k 2.28k 27.40k 81.00% | |
2761130 requests in 30.00s, 397.48MB read | |
Requests/sec: 92026.70 | |
Transfer/sec: 13.25MB | |
``` | |
### starman | |
``` | |
[ec2-user@ip- ~]$ starman --listen /dev/shm/app.sock --backlog=16384 --workers 8 --max-requests 500000 -E prod --preload-app --disable-keepalive -e 'sub{[200,[],["hello world\n"]]}' | |
[ec2-user@ip- wrk]$ ./wrk -t 4 -c 500 -d 30 http://localhost/ | |
Running 30s test @ http://localhost/ | |
4 threads and 500 connections | |
Thread Stats Avg Stdev Max +/- Stdev | |
Latency 10.81ms 7.90ms 193.00ms 91.54% | |
Req/Sec 12.29k 2.65k 17.58k 65.83% | |
1467607 requests in 30.02s, 211.27MB read | |
Requests/sec: 48887.84 | |
Transfer/sec: 7.04MB | |
``` | |
## counter | |
### psgi | |
``` | |
use Plack::Builder; | |
use Plack::Request; | |
use Cache::Memcached::Fast; | |
use JSON::XS; | |
my $_JSON = JSON::XS->new->utf8; | |
my $mem = Cache::Memcached::Fast->new({servers=>[qw/127.0.0.1:11211/]}); | |
$mem->set('counter:1',0); | |
$mem->disconnect_all; | |
builder { | |
enable 'AccessLog', logger => sub { }; | |
sub { | |
my $env = shift; | |
my $req = Plack::Request->new($env); | |
my $id = $req->parameters->{id}; | |
my $counter = $mem->incr('counter:'.$id); | |
[200, ['Content-Type'=>'application/json; charset=UTF-8'], [$_JSON->encode({counter=>$counter})]]; | |
} | |
}; | |
``` | |
### Gazelle | |
``` | |
[ec2-user@ip- ~]$ start_server --backlog=16384 --path=/dev/shm/app.sock -- plackup -s Gazelle --max-workers 16 --max-reqs-per-child 500000 -E prod -a app.psgi | |
[ec2-user@ip- wrk]$ ./wrk -t 4 -c 500 -d 30 'http://localhost/?id=1' | |
Running 30s test @ http://localhost/?id=1 | |
4 threads and 500 connections | |
Thread Stats Avg Stdev Max +/- Stdev | |
Latency 5.51ms 6.34ms 178.38ms 99.57% | |
Req/Sec 24.27k 1.67k 27.08k 87.92% | |
2897691 requests in 30.00s, 574.66MB read | |
Requests/sec: 96577.25 | |
Transfer/sec: 19.15MB | |
``` | |
### Starlet | |
``` | |
[ec2-user@ip- ~]$ start_server --backlog=16384 --path=/dev/shm/app.sock -- plackup -s Starlet --max-workers 16 --max-reqs-per-child 500000 -E prod -a app.psgi | |
[ec2-user@ip- wrk]$ ./wrk -t 4 -c 500 -d 30 'http://localhost/?id=1' | |
Running 30s test @ http://localhost/?id=1 | |
4 threads and 500 connections | |
Thread Stats Avg Stdev Max +/- Stdev | |
Latency 9.42ms 16.46ms 352.30ms 99.26% | |
Req/Sec 15.22k 1.44k 17.45k 89.50% | |
1817375 requests in 30.01s, 359.36MB read | |
Requests/sec: 60561.77 | |
Transfer/sec: 11.98MB | |
``` | |
### starman | |
``` | |
[ec2-user@ip- ~]$ starman --listen /dev/shm/app.sock --backlog=16384 --workers 16 --max-requests 500000 -E prod --preload-app --disable-keepalive -a app.psgi | |
[ec2-user@ip- wrk]$ ./wrk -t 4 -c 500 -d 30 'http://localhost/?id=1' | |
Running 30s test @ http://localhost/?id=1 | |
4 threads and 500 connections | |
t2 Thread Stats Avg Stdev Max +/- Stdev | |
Latency 13.06ms 18.95ms 385.51ms 98.31% | |
Req/Sec 10.96k 2.09k 13.84k 71.33% | |
1307919 requests in 30.01s, 258.32MB read | |
Requests/sec: 43588.36 | |
Transfer/sec: 8.61MB | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment