Hi, I have 2 questions about a haproxy setup I configured.
This is the setup: LB server (haproxy 1.4.20, debian squeeze 64-bit) in http mode, forwarding requests to a single nginx web server, that resides on a different machine. I'll paste the haproxy config at the end of this message. 1. Benchmarking: When doing some benchmarking with 'ab' or 'siege', for a small (2 bytes, single char) file: ab -n 10000 -c 40 http://lb/test.html VS ab -n 10000 -c 40 http://web-01/test.html web-01 directly gets 6000-6500 requests/sec. haproxy->nginx gets 3000 requests/sec. When using ab -k to enable keepalives, nginx is getting >12,000 requests/sec, and haproxy gets around 6000-7000 requests/sec. I wanted to ask if the x2 difference is normal? I tried to remove the ACL for checking if the path ends with PHP, the results were not different. 2. As you can see, I separate the dynamic (PHP) requests from other (static) requests. a. Is this the way to do it (path_end .php) ? b. I limit the number of connections to the dynamic backend server(s). I just set it according to the number of FastCGI PHP processes available on that machine. How do I check/benchmark what is the limit for the static backend? Or is it not needed? My nginx config is quite trivial. Here is my haproxy config: global daemon user haproxy group proxy log 127.0.0.1 local0 log-send-hostname maxconn 20000 defaults mode http log global retries 2 timeout client 90s # Client and server timeout must match the longest. timeout server 90s # Time we may wait for a response from the server. timeout queue 90s # Don't queue requests too long if saturated. timeout connect 4s # There's no reason to change this one. option abortonclose # Close aborted connections if they still didn't reach a backend (e.g still in a queue). option http-server-close # Enable HTTP connection closing on the server (backend) side. frontend public bind :80 maxconn 19500 option httplog # Add the backend server ID as a response header rspadd X-Backend:\ 0 if { srv_id 1 } rspadd X-Backend:\ 1 if { srv_id 2 } # Use dynamic backend if the request path ends with .php, fallback to the default static otherwise acl url_dynamic path_end .php use_backend dynamic if url_dynamic default_backend static backend dynamic balance roundrobin option forwardfor except 127.0.0.1 # Set the client IP in X-Forwarded-For except for when the client IP is loopback (nginx SSL termination). server web web:80 maxconn 50 check disabled server web-01 web-01:80 maxconn 50 check backend static balance roundrobin server web web:80 check disabled server web-01 web-01:80 check # Enable the stats page on a dedicated port (8888) listen stats # Uncomment 'disabled' below to disable the stats page # disabled bind :8888 stats uri / stats realm HAProxy\ Statistics stats auth admin:mypassword Thanks! Bar.