Forum Moderators: bakedjake
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?
Also, Iīve heard there is 'static' and other kinds of configs, and Iīm not sure of what they are, and how to change and fine tune them, in order I donīt end up increasing my CPU usage(!).
I wait for your help then!
Thanks a lot
phoenix_fly
PS: by the way, my host doesnīt support mod_perl.
how many proccesses of your FCGI script you run? Or you not handle it via process manager?
When you update code, you need kell your FCGI proccess and start it again.
We specialized in FCGI/perl coding.
To tune your code for speed, need to good knowledge of perl and how it handle things. Optimization technics you can find at perl.com.
For more recommendations need to see code, that you want optimize.
Best Regards,
Dmitry.
So I guess you will save me, as nobody else volunteered to help me in this difficult issue.
I managed to learn how to kill and restart the processes. But now Iīm stuck with 2 things:
1) memory leakage
2) problems with the 10seconds offline penality any script that dies for a couple times suffers.
As for 2:
I had a .fcgi script running ok - well, almost, some memory leaks I canīt figure out how to solve - and
then, after updating the code through ftp, it just stopped responding and started returning 500 server errors after a long seconds wait. Then I issued the
"top" at shell, but there werenīt any process for this script.
Then I went to check if it ran in the command line and it did! Smoothly!Only didnīt at the web!
So, as I had other test script that was running perrfectly from the web without any problems, I just copied the whole content of it, pasted inside
the problematic script, overwriting all its content, and FTPd it. Should work, right? It didnīt! So I thought it wasnīt the code (wich is below)!
It seems Apache is playing arround with me!
And, to make me crazy, 5 minutes after that, the script started both working and appearing at the "top" utility I use for seeing the processes! This was about 20 minutes after the massive errors, without me having done nothing. How come?
I send the code below, for you to help me also to find out about why I have memory leaks for the $start variable.
Thanks a lot, buddy
phoenix_fly
PS: About the problem #1, I found a guy with the same problem here: [fastcgi.com...]
>
> #!/usr/bin/perl -wT
>
> # Loads modules
>
> use CGI;
> use CGI::Fast;
> use DBI;
> require "./methods.cgi";
> use CGI::Carp qw( fatalsToBrowser );
> use Time::HiRes qw(gettimeofday);
> use strict;
>
> use lib "/home/myaccount/perl-lib";
> $ENV{'PATH'} = "/usr/local/bin:/usr/bin:/bin"; # (to MIME::Lite)
>
>
> # Weīre online?
>
> my $online = 1;
> my $mysqlhost = "mysql.myaccount.com";
>
> if ( $ENV{SERVER_NAME} eq "127.0.0.1" ) {
> $online = 0;
> $mysqlhost = "localhost";
> }
>
>
> # Connects to mysql
>
> [code]
>
> # Start of CGI::Fast loop
>
> while( my $q = new CGI::Fast ) {
>
> # Start cronometer
> my $elapsed = 0.000; my $t0; my $t1;
> if ( $online == 1 ) { $t0 = gettimeofday; }
>
>
> # Reading parameters
>
>
> my $cookie = check_string( $q->cookie( -name => "cookie" ) );
> my $section = check_string( $q->param("section") );
> my $start = check_string( $q->param("start") ); defined $start or $
> +start
> = 1;
>
> my $start_mysql = $start - 1;
> my $rec_p_pag = 30;
>
>
> # Global vars
>
> my $now = lc formatdate (time);
>
>
> # Balizamento da aįão, conforme a section solicitada
>
> if ( $section eq "this" ) { this(); }
>
> else { that(); }
>
>
> # end of chronometer
> if ( $online == 1 ) {
> $t1 = gettimeofday;
> $elapsed = $t1 - $t0;
> print $elapsed;
> }
>
> sub this {
>
>
> # Query
>
> $dbh->do ( ...query );
>
> # Loading hash
>
> my %things = load_hash_things();
>
> # starting the html
>
> print "Content-type: text/html\n\n";
>
> ...html
>
> }
>
> #############
> # that
> #############
>
> sub that {
> ...
>
> }
>
>
> } # END OF CGI::FAST LOOP
> 1. How you think that leaks in $start? What you use to detect leaks?
I know it leaks because when I put it online, the script's pagination just doesnīt obey to the $start sent from the url parameters. I then put a
print $start and confirmed that no matter the start=30 parameter i send, the start was always 1 (the default value). Am I supposed to insert some code to erase the $ENV{} variables from the prior request? Is the code structure I posted here right? > 2. Need to check mod_fastcgi settings for this script.
The only config I made was including the
AddType application/x-httpd-fcgi .fcgi .fpl Thanks
phoenix_fly