Hello,
I’m using HAProxy to front a simple node application, using the following acl/backend configuration:
acl acl_myapp hdr(host) -i myapp.service.consul
use_backend backend_myapp if acl_myapp
backend backend_myapp
    balance roundrobin
    option  httpchk GET /health
    server  10.134.20.234_31005 10.134.20.234:31005 maxconn 128  weight 100  check
I am running an ApacheBench test against the application to test the max requests/sec I can achieve with my app.  I am running ab with 300 concurrent requests, and a total of 6000 requests.
When I run ab against my application directly, on port 31005, for example:
ab -n 6000 -c 300 -k "http://10.134.20.234:31005/"
I see numbers like
Requests per second:    1053.19 [#/sec] (mean)
Requests per second:    1104.31 [#/sec] (mean)
Requests per second:    1069.48 [#/sec] (mean)
However, when I go via HAProxy via setting host header, i.e.
ab -H "Host: myapp.service.consul" -n 6000 -c 300 -k "http://10.134.20.234/"
I see numbers like
Requests per second:    699.89 [#/sec] (mean)
Requests per second:    752.43 [#/sec] (mean)
Requests per second:    747.10 [#/sec] (mean)
Which is around 300 req/sec worse than when going direct to the application.
When I look at the statistics using maxconn of 128, I see:
Queue time:  269 ms
Response time:  198 ms
Total time:  467 ms
If I change it to something really high, like 1000, I see:
Queue time:  0 ms
Response time:  418 ms
Total time:  418 ms
And if change the maxconn to something low like 30, I see:
Queue time:  311 ms
Response time:  41 ms
Total time:  386 ms
Any ideas why I’m seeing such a difference when going through HAProxy?