Re: [Mod-fcgid-users] Weird behavior or what?
Travers Carter a écrit : > On Thu, 20 Aug 2009 00:45:36 +0300, Noor > > wrote: > >> And while you're at it, I'll through in another question: How does >> eAccelerator/FastCGI manage the shared memory segments? According to >> eAccelerator's homepage, it'll share such segments when the spawning >> process is shared. In the case of FastCGI (mod_fcgid), *who* is the >> spawning process? And this spawning process, how many cgi-php >> processes it'll spawn? (which if I understand correctly, such cgi-php >> processes would share eAccelerator's cached scripts as they've got one >> "father"). >> >> > > As I understand it in FastCGI mode a php process will launch a number > of children equal to the value of the PHP_FCGI_CHILDREN environment > variable, I believe that this is the spawning process referred to in > the eAccelerator docs, meaning that the shared memory segment would > be shared by those PHP_FCGI_CHILDREN processes. > > But mod_fcgid (unlike mod_fastcgi) assumes that each process it starts > directly can only handle a single concurrent request so > PHP_FCGI_CHILDREN should be set to 0, meaning that no children will be > launched and the shared memory segment will only be used by a single > php process. > > PHP will shutdown the process after 500 request, so if you don't use PHP_FCGI_CHILDREN the opcode cache (eaccelerator/xcache/apc) will be lost. For this type of setup I generally set PHP_FCGI_CHILDREN to 1 and increase the "ProcessLifeTime" fastcgi parameter to 86400 seconds instead of 3600. Olivier -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july ___ Mod-fcgid-users mailing list Mod-fcgid-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mod-fcgid-users
Re: [Mod-fcgid-users] Spawning explanation
Filip Hajny a écrit : > Yes, well, my point was... if you care about shared memory, then > constrain mod_fcgid to a single PHP process only, let the PHP process > fork its own children and hope they will be able to process all > requests before mod_fcgid considers the single process busy and you > end up getting 503. > My english is not really good, so maybe I very badly explained my original problem, but all the problem is here : letting PHP do that doesn't work at all. I use this configuration for mod_fcgid : DefaultMaxClassProcessCount 1 DefaultMinClassProcessCount 1 And in the PHP wrapper : export PHP_FCGI_CHILDREN=8 So I obtain this php5-cgi processes : init(1)─┬─apache2(1591)─┬─apache2(22940)───php5-cgi(23015)─┬─php5-cgi(23017) │ │ ├─php5-cgi(23018) │ │ ├─php5-cgi(23019) │ │ ├─php5-cgi(23020) │ │ ├─php5-cgi(23021) │ │ ├─php5-cgi(23022) │ │ ├─php5-cgi(23023) │ │ └─php5-cgi(23024) I test with that PHP script : Then I launch 4 concurrent access though that script : #!/bin/sh wget http://localhost/test.php -q -O test1.log & wget http://localhost/test.php -q -O test2.log & wget http://localhost/test.php -q -O test3.log & wget http://localhost/test.php -q -O test4.log & wait Then : time ./test.sh > scrubby:~# time ./check > > real 0m21.012s > user 0m0.004s > sys 0m0.012s Or also : ab -c 4 -n 4 http://localhost/test.php > Concurrency Level: 4 > Time taken for tests: 22.2176 seconds > Complete requests: 4 > Failed requests: 0 > Write errors: 0 > Total transferred: 684 bytes > HTML transferred: 8 bytes > Requests per second: 0.18 [#/sec] (mean) > Time per request: 22002.176 [ms] (mean) > Time per request: 5500.544 [ms] (mean, across all concurrent requests) The benchmark should past 5 seconds per page, no ? The php forks are not usefull with mod_fgid, or my setup have a serious problem. Of course, if I remove PHP_FCGI_CHILDREN and increase DefaultMaxClassProcessCount, this works very well but loose all the shared memory stuff (APC, Xcache, etc) : > scrubby:~# time ./check > > real 0m5.008s > user 0m0.004s > sys 0m0.004s Olivier -- Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H ___ Mod-fcgid-users mailing list Mod-fcgid-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mod-fcgid-users
Re: [Mod-fcgid-users] Spawning explanation
my first question was about that : it seems that fcgid will _never_ use this concurrent PHP instances. If there is 2 concurrent access, fcgid will spawn an other "group" of PHP to handle that, it will not use the first group of php instance which have idled children. So in this groups of PHP, there is only one php child really used. If it is just to keep the opcode cache after PHP die (by default all the 500 queries), well, just 1 fork in necessary. Olivier Filip Hajny a écrit : > On 28.2.2009, at 17:05, Olivier B. wrote: > > >> Yes I was thinking that but what is the interest to share memory >> between >> processes which never run simultaneously ? >> >> > > They do. If you let PHP spawn them, they all start right away, and > keep running until you kill them. They are not killed when idle etc. > > F > > -- > Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA > -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise > -Strategies to boost innovation and cut costs with open source participation > -Receive a $600 discount off the registration fee with the source code: SFAD > http://p.sf.net/sfu/XcvMzF8H > ___ > Mod-fcgid-users mailing list > Mod-fcgid-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mod-fcgid-users > -- Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H ___ Mod-fcgid-users mailing list Mod-fcgid-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mod-fcgid-users
Re: [Mod-fcgid-users] Spawning explanation
Yes I was thinking that but what is the interest to share memory between processes which never run simultaneously ? Olivier Filip Hajny a écrit : > On 28.2.2009, at 15:24, Olivier B. wrote: > > >> So, I simply read the file sapi/cgi/README.FastCGI in the PHP source. >> If I well understand, this feature is usefull when you run directly >> PHP >> as the fcgi daemon. >> >> > > It's also useful when you want memory shared among the PHP processes > (e.g. for caching). It's not shared if spawned by mod_fcgid. > > -F > > -- > Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA > -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise > -Strategies to boost innovation and cut costs with open source participation > -Receive a $600 discount off the registration fee with the source code: SFAD > http://p.sf.net/sfu/XcvMzF8H > ___ > Mod-fcgid-users mailing list > Mod-fcgid-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mod-fcgid-users > -- Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H ___ Mod-fcgid-users mailing list Mod-fcgid-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mod-fcgid-users
Re: [Mod-fcgid-users] Spawning explanation
So, I simply read the file sapi/cgi/README.FastCGI in the PHP source. If I well understand, this feature is usefull when you run directly PHP as the fcgi daemon. I have the end of my explanation, thanks and sorry for noise ;) Olivier Olivier B. a écrit : > Max Dittrich a écrit : > >> AFAIK (?) mod_fcgid can't multiplex multiple request on one fcgi-socket. >> The fcgi-connection is 1:1 (http request <--> fcgi connection) and can't >> be shared across childs/threads of apache. >> >> .max >> >> > Ok, it is what I see too. Thanks. > > > Filip Hajny a écrit : > >> PHP forks because you tell it to. If you ever set PHP_FCGI_CHILDREN to >> anything, PHP will fork *that many* processes right away regardless of >> how many requests you receive. mod_fcgid doesn't know anything about >> this, so you're essentially spawning processes at two levels >> (mod_fcgid and PHP itself). My suggestion is to yank our >> PHP_FCGI_CHILDREN completely. Just leave the process management to >> mod_fcgid. >> >> -- >> Filip Hajny >> > Of course PHP forks because I ask to do it. But the question is why this > feature exists if it is _totally_ useless ? > I will ask on the PHP mailing list, maybe they know why they add that > strange behavior. > > Thanks. > > Olivier > > -- > Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA > -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise > -Strategies to boost innovation and cut costs with open source participation > -Receive a $600 discount off the registration fee with the source code: SFAD > http://p.sf.net/sfu/XcvMzF8H > ___ > Mod-fcgid-users mailing list > Mod-fcgid-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mod-fcgid-users > -- Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H ___ Mod-fcgid-users mailing list Mod-fcgid-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mod-fcgid-users
Re: [Mod-fcgid-users] Spawning explanation
Max Dittrich a écrit : > AFAIK (?) mod_fcgid can't multiplex multiple request on one fcgi-socket. > The fcgi-connection is 1:1 (http request <--> fcgi connection) and can't > be shared across childs/threads of apache. > > .max > Ok, it is what I see too. Thanks. Filip Hajny a écrit : > PHP forks because you tell it to. If you ever set PHP_FCGI_CHILDREN to > anything, PHP will fork *that many* processes right away regardless of > how many requests you receive. mod_fcgid doesn't know anything about > this, so you're essentially spawning processes at two levels > (mod_fcgid and PHP itself). My suggestion is to yank our > PHP_FCGI_CHILDREN completely. Just leave the process management to > mod_fcgid. > > -- > Filip Hajny Of course PHP forks because I ask to do it. But the question is why this feature exists if it is _totally_ useless ? I will ask on the PHP mailing list, maybe they know why they add that strange behavior. Thanks. Olivier -- Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H ___ Mod-fcgid-users mailing list Mod-fcgid-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mod-fcgid-users
Re: [Mod-fcgid-users] Spawning explanation
Yes, but in that case why PHP forks ? children will never be used !? Olivier Ivan Voras a écrit : > 2009/2/27 Olivier B. : > > >> The DefaultMaxClassProcessCount is reached, but why fcgid try have >> launched 4 process ? Just one or two should be sufficient in the case of >> five concurrent users, since each PHP process can handle 5 of them. No ? >> Or maybe I misunderstood this fork feature of PHP, and FCGID can't use >> this children in parallel ? But in that case, what is the interest of >> this fork() ? >> > > I think mod_fcgid spawns 1 PHP process per parallel request, so in > your case you need 5 processes. > > -- > Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA > -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise > -Strategies to boost innovation and cut costs with open source participation > -Receive a $600 discount off the registration fee with the source code: SFAD > http://p.sf.net/sfu/XcvMzF8H > ___ > Mod-fcgid-users mailing list > Mod-fcgid-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mod-fcgid-users > -- Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H ___ Mod-fcgid-users mailing list Mod-fcgid-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mod-fcgid-users
[Mod-fcgid-users] Spawning explanation
Hello, I use mod-fcgid 2.2 with Apache 2.2.9 (worker), and php 5.2.6 on a Debian Lenny 64bits. My fcgid conf (for tests) : MaxProcessCount 32 DefaultMaxClassProcessCount 4 DefaultMinClassProcessCount 2 the PHP wrapper : #!/bin/dash export PHP_FCGI_CHILDREN=5 export PHP_FCGI_MAX_REQUESTS=1000 exec /usr/bin/php5-cgi $@ I reload Apache (apache2ctl graceful) then I access to the website, there is 6 php-cgi process : it seems ok since PHP do a fork() to maintain 5 children per "fcgid process". So this configuration should allow 20 (4 * 5) simultaneous php queries, no ? So I run ab with only five concurrent users (-n 5000 and -c 5). And I obtain in my logs : [Fri Feb 27 01:18:45 2009] [notice] mod_fcgid: too much /home//http/v2/index.php process(current:4, max:4), skip the spawn request The DefaultMaxClassProcessCount is reached, but why fcgid try have launched 4 process ? Just one or two should be sufficient in the case of five concurrent users, since each PHP process can handle 5 of them. No ? Or maybe I misunderstood this fork feature of PHP, and FCGID can't use this children in parallel ? But in that case, what is the interest of this fork() ? Thanks for any explanation, Olivier B. -- Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H ___ Mod-fcgid-users mailing list Mod-fcgid-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mod-fcgid-users