10

I'm attempting to modify my current haproxy configuration to favor 1 server over the others (70%,15,15) Does anyone know if this is possible? Reading the docs I see a "weight" option, but I'm a bit weary of messing around with production servers.

Here's my current config:

listen MySQL 10.10.10.14:3306
   mode tcp
   balance roundrobin
   option persist
   server sql1 10.10.10.4:3306
   server sql2 10.10.10.5:3306
   server sql3 10.10.10.6:3306
nik
  • 7,100
  • 2
  • 25
  • 30

2 Answers2

13

There is a weight operator for the server line.
This works withing a range 0-256 where, 0 bypasses a server from the loop.
You should lookup these in the HAproxy Configuration.txt.

For a 75-15-15 distribution the weights should probably be 22-10-10.

I would expect the server lines to look like these, but please recheck with the notes or some better references.

   server sql1 10.10.10.4:3306 weight 22
   server sql2 10.10.10.5:3306 weight 10
   server sql3 10.10.10.6:3306 weight 10
nik
  • 7,100
  • 2
  • 25
  • 30
  • 11
    Where did those weights come from?? Haproxy should use the weight in linear propotion to the total weight. So 22-10-10 = 52% 24% 24%. That's not 70-15-15, which are the numbers he should actually use if he wants that distribution. – Chris S Sep 27 '12 at 01:45
  • I want to learn how do you calculate these weights: > For a 75-15-15 distribution the weights should probably be 22-10-10 Thanks in advance. –  Sep 26 '12 at 22:48
  • 1
    http://cbonte.github.com/haproxy-dconv/configuration-1.4.html#5-weight is an easier link for the documentation. – Xiong Chiamiov Oct 22 '12 at 21:21
3

Don't mess around with 'derived' values, haproxy works proportionally from the TOTAL of the weights provided, thus you can use percentage (out of 100) as long as all weights add up to 100 as follows:

server sql1 10.10.10.4:3306 weight 75
server sql2 10.10.10.5:3306 weight 15
server sql3 10.10.10.6:3306 weight 15
sl0m0
  • 31
  • 3