You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Jan Banan <b...@grabbarna.nu> on 2003/04/01 09:35:39 UTC

RE: [users@httpd] Count in SSI

I am using modperl: Server: Apache/1.3.27 (Unix) PHP/4.2.3 mod_perl/1.27
I rewrote the perl-script like this:

   #!/usr/local/bin/perl
   use Time::HiRes qw(gettimeofday tv_interval);
   $t0 = [gettimeofday];
   ($sec, $min, $hour)=localtime(time-2);
   $year += 1900;
   $mon++;
   print "Content-Type: text/plain\n\n";
   print (sprintf ("%.2d%.2d%.2d", $hour, $min, $sec));
   $t1 = [gettimeofday];
   $t0_t1 = tv_interval $t0, $t1;
   print STDERR "Time diff: $t0_t1\n";

This is the time diffs I get in Apache error_log:

  Time diff: 0.000337
  Time diff: 0.000339
  Time diff: 0.000348
  Time diff: 0.000366
  Time diff: 0.000333

So the perl-script seem to execute really fast. But what may take time is 
the SSI line:
   <!--#include virtual="/cgi-bin/slow_clock.pl" -->
because the client webbrowser is sending a GET every second but it only 
receives a result every 4-5 second.
If I change the SSI line to
   <!--#config timefmt="%H%M%S" --><!--#echo var="DATE_LOCAL" -->
(so I am not able to slow the clock my 2 secs) then the client get a 
respons each second (as I want).

So either there seem to be something really slow with SSI
   <!--#include virtual="/cgi-bin/slow_clock.pl" -->
or for Apache to start/stop using Perl.

Any suggestions are very welcome!!

/Jan

On 31 Mar 2003, Garth Winter Webb wrote:

> Are you running mod_perl?  A request to this CGI should definitely not
> take a few seconds.  It shouldn't even take a second.  The speed of your
> machine is not at issue here.  I've got a PII 300MHz machine serving
> content from multiple scripts that do way more than this one and the
> response is less than a second.
> 
> Use mod_perl if you not already.  You could load Time::HiRes from your
> script, record the time at the beginning and at the end and write the
> difference to STDERR which you can pick up in your log file.  By using
> mod_perl you won't incur a hit for loading Time::HiRes (or Perl, or any
> module it uses for that matter) after the first hit.  This will tell you
> how much time is being spent running your script.
> 
> G
> 
> On Mon, 2003-03-31 at 09:17, Jan Banan wrote:
> > > You have to call an external program which may be in CGI, e.g.
> > >         <!--#include virtual="/cgi-bin/slow_clock.pl" -->
> > > where slow_clock.pl always returns the time of two seconds ago.
> > 
> > I did that by creating the following /cgi-bin/slow_clock.pl :
> > 
> >    #!/usr/local/bin/perl
> >    print "Content-Type: text/plain\n\n";
> >    ($sec, $min, $hour)=localtime(time-2);
> >    print (sprintf ("%.2d%.2d%.2d", $hour, $min, $sec));
> > 
> > The problem is that this is extremely slow. I like the user to be able to 
> > send/receive a GET every second, but each request takes a few seconds to 
> > execute on this 550 MHz Pentium III running RedHat Linux 7.2 and Apache 
> > 1.3.27 :-( 
> > Probably I need to buy a faster computer... or just put the clock back 
> > two seconds, hrm.
> > 
> > /JB
> > 
> > 
> > ---------------------------------------------------------------------
> > The official User-To-User support forum of the Apache HTTP Server Project.
> > See <URL:http://httpd.apache.org/userslist.html> for more info.
> > To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> > For additional commands, e-mail: users-help@httpd.apache.org
> 


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] Count in SSI

Posted by Rich Bowen <rb...@rcbowen.com>.
On Tue, 1 Apr 2003, Jan Banan wrote:

> Hehe... mod_perl was not in use I realized... after adding this to
> httpd.conf it went lightening fast:
>
>   <Files index.cgi>
>       SetHandler perl-script
>       PerlHandler Apache::Registry
>       Options ExecCGI
>   </Files>
>
> One thing that disturbs me... I like to write the above three lines in
> .htaccess instead so it applies only to that directory.

