Connection statuses
Maxim Dounin
mdounin at mdounin.ru
Thu Feb 19 13:02:20 UTC 2015
Hello!
On Wed, Feb 18, 2015 at 09:25:01PM -0500, K Young wrote:
> Hello, I've been reading through nginx source to understand the metrics
> <http://nginx.org/en/docs/http/ngx_http_stub_status_module.html> that are
> reported. I've got an idea of what is happening, but since the flow is
> asynchronous, I'm not 100% confident, and would love your feedback.
>
> Is the following correct?
>
> - 'accepts' is incremented when a worker gets a new request for a
> connection from the OS
> - 'handled' is incremented when a worker gets a new connection for a
> request
>
>
> And then once a connection is opened:
>
> - 'active' is incremented (actually, it is incremented right before
> 'handled', but will be decremented if the worker doesn't handle the
> connection request).
> - then the connection briefly goes into a waiting state while the
> request is waiting to be processed
> - then the connection goes into a short reading state while request
> headers are read. Simultaneously, 'request' is incremented every time a new
> request header begins to be read.
> - then the connection goes into a writing state while all work is done
> by nginx and by upstream components
> - then if the connection will be kept alive, it goes back into waiting
> state, which is synonymous with 'idle'
> - finally when the connection is closed, active is decremented
>
> The things I'm least certain of about the 'waiting' state:
>
> - Does active always sum up to waiting+reading+writing?
Generally yes. There are nuances with SPDY where additional
connections are emulated for SPDY streams being handled, and
waiting+reading+writing may be bigger than active.
> - Does each new connection enter a waiting state just before it goes
> into the reading state?
No. If there are data available right after connect (this usually
happens with accept filters / deferred accept), nginx will not
mark a newly accepted connection as waiting, and will start
reading a request directly.
> - While waiting for upstream responses, is the connection in writing
> state or waiting state?
Writing.
> - While waiting for new client requests on an open connection, is the
> connection in a waiting state?
Yes.
> Is the attached sketch of the above connection states correct? (underneath
> "READ" it says "request++" to indicate that this is where the request
> counter gets incremented).
> [image: Inline image 1]
Mostly, see above.
--
Maxim Dounin
http://nginx.org/
More information about the nginx
mailing list