Hi Dominik,

On Mon, Nov 22, 2021 at 10:31:15AM +0000, Froehlich, Dominik wrote:
> For ongoing connections (not total), the stats page shows a tooltip stating
> 
> 
>   *   Current Active Connections
>   *   Current Used Connections
>   *   Current Idle Connections (broken down into safe and unsafe idle 
> connections)
> 
> What is the difference between active and used connections? Which number
> combined with idle connections reflects the current number of open
> connections on the OS level? (i.e. using resources like fds, buffers, ports)

You had me look at the code to figure the exact detail :-/

They're not computed the same way but I think that this results in them
being equivalent nowadays:
  - active is server->cur_sess, which is incremented whenever we need to
    establish a connection to a server, possibly after leaving the queue;

  - used is the number of server connections used, that is maintained at
    the idle pool layer for statistics.

Functionally speaking, even though they are not computed at the same place
and for the same reasons, I think they're the same. And except in rare
cases in my tests (slight timing differences), I think they're the same
now. Previously when idle connections couldn't be shared between threads
it would have been more complicated as one would be a sum of stuff that
could not necessarily be usable though. That's probably something we need
to consider cleaning for future versions.

> My ultimate goal is to answer the question "how loaded is this machine?" vs.
> a limit of open connections.

Got it. Then use either (or focus on active which is the historical one).
It's incremented only when under use. And use "used+idle" to know the number
of established connections at the OS level.

> What's the difference between safe and unsafe idle connections? Is it related
> to the http-reuse directive, e.g. private vs. non-private reusable
> connections?

Yes that's in part it. A safe connection is one which has proven that it was
reusable (it got reused at least once) an on which we're OK with sending the
first request of a connection because it's reasonably safe. An unsafe
connection is one that has processed 0 or 1 request only. When you use
"http-reuse always", this makesk no difference, both are always used.

Willy

Reply via email to