Skip to content

Instantly share code, notes, and snippets.

@haproxytechblog
Last active November 29, 2019 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haproxytechblog/289e43df08fb7cbdbf5fa2a71bb5904e to your computer and use it in GitHub Desktop.
Save haproxytechblog/289e43df08fb7cbdbf5fa2a71bb5904e to your computer and use it in GitHub Desktop.
HAProxy 2.1: Supercharged Performance and a Cleaner Codebase
global
h1-case-adjust content-length Content-Length
global
h1-case-adjust-file /etc/haproxy/headers_adjust.map
fcgi-app php-fpm
log-stderr global
option keep-conn
docroot /var/www/html
index index.php
path-info ^(/.+\.php)(/.*)?$
backend be_dynamic
mode http
use-fcgi-app php-fpm
server php-fpm1 192.168.1.71:9000 proto fcgi
server php-fpm2 192.168.1.72:9000 proto fcgi
frontend fe_main
bind :443 ssl crt www.haproxy.com.pem
mode http
use_backend be_dynamic if { path_reg ^/.+\.php(/.*)?$ } || { path / }
default_backend be_static
$ echo "show trace" | socat stdio /run/haproxy/admin.sock
Supported trace sources and states (.=stopped, w=waiting, R=running) :
[.] stream -> none [drp 0] [Applicative stream]
[.] h2 -> none [drp 0] [HTTP/2 multiplexer]
[.] h1 -> none [drp 0] [HTTP/1 multiplexer]
[.] fcgi -> none [drp 0] [FastCGI multiplexer]
$ echo "trace h2 level user; trace h2 sink stderr; trace h2 start now" | socat stdio /run/haproxy/admin.sock
$ socat /run/haproxy/admin.sock readline
prompt
> trace h2 sink buf0
> show events buf0 -w
<0>2019-11-23T13:22:02.287760 [02|h2|0|mux_h2.c:2555] rcvd H2 request : [1] H2 REQ: GET https://localhost:8001/ HTTP/2.0
<0>2019-11-23T13:22:02.288183 [02|h2|0|mux_h2.c:4759] sent H2 response : [1] H2 RES: HTTP/1.1 200 OK
> trace h2 level proto
> show events buf0 -wn
<0>2019-11-23T13:29:15.949293 [03|h2|1|mux_h2.c:2904] received preface
<0>2019-11-23T13:29:15.949318 [03|h2|1|mux_h2.c:3080] receiving H2 SETTINGS frame
<0>2019-11-23T13:29:15.949319 [03|h2|1|mux_h2.c:3085] sending H2 SETTINGS ACK frame
<0>2019-11-23T13:29:15.949320 [03|h2|1|mux_h2.c:3104] receiving H2 WINDOW_UPDATE frame
<0>2019-11-23T13:29:15.949321 [03|h2|1|mux_h2.c:3123] receiving H2 HEADERS frame
<0>2019-11-23T13:29:15.949351 [03|h2|0|mux_h2.c:2555] rcvd H2 request : [1] H2 REQ: GET https://localhost:8001/ HTTP/2.0
<0>2019-11-23T13:29:15.949494 [03|h2|1|mux_h2.c:3080] receiving H2 SETTINGS frame
<0>2019-11-23T13:29:15.949626 [03|h2|0|mux_h2.c:4759] sent H2 response : [1] H2 RES: HTTP/1.1 200 OK
<0>2019-11-23T13:29:15.949631 [03|h2|1|mux_h2.c:5430] ES flag set on outgoing frame
$ echo -e "set ssl cert localhost.pem.rsa <<\n$(cat kikyo.pem.rsa)\n" | socat stdio /run/haproxy/admin.sock
Transaction created for certificate localhost.pem!
$ echo -e "set ssl cert localhost.pem.dsa <<\n$(cat kikyo.pem.dsa)\n" | socat stdio /run/haproxy/admin.sock
Transaction updated for certificate localhost.pem!
$ echo -e "set ssl cert localhost.pem.ecdsa <<\n$(cat kikyo.pem.ecdsa)\n" | socat stdio /run/haproxy/admin.sock
Transaction updated for certificate localhost.pem!
$ echo "commit ssl cert localhost.pem" | socat stdio /run/haproxy/admin.sock
Committing localhost.pem.
Success!
$ ./haproxy -v
HA-Proxy version 2.1.0 2019/11/25 - https://haproxy.org/
Status: stable branch - will stop receiving fixes around Q1 2021.
Known bugs: http://www.haproxy.org/bugs/bugs-2.1.0.html
$ echo "show info desc" | socat stdio tcp-connect:127.0.0.1:9999
CurrConns: 0:"Current number of connections on this worker process"
CumConns: 1:"Total number of connections on this worker process since started"
CumReq: 1:"Total number of requests on this worker process since started"
MaxSslConns: 0:"Hard limit on the number of per-process SSL endpoints (front+back), 0=unlimited"
CurrSslConns: 4:"Current number of SSL endpoints on this worker process (front+back)"
CumSslConns: 99:"Total number of SSL endpoints on this worker process since started (front+back)"
$ echo "show stat typed desc" | socat stdio tcp-connect:127.0.0.1:9999
...
F.2.0.33.rate.1:MRP:u32:0:"Total number of sessions processed by this object over the last second (sessions for listeners/frontends, requests for backends/servers)"
F.2.0.34.rate_lim.1:CLP:u32:0:"Limit on the number of sessions accepted in a second (frontend only, 'rate-limit sessions' setting)"
F.2.0.35.rate_max.1:MMP:u32:0:"Highest value of 'rate' observed since the worker process started"
F.2.0.39.hrsp_1xx.1:MCP:u64:0:"Total number of HTTP responses with status 100-199 returned by this object since the worker process started"
F.2.0.40.hrsp_2xx.1:MCP:u64:0:"Total number of HTTP responses with status 200-299 returned by this object since the worker process started"
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment