cleanup handler - is it "free" time?
am 20.07.2011 22:37:08 von E R
I am wondering how time spent in a cleanup handler affects page response time.
For instance, if I do a sleep(1) in a cleanup handler, will my page
delivery times be increased by a second?
Or will other available mod-perl child processes pick up pending
requests until the cleanup handler returns?
Re: cleanup handler - is it "free" time?
am 20.07.2011 23:12:05 von torsten.foertsch
On Wednesday, 20 July 2011 22:37:08 E R wrote:
> I am wondering how time spent in a cleanup handler affects page
> response time.
>=20
> For instance, if I do a sleep(1) in a cleanup handler, will my page
> delivery times be increased by a second?
> Or will other available mod-perl child processes pick up pending
> requests until the cleanup handler returns?
it depends.
If the connection is closed after the request the worker will be busy but=20
the client won't notice it because the next request establishes a new=20
connection to another worker.
If the connection is kept alive the client will think the request is done=20
and send the next one over the same connection. But the server will start=20
processing it only when the cleanup handler returns.
If possible use an external queue processor (similar to a printer spooler=20
or a mail queue) to do such things. If that's not possible queue the work=20
internally (in $r->connection->pnotes for example) and use a $r-
>connection->pool cleanup handler. That one runs when the connection is=20
closed. Don't set MaxKeepAliveRequests to 0.
Torsten Förtsch
=2D-=20
Need professional modperl support? Hire me! (http://foertsch.name)
Like fantasy? http://kabatinte.net
Re: cleanup handler - is it "free" time?
am 21.07.2011 00:21:24 von Perrin Harkins
2011/7/20 Torsten Förtsch :
> If the connection is kept alive the client will think the request is done
> and send the next one over the same connection. But the server will start
> processing it only when the cleanup handler returns.
A common approach is to use KeepAlive on the front-end proxy but not
on the back-end mod_perl server.
The other problem though is with scaling. If you do a lot of work in
cleanup handlers, you'll end up tying up a lot of processes that would
otherwise be handling requests and possibly run out of free processes.
Using an external queue avoids this. It also lets you control how
many of the queued jobs you handle at one time, so you don't bog down
your database or credit card processor.
But... for simple things that happen occasionally, cleanup handlers
are VERY easy.
- Perrin