The more correct way to do this would be to nest the <Files> section
inside a <Directory> section. .htaccess files are slow, and so, by
introducing .htaccess file into this, you are giving up much of the
performance gain achieved by using mod_perl in the first place. See the
.htaccess file tutorial, and the performance tips document, for
elaboration on this point.

-- 
Oh I have slipped the surly bonds of earth
And danced the sky on laughter-silvered wings
 --High Flight (John Gillespie Magee)

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] Count in SSI

Posted by Jan Banan <b...@grabbarna.nu>.
Hehe... mod_perl was not in use I realized... after adding this to 
httpd.conf it went lightening fast:

  <Files index.cgi>
      SetHandler perl-script
      PerlHandler Apache::Registry
      Options ExecCGI
  </Files>

One thing that disturbs me... I like to write the above three lines in 
.htaccess instead so it applies only to that directory. I tried to put 
these lines in .htaccess but then I get this in error_log :

   [Tue Apr  1 12:06:53 2003] [error] access to 
   /path/to/the/file.jpg failed for xx.yy.zz.uu, reason: 
   file permissions deny server execution

But the file /path/to/the/file.jpg is 644 and the directory is 755... 
so why is it screaming?

/Jan

On Tue, 1 Apr 2003, Jan Banan wrote:

> Just one thought... how do I know that mod_perl is being used? The Apache 
> server identifies itself by
> 
>     Server: Apache/1.3.27 (Unix) mod_perl/1.27
> 
> Maybe I need to do something more than just having the filname like
> index.cgi and start it with "#!/usr/local/bin/perl" ?
> 
> /Jan
> 
> On Tue, 1 Apr 2003, Jan Banan wrote:
> 
> > I tested by rewriting my index.shtml into a cgi-script (index.cgi) and the 
> > result is exactly the same... the client requests a new page as soon as 
> > possible after it has received the previos page and it takes about 4-5 
> > secs between each page. 
> > 
> > When using a simple index.shtml with no perl-calls it takes no more than 
> > one second, so there seem to be no problem with SSI, the problem seem to 
> > be that apache 1.3.27 takes seconds to start/stop executing a perl-script 
> > with mod_perl/1.27.
> > 
> > Any suggestions of how to fasten this up are very welcome!!
> > 
> > /Jan
> > 
> > On Tue, 1 Apr 2003, Jan Banan wrote:
> > 
> > > I am using modperl: Server: Apache/1.3.27 (Unix) PHP/4.2.3 mod_perl/1.27
> > > I rewrote the perl-script like this:
> > > 
> > >    #!/usr/local/bin/perl
> > >    use Time::HiRes qw(gettimeofday tv_interval);
> > >    $t0 = [gettimeofday];
> > >    ($sec, $min, $hour)=localtime(time-2);
> > >    $year += 1900;
> > >    $mon++;
> > >    print "Content-Type: text/plain\n\n";
> > >    print (sprintf ("%.2d%.2d%.2d", $hour, $min, $sec));
> > >    $t1 = [gettimeofday];
> > >    $t0_t1 = tv_interval $t0, $t1;
> > >    print STDERR "Time diff: $t0_t1\n";
> > > 
> > > This is the time diffs I get in Apache error_log:
> > > 
> > >   Time diff: 0.000337
> > >   Time diff: 0.000339
> > >   Time diff: 0.000348
> > >   Time diff: 0.000366
> > >   Time diff: 0.000333
> > > 
> > > So the perl-script seem to execute really fast. But what may take time is 
> > > the SSI line:
> > >    <!--#include virtual="/cgi-bin/slow_clock.pl" -->
> > > because the client webbrowser is sending a GET every second but it only 
> > > receives a result every 4-5 second.
> > > If I change the SSI line to
> > >    <!--#config timefmt="%H%M%S" --><!--#echo var="DATE_LOCAL" -->
> > > (so I am not able to slow the clock my 2 secs) then the client get a 
> > > respons each second (as I want).
> > > 
> > > So either there seem to be something really slow with SSI
> > >    <!--#include virtual="/cgi-bin/slow_clock.pl" -->
> > > or for Apache to start/stop using Perl.
> > > 
> > > Any suggestions are very welcome!!
> > > 
> > > /Jan
> > > 
> > > On 31 Mar 2003, Garth Winter Webb wrote:
> > > 
> > > > Are you running mod_perl?  A request to this CGI should definitely not
> > > > take a few seconds.  It shouldn't even take a second.  The speed of your
> > > > machine is not at issue here.  I've got a PII 300MHz machine serving
> > > > content from multiple scripts that do way more than this one and the
> > > > response is less than a second.
> > > > 
> > > > Use mod_perl if you not already.  You could load Time::HiRes from your
> > > > script, record the time at the beginning and at the end and write the
> > > > difference to STDERR which you can pick up in your log file.  By using
> > > > mod_perl you won't incur a hit for loading Time::HiRes (or Perl, or any
> > > > module it uses for that matter) after the first hit.  This will tell you
> > > > how much time is being spent running your script.
> > > > 
> > > > G
> > > > 
> > > > On Mon, 2003-03-31 at 09:17, Jan Banan wrote:
> > > > > > You have to call an external program which may be in CGI, e.g.
> > > > > >         <!--#include virtual="/cgi-bin/slow_clock.pl" -->
> > > > > > where slow_clock.pl always returns the time of two seconds ago.
> > > > > 
> > > > > I did that by creating the following /cgi-bin/slow_clock.pl :
> > > > > 
> > > > >    #!/usr/local/bin/perl
> > > > >    print "Content-Type: text/plain\n\n";
> > > > >    ($sec, $min, $hour)=localtime(time-2);
> > > > >    print (sprintf ("%.2d%.2d%.2d", $hour, $min, $sec));
> > > > > 
> > > > > The problem is that this is extremely slow. I like the user to be able to 
> > > > > send/receive a GET every second, but each request takes a few seconds to 
> > > > > execute on this 550 MHz Pentium III running RedHat Linux 7.2 and Apache 
> > > > > 1.3.27 :-( 
> > > > > Probably I need to buy a faster computer... or just put the clock back 
> > > > > two seconds, hrm.
> > > > > 
> > > > > /JB
> > > > > 
> > > > > 
> > > > > ---------------------------------------------------------------------
> > > > > The official User-To-User support forum of the Apache HTTP Server Project.
> > > > > See <URL:http://httpd.apache.org/userslist.html> for more info.
> > > > > To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> > > > >    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> > > > > For additional commands, e-mail: users-help@httpd.apache.org
> > > > 
> > > 
> > > 
> > > ---------------------------------------------------------------------
> > > The official User-To-User support forum of the Apache HTTP Server Project.
> > > See <URL:http://httpd.apache.org/userslist.html> for more info.
> > > To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> > >    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> > > For additional commands, e-mail: users-help@httpd.apache.org
> > > 
> > > 
> > 
> > 
> > ---------------------------------------------------------------------
> > The official User-To-User support forum of the Apache HTTP Server Project.
> > See <URL:http://httpd.apache.org/userslist.html> for more info.
> > To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> > For additional commands, e-mail: users-help@httpd.apache.org
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 
> 


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] Count in SSI

