Re: FCGI process handling and fine-tunning for saving CPU, under Perl code

"phoenix_fly" <[email protected]>
Newsgroups gmane.comp.web.fastcgi.devel
Message-ID <000501c5f769$c651bf00$0201a8c0@e9w8t5>
> > Here´s the problem: I´ve finally made FCGI (and also
> > CGI::Fast, but not mod_perl, as my host doesn´t support
> > it) work at my shared account. But just can´t figure out
> > how to handle it, I mean, how do I restart the processes
> > when I update the script code? How do I know the number of
> > the process??
>
> Two options: you can have the mod_fastcgi process manager
> (if you use that) notice when your script file is updated
> on disk and then automatically restart it when it is
> (assuming you can switch that option on); this is limited
> by the fact that it only checks your main script file, so
> if you have modules which you also change, this won't help
> you.

I am not aware I have a mod_cgi process manager installed, but in fact, this
correlate updates happen just all the time. So I really will need to
kill/restart through the shell.

Alternatively, you can check the timestamp on your
> script files in your main loop. We have code to do this
> here:
>
https://secure.mysociety.org/cvstrac/getfile/mysociety/perllib/mySociety/Wat
chUpdate.pm
> though it's a little ugly.

I have tried to use it, but for some reason it didn´t work, I mean, the
script stopped working after including the code calling the module. Also, I
fear that this verification will consume precious CPU, maybe it´s better to
restart/kill the processes myself, as soon as I know how to do that.

> > My main goal with FCGI is to save precious CPU minutes,
> > as the traffic is increasing a lot (and my host will kick
> > me out if I get too heavy-processing, as they just dont
> > have dedicated servers available). You guys know if the
> > CPU savings are worth adapting the code? I mean, can I
> > expect to use, like, 30% less CPU?
>
> That depends on the startup cost of your program vs the
> marginal cost of serving one request, basically. Without
> knowing any more detail it's impossible to comment; really
> you need to measure it now and decide whether it's
> worthwhile.

All scripts load 5 method libraries with more than 10 thousand lines total,
and connect to mysql before doing anything. So FCGI it may be a good thing
to save CPU, right? You´d say I can save 50% CPU?

> > And, last but not least, I am not quite sure about
> > converting guidelines, like avoiding referencing $q (new
> > CGI) inside subs and all. If you can offer me some links
> > for that, it would be great too.
>
> Again, without seeing your code, it's impossible to
> comment, but the basic skeleton I'd recommend for a
> perl FastCGI server would be:

This one is fine now. I´ve succeeded adapting a production script, without
leaks. The concern is only how to tell the server to restart that creature
now that I´ve made updates! ...lghs I wait for your help on that.

Thanks a lot Chris!

phoenix_fly

___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.