Hello,

I have a high volume application that basically needs to keep track of a
couple counters for the number of times certain requests were made and
update a MySQL db.

Unfortunately, it's high volume enough that it's no longer possible to
keep these counters in the databases updated in real time.  (updates are
to the order of 1000's per second).

So, my goal is to alter my module so that upon the fork of each child,
with X number of perl interp threads, to create two things:

* A shared hash to keep track of all of the counters, so that interp
threads can lock() and update as neccessary.

* A overseer/manager thread that wakes up once every so often and
updates the MySQL database with the contents of the global shared hash.

I have the first one handled fine.  All the interpreter threads in a
process see the same data, increments work fine.

The second part has me stumped.  I use Apache->server->push_handlers
called from a BEGIN block to install a PerlChildInitHandler, and this
subroutine starts a detached thread that executes the code to sleep and
update the datbase.

Well, it works, but the only 'manager' thread that seems to start is for
the main apache process (which doesn't handle requests directly
anyways).  In the children this never executes.  There is an error in
the apache log that comes immediately upon server startup complaining
that a thread had exited while others were running.  I suspect this
error is due to apache daemonizing on startup.

Where is the correct place to start such an 'manager' thread in each
apache child?  I thought that by installing a ChildInitHandler from the
BEGIN block would work just fine...

Thanks!



-- 
Richard F. Rebel

cat /dev/null > `tty`

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to