Posted by Jan Banan <b...@grabbarna.nu>.
Just one thought... how do I know that mod_perl is being used? The Apache 
server identifies itself by

    Server: Apache/1.3.27 (Unix) mod_perl/1.27

Maybe I need to do something more than just having the filname like
index.cgi and start it with "#!/usr/local/bin/perl" ?

/Jan

On Tue, 1 Apr 2003, Jan Banan wrote:

> I tested by rewriting my index.shtml into a cgi-script (index.cgi) and the 
> result is exactly the same... the client requests a new page as soon as 
> possible after it has received the previos page and it takes about 4-5 
> secs between each page. 
> 
> When using a simple index.shtml with no perl-calls it takes no more than 
> one second, so there seem to be no problem with SSI, the problem seem to 
> be that apache 1.3.27 takes seconds to start/stop executing a perl-script 
> with mod_perl/1.27.
> 
> Any suggestions of how to fasten this up are very welcome!!
> 
> /Jan
> 
> On Tue, 1 Apr 2003, Jan Banan wrote:
> 
> > I am using modperl: Server: Apache/1.3.27 (Unix) PHP/4.2.3 mod_perl/1.27
> > I rewrote the perl-script like this:
> > 
> >    #!/usr/local/bin/perl
> >    use Time::HiRes qw(gettimeofday tv_interval);
> >    $t0 = [gettimeofday];
> >    ($sec, $min, $hour)=localtime(time-2);
> >    $year += 1900;
> >    $mon++;
> >    print "Content-Type: text/plain\n\n";
> >    print (sprintf ("%.2d%.2d%.2d", $hour, $min, $sec));
> >    $t1 = [gettimeofday];
> >    $t0_t1 = tv_interval $t0, $t1;
> >    print STDERR "Time diff: $t0_t1\n";
> > 
> > This is the time diffs I get in Apache error_log:
> > 
> >   Time diff: 0.000337
> >   Time diff: 0.000339
> >   Time diff: 0.000348
> >   Time diff: 0.000366
> >   Time diff: 0.000333
> > 
> > So the perl-script seem to execute really fast. But what may take time is 
> > the SSI line:
> >    <!--#include virtual="/cgi-bin/slow_clock.pl" -->
> > because the client webbrowser is sending a GET every second but it only 
> > receives a result every 4-5 second.
> > If I change the SSI line to
> >    <!--#config timefmt="%H%M%S" --><!--#echo var="DATE_LOCAL" -->
> > (so I am not able to slow the clock my 2 secs) then the client get a 
> > respons each second (as I want).
> > 
> > So either there seem to be something really slow with SSI
> >    <!--#include virtual="/cgi-bin/slow_clock.pl" -->
> > or for Apache to start/stop using Perl.
> > 
> > Any suggestions are very welcome!!
> > 
> > /Jan
> > 
> > On 31 Mar 2003, Garth Winter Webb wrote:
> > 
> > > Are you running mod_perl?  A request to this CGI should definitely not
> > > take a few seconds.  It shouldn't even take a second.  The speed of your
> > > machine is not at issue here.  I've got a PII 300MHz machine serving
> > > content from multiple scripts that do way more than this one and the
> > > response is less than a second.
> > > 
> > > Use mod_perl if you not already.  You could load Time::HiRes from your
> > > script, record the time at the beginning and at the end and write the
> > > difference to STDERR which you can pick up in your log file.  By using
> > > mod_perl you won't incur a hit for loading Time::HiRes (or Perl, or any
> > > module it uses for that matter) after the first hit.  This will tell you
> > > how much time is being spent running your script.
> > > 
> > > G
> > > 
> > > On Mon, 2003-03-31 at 09:17, Jan Banan wrote:
> > > > > You have to call an external program which may be in CGI, e.g.
> > > > >         <!--#include virtual="/cgi-bin/slow_clock.pl" -->
> > > > > where slow_clock.pl always returns the time of two seconds ago.
> > > > 
> > > > I did that by creating the following /cgi-bin/slow_clock.pl :
> > > > 
> > > >    #!/usr/local/bin/perl
> > > >    print "Content-Type: text/plain\n\n";
> > > >    ($sec, $min, $hour)=localtime(time-2);
> > > >    print (sprintf ("%.2d%.2d%.2d", $hour, $min, $sec));
> > > > 
> > > > The problem is that this is extremely slow. I like the user to be able to 
> > > > send/receive a GET every second, but each request takes a few seconds to 
> > > > execute on this 550 MHz Pentium III running RedHat Linux 7.2 and Apache 
> > > > 1.3.27 :-( 
> > > > Probably I need to buy a faster computer... or just put the clock back 
> > > > two seconds, hrm.
> > > > 
> > > > /JB
> > > > 
> > > > 
> > > > ---------------------------------------------------------------------
> > > > The official User-To-User support forum of the Apache HTTP Server Project.
> > > > See <URL:http://httpd.apache.org/userslist.html> for more info.
> > > > To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> > > >    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> > > > For additional commands, e-mail: users-help@httpd.apache.org
> > > 
> > 
> > 
> > ---------------------------------------------------------------------
> > The official User-To-User support forum of the Apache HTTP Server Project.
> > See <URL:http://httpd.apache.org/userslist.html> for more info.
> > To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> > For additional commands, e-mail: users-help@httpd.apache.org
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 
> 


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] Count in SSI

