Casual test by ab program through ngrok tunnel

  • ngrokが気になっていたので、以下のような構成でテストをやってみた
  • wifiルータは0001softbank

f:id:nishidy:20150421212754p:plain

  • haproxyで設定した通りにL4-NAT負荷分散されていることを、VM内でphp/sqlite3で簡素なカウンターを実装して目視で確認
  • nginxはsupermarket.chef.ioのBerkshelvesからcookbookを落としてchef-soloで入れてみた
  • ちなみにvagrant shareでもngrokと同じようにvagrantゲストに対してトンネルが張れるが、今回はhaproxyをホストで動かしている
Vagrant.configure(2) do |config|
  config.omnibus.chef_version = :latest
  config.berkshelf.enabled = false

  config.vm.box = "centos65"

  config.vm.network "forwarded_port", guest: 80, host: 10011

  config.vm.provider "virtualbox" do |vb|
    vb.memory = "512"
  end

  config.vm.provision "shell", inline: <<-SHELL
    sudo yum install -y vim php php-fpm php-pdo sqlite
  SHELL

  config.vm.provision :chef_solo do |chef|
    chef.cookbooks_path = ["./berks-cookbooks"]
    chef.add_recipe "nginx"
  end
end
  • haproxyコンフィグ(今回のabテストではbackend web1のみを使用)
  • httpchkでもカウンタをふむとカウントされてしまうので、index.htmlをhttpchkに使い、index.phpをデフォルトindexとしてこちらにカウンタを設置
global
  maxconn 4096
  pidfile tmp/haproxy-queue.pid

defaults
  log global
  log 127.0.0.1 local0
  log 127.0.0.1 local1 notice
  mode http
  timeout connect 3000
  timeout client 10000
  timeout server 10000
  maxconn 2000
  option redispatch
  retries 3
  option httpclose
  option httplog
  option forwardfor
  option httpchk HEAD / HTTP/1.0

frontend web-test
  bind 127.0.0.1:80
  default_backend web1
  acl prefer1to2 path_beg /prefer1to2
  acl prefer2to1 path_beg /prefer2to1
  acl crm hdr_sub(User-Agent) -i Chrome
  acl sfr hdr_sub(User-Agent) -i Safari
  use_backend web1 if prefer1to2 or crm
  use_backend web2 if prefer2to1 or sfr

backend web1
  balance roundrobin
  option httpchk GET /index.html
  server local11 localhost:10011 weight 1  check inter 1000
  server local12 localhost:10012 weight 5 check inter 1000

backend web2
  balance roundrobin
  option httpchk GET /index.html
  server local21 localhost:10021 weight 5 check inter 1000
  server local22 localhost:10022 weight 1  check inter 1000

abテスト

結果

f:id:nishidy:20150531172658p:plain

  • 1 concurrent connection
$ sudo ab -n 50 -c 1 http://xxxxfdc1.ngrok.io/
This is ApacheBench, Version 2.3 <$Revision: 1554214 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking xxxxfdc1.ngrok.io (be patient).....done


Server Software:        nginx/1.0.15
Server Hostname:        xxxxfdc1.ngrok.io
Server Port:            80

Document Path:          /
Document Length:        12 bytes

Concurrency Level:      1
Time taken for tests:   31.934 seconds
Complete requests:      50
Failed requests:        0
Total transferred:      7950 bytes
HTML transferred:       600 bytes
Requests per second:    1.57 [#/sec] (mean)
Time per request:       638.677 [ms] (mean)
Time per request:       638.677 [ms] (mean, across all concurrent requests)
Transfer rate:          0.24 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       26   44  40.5     37     322
Processing:   527  595  23.7    600     634
Waiting:      527  594  23.6    600     634
Total:        558  639  49.9    640     937

Percentage of the requests served within a certain time (ms)
  50%    640
  66%    645
  75%    647
  80%    649
  90%    651
  95%    674
  98%    937
  99%    937
 100%    937 (longest request)
  • 2 concurrent connections
$ sudo ab -n 50 -c 2 http://xxxxfdc1.ngrok.io/
This is ApacheBench, Version 2.3 <$Revision: 1554214 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking xxxxfdc1.ngrok.io (be patient).....done


Server Software:        nginx/1.0.15
Server Hostname:        xxxxfdc1.ngrok.io
Server Port:            80

Document Path:          /
Document Length:        12 bytes

Concurrency Level:      2
Time taken for tests:   16.219 seconds
Complete requests:      50
Failed requests:        0
Total transferred:      7950 bytes
HTML transferred:       600 bytes
Requests per second:    3.08 [#/sec] (mean)
Time per request:       648.761 [ms] (mean)
Time per request:       324.381 [ms] (mean, across all concurrent requests)
Transfer rate:          0.48 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       27   47  42.9     38     253
Processing:   529  602  25.1    606     648
Waiting:      529  601  25.0    605     647
Total:        572  648  55.5    641     901

Percentage of the requests served within a certain time (ms)
  50%    641
  66%    648
  75%    656
  80%    660
  90%    671
  95%    682
  98%    901
  99%    901
 100%    901 (longest request)
  • 5 concurrent connections
$ sudo ab -n 50 -c 5 http://xxxxfdc1.ngrok.io/
Password:
This is ApacheBench, Version 2.3 <$Revision: 1554214 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking xxxxfdc1.ngrok.io (be patient).....done


Server Software:        nginx/1.0.15
Server Hostname:        xxxxfdc1.ngrok.io
Server Port:            80

Document Path:          /
Document Length:        12 bytes

Concurrency Level:      5
Time taken for tests:   6.302 seconds
Complete requests:      50
Failed requests:        0
Total transferred:      7950 bytes
HTML transferred:       600 bytes
Requests per second:    7.93 [#/sec] (mean)
Time per request:       630.216 [ms] (mean)
Time per request:       126.043 [ms] (mean, across all concurrent requests)
Transfer rate:          1.23 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       24   35   6.9     33      49
Processing:   516  592  39.8    587     687
Waiting:      516  591  39.7    587     686
Total:        544  627  40.7    627     720

Percentage of the requests served within a certain time (ms)
  50%    627
  66%    645
  75%    654
  80%    658
  90%    680
  95%    699
  98%    720
  99%    720
 100%    720 (longest request)
  • 10 concurrent connections
$ sudo ab -n 50 -c 10 http://xxxxfdc1.ngrok.io/
This is ApacheBench, Version 2.3 <$Revision: 1554214 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking xxxxfdc1.ngrok.io (be patient).....done


Server Software:        nginx/1.0.15
Server Hostname:        xxxxfdc1.ngrok.io
Server Port:            80

Document Path:          /
Document Length:        13 bytes

Concurrency Level:      10
Time taken for tests:   3.328 seconds
Complete requests:      50
Failed requests:        8
   (Connect: 0, Receive: 0, Length: 8, Exceptions: 0)
Total transferred:      7992 bytes
HTML transferred:       642 bytes
Requests per second:    15.02 [#/sec] (mean)
Time per request:       665.653 [ms] (mean)
Time per request:       66.565 [ms] (mean, across all concurrent requests)
Transfer rate:          2.34 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       19   36   6.5     37      54
Processing:   515  590  94.2    548     824
Waiting:      514  590  94.3    548     824
Total:        548  627  94.9    589     862

Percentage of the requests served within a certain time (ms)
  50%    589
  66%    596
  75%    619
  80%    704
  90%    819
  95%    826
  98%    862
  99%    862
 100%    862 (longest request)
  • 結果だけ見ると、公衆wifiルータでも5ポート以上は同時に開いてくれているようだ