Hi,
I’ve been tested HTTP2 in haproxy 1.8, and seems HTTP2 is not faster than HTTP1.1 in haproxy.
Here are the test result:
HTTP2
root@client9:~# h2load -n 1000000 -c 10 -m 20 https://www.example.com
starting benchmark...
spawning thread #0: 10 total client(s). 1000000 total requests
TLS Protocol: TLSv1.2
Cipher: ECDHE-RSA-AES256-GCM-SHA384
Server Temp Key: ECDH P-256 256 bits
Application protocol: h2
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 32.96s, 30338.35 req/s, 21.84MB/s
requests: 1000000 total, 1000000 started, 1000000 done, 1000000 succeeded, 0 failed, 0 errored, 0 timeout
status codes: 1000000 2xx, 0 3xx, 0 4xx, 0 5xx
traffic: 720.02MB (755000240) total, 119.21MB (125000000) headers (space savings 32.80%), 583.65MB (612000000) data
min max mean sd +/- sd
time for request: 736us 29.84ms 5.62ms 1.37ms 68.33%
time for connect: 3.95ms 7.62ms 5.78ms 1.36ms 60.00%
time to 1st byte: 6.31ms 13.75ms 9.17ms 2.63ms 60.00%
req/s : 3033.88 4628.95 3653.63 663.31 90.00%
root@client9:~#
HTTP1.1
root@client9:~# h2load -n 1000000 -c 10 -m 20 https://www.example.com
starting benchmark...
spawning thread #0: 10 total client(s). 1000000 total requests
TLS Protocol: TLSv1.2
Cipher: ECDHE-RSA-AES256-GCM-SHA384
Server Temp Key: ECDH P-256 256 bits
No protocol negotiated. Fallback behaviour may be activated
Server does not support NPN/ALPN. Falling back to HTTP/1.1.
Application protocol: http/1.1
No protocol negotiated. Fallback behaviour may be activated
Server does not support NPN/ALPN. Falling back to HTTP/1.1.
No protocol negotiated. Fallback behaviour may be activated
Server does not support NPN/ALPN. Falling back to HTTP/1.1.
No protocol negotiated. Fallback behaviour may be activated
Server does not support NPN/ALPN. Falling back to HTTP/1.1.
No protocol negotiated. Fallback behaviour may be activated
Server does not support NPN/ALPN. Falling back to HTTP/1.1.
No protocol negotiated. Fallback behaviour may be activated
Server does not support NPN/ALPN. Falling back to HTTP/1.1.
No protocol negotiated. Fallback behaviour may be activated
Server does not support NPN/ALPN. Falling back to HTTP/1.1.
No protocol negotiated. Fallback behaviour may be activated
Server does not support NPN/ALPN. Falling back to HTTP/1.1.
No protocol negotiated. Fallback behaviour may be activated
Server does not support NPN/ALPN. Falling back to HTTP/1.1.
No protocol negotiated. Fallback behaviour may be activated
Server does not support NPN/ALPN. Falling back to HTTP/1.1.
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 22.86s, 43738.68 req/s, 34.83MB/s
requests: 1000000 total, 1000000 started, 1000000 done, 1000000 succeeded, 0 failed, 0 errored, 0 timeout
status codes: 1000000 2xx, 0 3xx, 0 4xx, 0 5xx
traffic: 796.32MB (835000000) total, 167.85MB (176000000) headers (space savings 0.00%), 583.65MB (612000000) data
min max mean sd +/- sd
time for request: 1.24ms 22.40ms 4.40ms 1.40ms 78.87%
time for connect: 3.62ms 15.69ms 8.56ms 3.89ms 80.00%
time to 1st byte: 5.92ms 21.85ms 13.02ms 5.01ms 70.00%
req/s : 4373.94 4839.08 4549.50 154.24 60.00%
root@client9:~#
root@haproxy-1-6:~# ./haproxy-1.8.25/haproxy -v
HA-Proxy version 1.8.25 2020/04/02
Copyright 2000-2020 Willy Tarreau <willy@haproxy.org>
root@haproxy-1-6:~#
root@haproxy-1-6:~# diff haproxy.cfg haproxy.http2.cfg
15a16,17
> # log 127.0.0.1 local0 info
>
58c60,61
< bind *:443 ssl crt-list /usr/local/etc/cert_list_lbl-afusldyn no-sslv3
---
> bind *:443 ssl crt-list /usr/local/etc/cert_list_lbl-afusldyn no-sslv3 alpn h2,http/1.1
> # bind *:443 ssl crt-list /usr/local/etc/cert_list_lbl-afusldyn no-sslv3 alpn http/1.1,h2
root@haproxy-1-6:~#
Also, what bother me is that HTTP2 requires web server tuned to speed web load, like ngx_http_v2_module in nginx, we need to configure http2_push
to enable server pushing feature in HTTP2.
So as a pure proxy, is it helpful to enable H2 in haproxy? Can haproxy speed up web load using H2? Is H2 in haproxy still incomplete?