Posted by Jan Banan <b...@grabbarna.nu>.
I tested by rewriting my index.shtml into a cgi-script (index.cgi) and the 
result is exactly the same... the client requests a new page as soon as 
possible after it has received the previos page and it takes about 4-5 
secs between each page. 

When using a simple index.shtml with no perl-calls it takes no more than 
one second, so there seem to be no problem with SSI, the problem seem to 
be that apache 1.3.27 takes seconds to start/stop executing a perl-script 
with mod_perl/1.27.

Any suggestions of how to fasten this up are very welcome!!

/Jan

On Tue, 1 Apr 2003, Jan Banan wrote:

> I am using modperl: Server: Apache/1.3.27 (Unix) PHP/4.2.3 mod_perl/1.27
> I rewrote the perl-script like this:
> 
>    #!/usr/local/bin/perl
>    use Time::HiRes qw(gettimeofday tv_interval);
>    $t0 = [gettimeofday];
>    ($sec, $min, $hour)=localtime(time-2);
>    $year += 1900;
>    $mon++;
>    print "Content-Type: text/plain\n\n";
>    print (sprintf ("%.2d%.2d%.2d", $hour, $min, $sec));
>    $t1 = [gettimeofday];
>    $t0_t1 = tv_interval $t0, $t1;
>    print STDERR "Time diff: $t0_t1\n";
> 
> This is the time diffs I get in Apache error_log:
> 
>   Time diff: 0.000337
>   Time diff: 0.000339
>   Time diff: 0.000348
>   Time diff: 0.000366
>   Time diff: 0.000333
> 
> So the perl-script seem to execute really fast. But what may take time is 
> the SSI line:
>    <!--#include virtual="/cgi-bin/slow_clock.pl" -->
> because the client webbrowser is sending a GET every second but it only 
> receives a result every 4-5 second.
> If I change the SSI line to
>    <!--#config timefmt="%H%M%S" --><!--#echo var="DATE_LOCAL" -->
> (so I am not able to slow the clock my 2 secs) then the client get a 
> respons each second (as I want).
> 
> So either there seem to be something really slow with SSI
>    <!--#include virtual="/cgi-bin/slow_clock.pl" -->
> or for Apache to start/stop using Perl.
> 
> Any suggestions are very welcome!!
> 
> /Jan
> 
> On 31 Mar 2003, Garth Winter Webb wrote:
> 
> > Are you running mod_perl?  A request to this CGI should definitely not
> > take a few seconds.  It shouldn't even take a second.  The speed of your
> > machine is not at issue here.  I've got a PII 300MHz machine serving
> > content from multiple scripts that do way more than this one and the
> > response is less than a second.
> > 
> > Use mod_perl if you not already.  You could load Time::HiRes from your
> > script, record the time at the beginning and at the end and write the
> > difference to STDERR which you can pick up in your log file.  By using
> > mod_perl you won't incur a hit for loading Time::HiRes (or Perl, or any
> > module it uses for that matter) after the first hit.  This will tell you
> > how much time is being spent running your script.
> > 
> > G
> > 
> > On Mon, 2003-03-31 at 09:17, Jan Banan wrote:
> > > > You have to call an external program which may be in CGI, e.g.
> > > >         <!--#include virtual="/cgi-bin/slow_clock.pl" -->
> > > > where slow_clock.pl always returns the time of two seconds ago.
> > > 
> > > I did that by creating the following /cgi-bin/slow_clock.pl :
> > > 
> > >    #!/usr/local/bin/perl
> > >    print "Content-Type: text/plain\n\n";
> > >    ($sec, $min, $hour)=localtime(time-2);
> > >    print (sprintf ("%.2d%.2d%.2d", $hour, $min, $sec));
> > > 
> > > The problem is that this is extremely slow. I like the user to be able to 
> > > send/receive a GET every second, but each request takes a few seconds to 
> > > execute on this 550 MHz Pentium III running RedHat Linux 7.2 and Apache 
> > > 1.3.27 :-( 
> > > Probably I need to buy a faster computer... or just put the clock back 
> > > two seconds, hrm.
> > > 
> > > /JB
> > > 
> > > 
> > > ---------------------------------------------------------------------
> > > The official User-To-User support forum of the Apache HTTP Server Project.
> > > See <URL:http://httpd.apache.org/userslist.html> for more info.
> > > To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> > >    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> > > For additional commands, e-mail: users-help@httpd.apache.org
> > 
> 
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 
> 


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org