I am testing a bit with etherpad. You can create a simple collaboration notepad, by generating a unique string at the end of the url, like this:
group1 is using Riseup Pad
group2 is using Riseup Pad
How would I create a haproxy cfg that would redirect users to a specific backend based on a previously used url?
Say I have one server running and thus all urls are going to be on that server. When the load increases I scale this task to 2 servers.
Now haproxy needs to remember what urls where on the first server and keep users there. But if there is a new request for a url that is on the first server, the first server should still receive it.
If there is a new url the new url should be send to the 2nd server.
Thus in this scenario, you need to scale to 2nd server at 80% load or so, so you can still facilitate new users on this first server.
I thought about using maps but maybe that is not the best choice “This lookup is done by a linear search and can be expensive with large lists!”
Currently I have this:
http-request set-map(/etc/haproxy/maps/etherpad.map) %[url] %[str(value)] if { path_beg /p/ }
use_backend %[req.hdr(host),lower,word(1,:),map(/etc/haproxy/maps/etherpad.map,etherpad)]
But I do not see an option somewhere to select a server. So I guess maybe stick-tables?
Currently I am trying with:
stick-table type string len 15 size 1000 nopurge store server_id
stick store-request url if { path_beg /p/ }
stick match url if { path_beg /p/ }