Created
July 2, 2014 05:12
-
-
Save fujiwara/47939b474bd8bf136312 to your computer and use it in GitHub Desktop.
stud / HAProxy SSL benchmark
This file contains 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
[ client ] --> [ :8443 stud ] --> [ :8888 haproxy ] ---> [ :80 nginx ] | |
+---------------------------> [ :9443 haproxy ] -/ |
This file contains 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
# haproxy 1.5 required | |
# USE_OPENSSL=1 make TARGET=linux2628 USE_OPENSSL=1 | |
global | |
maxconn 4096 | |
daemon | |
nbproc 8 | |
log 127.0.0.1 local6 | |
user haproxy | |
group haproxy | |
defaults | |
log global | |
timeout connect 5000ms | |
timeout client 50000ms | |
timeout server 50000ms | |
listen https | |
mode http | |
bind *:8888 accept-proxy # studから来たPROXY PROTOCOLを受ける | |
bind *:9443 ssl crt /tmp/cert.pem | |
option forwardfor | |
option http-server-close # forwardfor, reqaddの書き換えは最初の1回しか起きないのでサーバ側はkeepalive offにする必要がある | |
option log-health-checks | |
reqadd X-Forwarded-Proto:\ https | |
default_backend local | |
backend local | |
mode http | |
option httpchk GET /ping HTTP/1.0 | |
server host1 127.0.0.1:80 check inter 5000 |
This file contains 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
$ K=1 T=10 C=50 perl sslbench.pl https://www01:8443/ | |
[INFO] url: https://www01:8443/ at sslbench.pl line 9 | |
[INFO] keepalive requests 1 at sslbench.pl line 11 | |
[INFO] starting benchmark: concurrency: 50, time: 10 | |
[INFO] done benchmark: score 12334, elapsed 10.046 sec = 1227.749 / sec | |
$ K=1 T=10 C=50 perl sslbench.pl https://www01:9443/ | |
[INFO] url: https://www01:9443/ at sslbench.pl line 9 | |
[INFO] keepalive requests 1 at sslbench.pl line 11 | |
[INFO] starting benchmark: concurrency: 50, time: 10 | |
[INFO] done benchmark: score 9333, elapsed 10.045 sec = 929.083 / sec | |
$ K=2 T=10 C=50 perl sslbench.pl https://www01:8443/ | |
[INFO] url: https://www01:8443/ at sslbench.pl line 9 | |
[INFO] keepalive requests 2 at sslbench.pl line 11 | |
[INFO] starting benchmark: concurrency: 50, time: 10 | |
[INFO] done benchmark: score 20578, elapsed 10.047 sec = 2048.124 / sec | |
$ K=2 T=10 C=50 perl sslbench.pl https://www01:9443/ | |
[INFO] url: https://www01:9443/ at sslbench.pl line 9 | |
[INFO] keepalive requests 2 at sslbench.pl line 11 | |
[INFO] starting benchmark: concurrency: 50, time: 10 | |
[INFO] done benchmark: score 17582, elapsed 10.046 sec = 1750.121 / sec | |
$ K=5 T=10 C=50 perl sslbench.pl https://www01:8443/ | |
[INFO] url: https://www01:8443/ at sslbench.pl line 9 | |
[INFO] keepalive requests 5 at sslbench.pl line 11 | |
[INFO] starting benchmark: concurrency: 50, time: 10 | |
[INFO] done benchmark: score 43215, elapsed 10.055 sec = 4297.895 / sec | |
$ K=5 T=10 C=50 perl sslbench.pl https://www01:9443/ | |
[INFO] url: https://www01:9443/ at sslbench.pl line 9 | |
[INFO] keepalive requests 5 at sslbench.pl line 11 | |
[INFO] starting benchmark: concurrency: 50, time: 10 | |
[INFO] done benchmark: score 38620, elapsed 10.064 sec = 3837.318 / sec | |
$ K=10 T=10 C=50 perl sslbench.pl https://www01:8443/ | |
[INFO] url: https://www01:8443/ at sslbench.pl line 9 | |
[INFO] keepalive requests 10 at sslbench.pl line 11 | |
[INFO] starting benchmark: concurrency: 50, time: 10 | |
[INFO] done benchmark: score 68540, elapsed 10.056 sec = 6815.914 / sec | |
$ K=10 T=10 C=50 perl sslbench.pl https://www01:9443/ | |
[INFO] url: https://www01:9443/ at sslbench.pl line 9 | |
[INFO] keepalive requests 10 at sslbench.pl line 11 | |
[INFO] starting benchmark: concurrency: 50, time: 10 | |
[INFO] done benchmark: score 62030, elapsed 10.087 sec = 6149.510 / sec |
This file contains 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
#!/usr/bin/env perl | |
use strict; | |
use Furl; | |
use IO::Socket::SSL; | |
use Parallel::Benchmark; | |
use Log::Minimal; | |
my $url = shift; | |
infof "url: %s", $url; | |
my $keep_alive_req = $ENV{K} || 1; | |
infof "keepalive requests %d", $keep_alive_req; | |
sub ua { | |
Furl->new( | |
ssl_opts => { | |
SSL_verify_mode => SSL_VERIFY_NONE(), | |
}, | |
); | |
} | |
my $bench = Parallel::Benchmark->new( | |
time => $ENV{T} || 5, | |
concurrency => $ENV{C} || 1, | |
benchmark => sub { | |
my ($self, $n) = @_; | |
my $ua = ua; | |
my $success = 0; | |
for ( 1 .. $keep_alive_req ) { | |
my $res = $ua->get($url); | |
if ($res->is_success) { | |
$success++; | |
} | |
else { | |
critf "failed. %s", $res->status_line; | |
die; | |
} | |
} | |
return $success; | |
}, | |
); | |
$bench->run; |
This file contains 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
# https://github.com/bumptech/stud | |
frontend = "[*]:8443" | |
backend = "[127.0.0.1]:8888" | |
pem-file = "cert.pem" | |
ciphers = "" | |
prefer-server-ciphers = off | |
ssl-engine = "" | |
workers = 8 | |
backlog = 1024 | |
keepalive = 3600 | |
chroot = "" | |
user = "" | |
group = "" | |
quiet = off | |
syslog = off | |
syslog-facility = "daemon" | |
daemon = off | |
write-ip = off | |
write-proxy = on # haproxyのPROXY PROTOCOLに対応 | |
proxy-proxy = off |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment