At 11:13 -0800 11/26/03, Stas Bekman wrote:
Elizabeth Mattijsen wrote:
I was wondering whether the following trick could somehow work with mod_perl 2. And excuse my preference for prefork MPM's: I guess that's the hammer to work on all my nails (pun intended). I'm open to other solutions to this "problem"!
Liz, when you are talking about prefork mpm, you get a better chance to get more people to read your question if you don't mention mp2. My guess is that folks won't even try to reply, since they aren't familiar with mp2. But your question applies to mp1 just as well.

I'll keep that in mind next time... but I was under the impression that I could only do this in MP2 because that's where there is a Perl*Handler running in the parent for each request, or sequence of request in the case of Keep-Alive. To my knowledge, you can't do that in MP1, or can you?



When you're using prefork MPM, you try to create as many constant data-structures as possible before the children are being forked. Sometimes, these structures require updating during the lifetime of the server, but the updated information does not need to be available to all the currently running children. And/Or you don't want the server to be completely restarted for that. An example would be a blacklist of IP-numbers that you want to block, or indexes that only need updating if a new entry is added.
If I remember correctly, you mentioned this to me back at YAPC::Paris in July. But back then you said you are going to gracefully restart the child processes, after updating the parent's data so that the newly spawned processes will see the updated info. It won't work in any other way.

Having to gracefully restart is what I'm trying to prevent, really. My experience so far with grceful restarts hasn't been very favourable. Was I wrong?



You are probably much better off using a dbm file or some other external cache, so that you don't need to look for tricky solutions. David Harris wrote Apache::DB_File which is optimized for read-often/update-rarely case.

I'll have a look at that...



and a Perl*Handler (PreConnection?) is installed. This handler should run _inside_ the parent before each request. It would conceptually go like this:
PreConnection will work only if you don't use KeepAlive. With KeepAlive it'll be executed once for the whole connection.

That's fine...



If you are talking about serving HTTP, you probably want PerlInitHandler. Similar to Apache::Reload.

But PerlInitHandler runs in the child, does it not?



Liz


--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html



Reply via email to