Post A11YMAd8nqceUTdMBc by wolf480pl@mstdn.io
(DIR) More posts by wolf480pl@mstdn.io
(DIR) Post #A11GpHkFdD8LmNh16m by wolf480pl@mstdn.io
2020-11-09T10:58:06Z
0 likes, 0 repeats
For nginx load balancing, ip_hash vs cookie?Is least_conn a good idea?Do I understand correctly that I can't use least_conn and ip_hash at the same time?
(DIR) Post #A11OvRLxcWyuwvmEjI by wolf480pl@mstdn.io
2020-11-09T12:28:50Z
0 likes, 0 repeats
I guess I'll go for ip_hash, I don't want users to stick to one upstream for too long in case load shifts...
(DIR) Post #A11WYzkEO3asaMwBkW by tomleb@toot.cafe
2020-11-09T13:54:09Z
0 likes, 0 repeats
@wolf480pl ip_hash selects the upstream based on the client's IP address so in that case the client would stick to one upstream
(DIR) Post #A11WhjYbwOLUzHfYsy by wolf480pl@mstdn.io
2020-11-09T13:56:00Z
0 likes, 0 repeats
@tomleb hm.. right, it won't ever switch a client elsewhere unless I change the weights.No idea what I was thinking back then.
(DIR) Post #A11XiV7ZCRGsSSwv4q by tomleb@toot.cafe
2020-11-09T14:07:20Z
0 likes, 0 repeats
@wolf480pl If you receive most requests from a single IP then ip_hash is not a good idea. The best idea might be to deploy the load balancer, wait for traffic, analyse what kind of traffic you receive and then tune accordingly.What is your expected load? Maybe you'll be bottlenecked on the load balancer first before even reaching the upstreams too
(DIR) Post #A11YDzQsYIYzRczuBU by wolf480pl@mstdn.io
2020-11-09T14:13:00Z
0 likes, 0 repeats
@tomleb it won't be bottlenecked on the load balancer - the upstream python app is waay too slow.The kind of traffic I receive is a bunch of kids trying to view contest tasks at the same time when the round starts. I have access logs from the last time it happened. What should I look at?Also note that I need requests from the same page load to hit the same upstream (because different upstreams serve differently-named JS files because reasons)
(DIR) Post #A11YMAd8nqceUTdMBc by wolf480pl@mstdn.io
2020-11-09T14:14:30Z
0 likes, 0 repeats
@tomleb hm... maybe a very quickly expiring cookie? like 5s or sth....I don't want them to stick to the same backend too much...
(DIR) Post #A11ZB6UpvsPMRE2JgO by tomleb@toot.cafe
2020-11-09T14:23:41Z
0 likes, 0 repeats
@wolf480pl Yeah you'll need sticky cookie to make them use the same upstream. But then if only 5s expiry then it's rpetty useless because well.. It's going to expire, so they'll reach another upstream.You could make them 'stick' to an upstream with ip_hash too, unless kids are at school under a single IP, then the load won't be spread.Why don't you want them to stick to the same upstream for too long?
(DIR) Post #A11ZNn33YEo9sy5k92 by wolf480pl@mstdn.io
2020-11-09T14:26:01Z
0 likes, 0 repeats
@tomleb I'm afraid that if one of the upstreams becomes overwhelmed, the other one may still have free capacity while the users are getting timeouts because they got stuck to the overwhelmed server
(DIR) Post #A11o4Qf83XDEGd7rSi by tomleb@toot.cafe
2020-11-09T17:10:34Z
0 likes, 0 repeats
@wolf480pl In your case you need sticky for sure. I've never tried least_conn, maybe round robin is enough too.You could try simulating the traffic and see benchmark which handles it better