Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

w2ksp4.exe, WwwxxXdbf, procmail "FROM_MAILER" patch, Use of assignment to $[ is deprecated at /usr/local/sbin/apxs line 86. , wwwxxx vim, mysql closing table and opening table, 800c5000, setgid operation not permitted, pciehp: acpi_pciehprm on IBM, WWWXXX.DBF

Links

XODOX
Impressum

#1: cleanup handler - is it "free" time?

Posted on 2011-07-20 22:37:08 by 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?

Report this message

#2: Re: cleanup handler - is it "free" time?

Posted on 2011-07-20 23:12:05 by 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=F6rtsch

=2D-=20
Need professional modperl support? Hire me! (http://foertsch.name)

Like fantasy? http://kabatinte.net

Report this message

#3: Re: cleanup handler - is it "free" time?

Posted on 2011-07-21 00:21:24 by Perrin Harkins

2011/7/20 Torsten F=F6rtsch <torsten.foertsch@gmx.net>:
> 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

Report this message