1

I am using HAProxy for load balance with cookie based session persistence.

Configuration:

backend nodes mode http balance roundrobin cookie SERVER insert indirect nocache server node1 localhost:8080 cookie node1 server node2 localhost:9090 cookie node2 server node3 localhost:9091 cookie node3 server node4 localhost:9092 cookie node4 server node5 localhost:9093 cookie node5 server node6 localhost:9094 cookie node6 

The problem is that I had five servers, perfectly balanced, but I added a new server and sessions are not being rebalanced as I thought they would be. The new server only have a few sessions.

How can I force a rebalance?

2 Answers 2

3

Try using maxidle and maxlife params for the cookie statement.

E.g.

cookie SERVER insert indirect nocache maxidle 30m maxlife 8h 

See the documentation.

1
  • Just curious, why is indirect and maxidle each needed? Commented Oct 25, 2024 at 15:01
0

Just change:

balance roundrobin 

to

balance leastconn 
1
  • this won't redistribute the already existing associations, which are based on cookies Commented Aug 16, 2024 at 7:58

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.