Forum: NGINX Upstream least_conn behavior irregularity

Posted by John Watson (Guest)
on 2013-03-21 09:46
(Received via mailing list)
Was investigating some issues today when we noticed that least_conn 
wasn't
behaving as expected.

upstream backend {
  least_conn;
  server unix:/tmp/sock-1.sock;
  server unix:/tmp/sock-2.sock;
  server unix:/tmp/sock-3.sock;
}

The expected behavior for 4 simultaneous requests it should distribute 
them:
sock-1: 2
sock-2: 1
sock-3: 1

However, what we're seeing is:
sock-1: 3
sock-2: 1
sock-3: 0

Which coincidentally lines up with the number of requests a socket can
service simultaneously.

This is using 1.2.7
Posted by Ruslan Ermilov (Guest)
on 2013-03-21 12:47
(Received via mailing list)
On Thu, Mar 21, 2013 at 01:45:14AM -0700, John Watson wrote:
>    sock-1: 2
>    sock-2: 1
>    sock-3: 1
>    However, what we're seeing is:
>    sock-1: 3
>    sock-2: 1
>    sock-3: 0
>    Which coincidentally lines up with the number of requests a socket can
>    service simultaneously.
>    This is using 1.2.7

And the number of configured worker processes is?
Posted by John Watson (Guest)
on 2013-03-21 17:34
(Received via mailing list)
Ohhhh... that makes complete sense now.

Had 4 workers.

Thanks!
Posted by John Watson (Guest)
on 2013-03-21 20:04
(Received via mailing list)
Well doesn't make sense when theres >4 concurrent requests

At any given time there's around 12 active_connections, but sock-3 is 
still
never being used
Posted by Ruslan Ermilov (Guest)
on 2013-03-21 20:30
(Received via mailing list)
On Thu, Mar 21, 2013 at 12:03:59PM -0700, John Watson wrote:
>    Well doesn't make sense when theres >4 concurrent requests
>    At any given time there's around 12 active_connections, but sock-3 is
>    still never being used

Can you see a difference with only one worker process?

Currently, different workers have distinct counters of active 
connections.
It should be unnoticed under a high load.
Posted by John Watson (Guest)
on 2013-03-21 21:02
(Received via mailing list)
Going to pushing out the change to 1 worker later today.

It's just become more of an exercise in understanding why it was 
behaving
that way.

Even under "high" load (in this case ~50 active_connections), the 3 
socks
don't seem to be getting equal number of requests.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.