least_conn not working for me
Maxim Dounin
mdounin at mdounin.ru
Wed Dec 23 17:14:42 UTC 2020
Hello!
On Wed, Dec 23, 2020 at 10:27:44AM -0500, Kenneth Brooks wrote:
> I have a fully working config doing loadbalancing over 2 upstream servers.
> I want to use "least_conn"
>
> When I put least_conn in, it still is doing round robin.
> I can confirm that other configs like "weight' and "ip_hash" are working as
> expected.
>
> Is there some other configuration/setting that also affects whether
> least_conn is honored?
The "least_conn" balancing method is equivalent to round-robin as
long as all configured upstream servers have equal number of
connections opened. That is, if you are seeing nginx is "doing
round robin", most likely this means that there isn't enough
active connections for least_conn to be different from
round-robin.
Note well that "number of connections" applies to a single nginx
worker process, and if there is more than one worker, least_conn
might not see all the connections (unless you've configured nginx
to share information about upstream servers between worker
processes, see http://nginx.org/r/zone).
--
Maxim Dounin
http://mdounin.ru/
More information about the nginx
mailing list