1

I am very new to HAProxy. I spent a few hours trying to figure out how to do it but could not get any leads. My requirement is this:

If end point of request is /special then I need to check URL_PARAM.

For example: localhost/special?id=10 Based on ID, I need to route it to one of the 3 servers. If id <=3 server1, if id > 3 and id <=6 server2 else server3.

If end point is not /special round robin between all 3 servers.

How do I achieve this 2 level balancing?

1 Answers1

2

You could use acl location_special path /special to match url and acl srv_1 urlp_val(id) -m int eq 0:3 to match on id= parameter. And finally

use-server server1 if location_special srv_1

to map request to certain server

Fedor Dikarev
  • 706
  • 4
  • 10
  • Hi! Thanks for the answer. Would it work for large 64 bit numbers? Currently my ID ranges are like: "456304162255302657" to "456316501914435584". It doesn't seem to be working for it, although it works alright for smaller ranges. – Maxsteel Dec 01 '16 at 00:59
  • 1
    I guess you need patch for Haproxy to work with such large numbers. Seems it will be easier to adjust your backends' logic to use lower IDs. – Fedor Dikarev Dec 05 '16 at 12:08