I'm trying to make a simple load balancing using haProxy. My config:
global
log /dev/log local0
log 127.0.0.1 local1 notice
maxconn 200000
user haproxy
group haproxy
daemon
defaults
log global
mode http
option httplog
option dontlognull
retries 3
option redispatch
maxconn 200000
timeout connect 5000
timeout client 50000
timeout server 50000
frontend front
bind *:80
mode http
default_backend back
backend back
mode http
balance roundrobin
option httpclose
option forwardfor
server webserver01 127.0.0.1:5001 check
server webserver02 127.0.0.1:5002 check
server webserver03 127.0.0.1:5003 check
server webserver04 127.0.0.1:5004 check
server webserver05 127.0.0.1:5005 check
server webserver06 127.0.0.1:5006 check
listen sts *:1936
mode http
stats enable
stats uri /
And I have a six instances of Flask, each on diffrent port according to config.
In Flask function is only time.sleep(5) and return.
When I opening the haproxy IP in browser - it's working - I have the roundrobin strategy working.
But when I opening 3 or more pages with this IP I received strange situation. I think that haProxy should redirect traffic to one of my Flask instances but when I open first time this IP in browser and I'm waiting for response (sleep in Flask) and open second page, the second page will be loaded when first is loaded + 5 seconds (time.sleep). And the third page is similar - it will be loaded when second is loaded + 5 seconds.
I think that this is not valid beacuse when haProxy redirect traffic from one request to one instance of Flask and second request to second instance - this requests should be seperated from each other.. I should have response from each request in 5 second. Not in 5, 10, 15, 20..
Could someone help me with it?
Best regards, Matt.