matsumotory / trusterd

Trusterd: High Performance HTTP/2 Web Server scripting with mruby
171 stars 8 forks source link

Performance: nginx(HTTP/1.1) vs Trusterd(HTTP/2) using mruby-http2 engine #1

Closed matsumotory closed 9 years ago

matsumotory commented 10 years ago

2014/05/25 Benchmark

nginx (HTTP/1.1)

Version

$ sudo apt-get install nginx
$ nginx -v
nginx version: nginx/1.4.6 (Ubuntu)

conf

user www-data;
master_process off;
worker_processes 1;

events {
  worker_connections 1024;
  multi_accept on;
}

http {
  sendfile on;
  tcp_nopush on;
  tcp_nodelay on;
  keepalive_timeout 65;
  types_hash_max_size 2048;

  include /etc/nginx/mime.types;
  default_type application/octet-stream;

  access_log off;
  error_log off;

  gzip on;
  gzip_disable "msie6";

・
・
・

content

$ curl http://127.0.0.1/test.html
hello nginx--- world.

Benchmark

$ weighttp -c 100 -n 1000000 http://127.0.0.1/test.html
weighttp - a lightweight and simple webserver benchmarking tool

starting benchmark...
spawning thread #1: 100 concurrent requests, 1000000 total requests
progress:  10% done
progress:  20% done
progress:  30% done
progress:  40% done
progress:  50% done
progress:  60% done
progress:  70% done
progress:  80% done
progress:  90% done
progress: 100% done

finished in 42 sec, 371 millisec and 492 microsec, 23600 req/s, 6015 kbyte/s
requests: 1000000 total, 1000000 started, 1000000 done, 1000000 succeeded, 0 failed, 0 errored
status codes: 1000000 2xx, 0 3xx, 0 4xx, 0 5xx
traffic: 261000000 bytes total, 239000000 bytes http, 22000000 bytes data

Trusterd (HTTP/2 with mruby-http2 engine)

version

Trusterd: bad899053f18a93615d66eb1f4233581713139b7
mruby-http2: https://github.com/matsumoto-r/mruby-http2/commit/32914462c5b52f31c7850b60b3e1568391cfa0c2
nghttp2: https://github.com/tatsuhiro-t/nghttp2/commit/78a55935ace7fb6d617dc3e7106bdca59a712899
mruby: https://github.com/mruby/mruby/commit/8bbde64ead3cfa2ffd3ca9f8f70ed3428fd22cf8

conf

SERVER_NAME = "Trusterd"                                                         
SERVER_VERSION = "0.0.1"                                                         
SERVER_DESCRIPTION = "#{SERVER_NAME}/#{SERVER_VERSION}"                          

root_dir = "/usr/local/trusterd"                                                 

s = HTTP2::Server.new({                                                          

  :port           => 8080,                                                       
  :document_root  => "#{root_dir}/htdocs",                                       
  :server_name    => SERVER_DESCRIPTION,                                                                                         
  :tls => false,                                                                 

})                                                                               

s.run

contents

$ nghttp http://127.0.0.1:8080/index.html
hello trusterd world.

Benchmark

$ h2load -W 30 -w 30 -c 100 -m 100 -n 1000000 http://127.0.0.1:8080/index.html
starting benchmark...
spawning thread #0: 100 concurrent clients, 1000000 total requests
progress: 10% done
progress: 20% done
progress: 30% done
progress: 40% done
progress: 50% done
progress: 60% done
progress: 70% done
progress: 80% done
progress: 90% done
progress: 100% done

finished in 6 sec, 461 millisec and 603 microsec, 154760 req/s, 7560 kbytes/s
requests: 1000000 total, 1000000 started, 1000000 done, 1000000 succeeded, 0 failed, 0 errored
status codes: 1000000 2xx, 0 3xx, 0 4xx, 0 5xx
traffic: 50023900 bytes total, 4021800 bytes headers, 22000000 bytes data

Result

nginx: 23600 req/s

trusterd: 154760 req/s

Benchmark Environment

OS

Ubunt 14.04 64bit on VMWare

CPU

$ cat /proc/cpuinfo 
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 60
model name      : Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz
stepping        : 3
microcode       : 0x9
cpu MHz         : 3498.029
cache size      : 8192 KB
physical id     : 0
siblings        : 1
core id         : 0
cpu cores       : 1
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm ida arat epb xsaveopt pln pts dtherm tpr_shadow vnmi ept vpid fsgsbase smep
bogomips        : 6996.05
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 60
model name      : Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz
stepping        : 3
microcode       : 0x9
cpu MHz         : 3498.029
cache size      : 8192 KB
physical id     : 2
siblings        : 1
core id         : 0
cpu cores       : 1
apicid          : 2
initial apicid  : 2
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm ida arat epb xsaveopt pln pts dtherm tpr_shadow vnmi ept vpid fsgsbase smep
bogomips        : 6996.05
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

Memory

$ free -m
             total       used       free     shared    buffers     cached
Mem:          7978       2101       5876         11        160       1588
-/+ buffers/cache:        352       7625
Swap:         1021          0       1021
csrgxtu commented 9 years ago

I have read the HTTP/2.0 introduction, it is said that "to decrease the latency the HTTP/2.0 use compressed headers and server push techs to implement the fast page loading", and your benchmark test proves the idea was right, thank you.

nanonyme commented 9 years ago

Just a note so no one will be getting false hopes of HTTP2.0: The standard requires header compression to be disabled with HTTPS browsers are only going to implement HTTPS so there will effectively be no header compression in HTTP2.0