Hi All,
is it possible to have connection reuse and http keepalive at server-side with url balancing?
For example, I have two clients with keepalive executing requests
Client 1 connection:
GET /server1-url1
GET /server2-url1
Client 2 connection:
GET /server2-url2
GET /server1-url2
and it goes through two connections from HAProxy to servers:
connection 1 to server 1:
GET /server1-url1
GET /server1-url2
connection 2 to server 2:
GET /server2-url1
GET /server2-url2
(ordering doesn’t matter, the main idea is connection reuse)
I tried the following config (HAProxy version is 1.5.4-2.el6_7.1), my clients do not reconnect to HAProxy, but it keeps reconnecting to backend, utilises 100% cpu and works slower than a single server without HAProxy:
global
log 127.0.0.1 local2
chroot /var/lib/haproxy pidfile /var/run/haproxy.pid maxconn 400000 user haproxy group haproxy daemon
stats socket /var/lib/haproxy/stats
defaults
mode http
option dontlognull
option forwardfor except 127.0.0.0/8
option redispatch
option http-keep-alive
retries 1
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 300000
listen stats :1936
mode http
stats enable
stats hide-version
stats realm Haproxy\ Statistics
stats uri /
stats auth private:hastats777
frontend main *:80
acl url_static path_beg -i /stats
use_backend static if url_static default_backend mybackend
backend static
balance roundrobin
server static host1:8080 check
backend mybackend
balance uri depth 2
hash-type consistent
mode http
server back1 host1:8080 check
server back2 host2:8080 check