Re: Accept() loop in php-fcgi?
Jonathan Chen <ccchen-z0t8KZiULAH2/[email protected]>
| Newsgroups | gmane.comp.web.fastcgi.devel |
|---|---|
| Message-ID | <[email protected]> |
Dear Igor,
Thanks to your quick and detailed response. I have one questions in
regard to this paragraph:
> As to PHP + FastCGI... you would have noticed the performance burst
> if you either had a lot of modules to include or heavy load on your
> server. When PHP is translating some script.php it first compiles
> all the PHP modules into one translation unit, then it interprets
> it. The time required to compile the files and then interpret them
> is the time Fast-CGI saved for you in case of PHP.
If my main php script is structured as follows:
<?
include("include/include.1.inc");
include("include/include.2.inc");
include("include/include.3.inc");
...
...
include("include/include.100.inc");
echo("this is main.php");
?>
and all of the "include/include.`seq 1 100`.inc" php include files are
empty, then the one unit after translation should be equivalent to:
<?
// empty
// empty
// empty
...
// empty
echo("this is main.php");
?>
However, from the benchmark under (mod_fastcgi + php-fcgi), a single
echo statement in php yields 1500+ requests per seconds performance
versus 200+ requests per second from a single echo statement plus 100
empty includes.
Obviously I may have done something wrong in the benchmark
methodology. Could you please kindly provide an example that would
demostrate the benefit of time saved from compiling the files
(repeatedly)?
Thanks,
Jonathan
* Igor <[email protected]> [2006-01-19 18:44]:
> Hello Jonathan,
>
> Friday, January 20, 2006, 12:10:03 AM, you wrote:
>
> JC> Recently I moved some of my php scripts from running on mod_php to
> JC> (mod_fastcgi + php-fcgi) under Apache; hoping to see some gains on
> JC> performance, however, I observed that having (mod_fastcgi + php-fcgi)
> JC> brings almost no benefit. On the other hand, the equivalent perl
> JC> script runs 10x faster on (mod_fastcgi + perl).
>
> You're generally correct. I would only mention that PHP, in contrary to
> Perl is using different interface strategies. By default
> when you open http://site.com/scirpt.pl Perl interpreter is invoked
> with perl.pl script as a parameter. The data exchange between
> Perl script and Apache is based on STDIN, STDOUT streams. In this
> CGI configuration the time spent on to:
>
> - load perl interpreter
> - execute interpreter code
> - handle streams
> - interpret and execute script
>
> If you have 100 requests per second - 100 perl interpreters got to
> be loaded at one second to serve them.
>
> In the recent versions of PHP you may use the same interface,
> better know as CGI, to access your PHP scripts, yet this is
> neither fast nor native for PHP.
>
> mod_php is Apache extensions which holds PHP interpreter. Since it
> is loaded with Apache there is no time required for interpreter to
> load and initialize when you open http://site.com/script.php. There
> is no straightforward STDIN/OUT interfaces between a script and Apache as well.
> Not to mention that Perl interpreter by itself takes more time to
> load than PHP.
>
> CGI-FAST is an interface which among other useful services
> saves the time required for loading and translation, turining your
> otherwise slow loading CGI scripts to "almost apache module".
>
> As to PHP + FastCGI... you would have noticed the performance burst
> if you either had a lot of modules to include or heavy load on your
> server. When PHP is translating some script.php it first compiles all
> the PHP modules into one translation unit, then it interprets it.
> The time required to compile the files and then interpret them is the
> time Fast-CGI saved for you in case of PHP.
>
> JC> I am wondering if there is a notion of FCGI::accept() loop in php
> JC> semantics?
>
> No, in case of PHP it is not available or at least I don't know
> how to use it. That is, in some cases, a disadvantage of PHP if it
> is compared with Perl.
>
> JC> It seems like php-fcgi implements the accept() outside of
> JC> the php scripts, which makes me unable to seperate the heavy
> JC> initialization part from the response part.
>
> JC> Any ideas?
>
> I doubt it is possible for PHP to separate initialization
> routines "before" and "after" CGI Loop. At least I've never seen a
> PHP script which applies this strategy.
>
>
> --
> www.rol.ru
> Best regards,
> Igor mailto:[email protected]
>
___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/