Hi All, Just installed xCache and I've noticed that PHP scripts listed as being cached is being cleared despite the php.ini settings xcache.gc_interval=0 and xcache.ttl=0. To my understanding this should mean that scripts never expire and garbage collection is disabled, resulting in scripts never being removed from cache. Any ideas why this might be? *edit* BTW, I'm using xCache 1.2.1 dev with PHP 4.4.4 on a Windows 2003/IIS6 box with PHP configured to use FastCGI. I'm wondering if this has anything to do with having PHP configured to use FastCGI mode?
on 19.02.2007 15:25
on 19.02.2007 21:10
Dominic Ryan wrote: > Hi All, > > Just installed xCache and I've noticed that PHP scripts listed as being > cached is being cleared despite the php.ini settings > xcache.gc_interval=0 and xcache.ttl=0. To my understanding this should > mean that scripts never expire and garbage collection is disabled, > resulting in scripts never being removed from cache. Any ideas why this > might be? > > *edit* > > BTW, I'm using xCache 1.2.1 dev with PHP 4.4.4 on a Windows 2003/IIS6 > box with PHP configured to use FastCGI. I'm wondering if this has > anything to do with having PHP configured to use FastCGI mode? I didn't realise fastcgi worked with php 4 and ii6 - are you sure its not ordinary CGI? Microsoft/Zend recently had press release that they were collaborating to support fastcgi with PHP 5.2.1 and a fastcgi extension for IIS 6/7 which is available at the moment as a technology preview.
on 20.02.2007 01:25
Jay Rabbit wrote: > I didn't realise fastcgi worked with php 4 and ii6 - are you sure its > not ordinary CGI? Microsoft/Zend recently had press release that > they were collaborating to support fastcgi with PHP 5.2.1 and a > fastcgi extension for IIS 6/7 which is available at the moment as a > technology preview. PHP FastCGI for IIS has been around since 2002 when it was developed by Shane Caraveo. If you want a look I have included it in a free PHP installer (currently PHP 4.4.1) I developed for IIS which can be found here; http://www.iis-aid.com/iis_aid_php_installer My installer currently uses APC for the bytecode cache, but unfortunately it is just not stable for the PHP 4.x branch. I'm hoping to replace APC with xCache in my installer as I want to have a bytecode caching system that is fast and stable on both the PHP 4.x and PHP 5.x branches. The FastCGI module the IIS lads at Microsoft are working on will be better when it's finished, but that will be several months away yet. Any ideas why xCache seems to be clearing my cache? It seems to be doing it every 30 seconds or so. It's almost like the xCache cache is tied to the individual PHP.exe processes being launched by FastCGI and then being cleared when FastCGI recycles the PHP.exe process.
on 20.02.2007 09:10
It would be tied to the exe if your fastcgi implementation spawns one for each thread. To share the cache between threads you need to have one php.exe spawn multiple fastcgi child threads rather than have your fastcgi implementation spawn multiple php.exe processes.
on 22.02.2007 10:50
Jay Rabbit wrote: > It would be tied to the exe if your fastcgi implementation spawns one > for each thread. To share the cache between threads you need to have one > php.exe spawn multiple fastcgi child threads rather than have your > fastcgi implementation spawn multiple php.exe processes. Hi Jay, As much as it disappoints me, I think that you might be right. I reconfigured my FastCGI implementation with these values; StartServers = 1 MaxServers = 1 IncrementServers = 0 PHP_FCGI_MAX_REQUESTS = 1000 This basically changed FastCGI so that it only used a single PHP.exe process that does not get recycled for 1000 requests. After I did this and restarted IIS the xCache cache list no longer got cleared. Not sure what to do from here as neither eAccelerator or APC have this issue.
on 22.02.2007 18:11
> This basically changed FastCGI so that it only used a single PHP.exe > process that does not get recycled for 1000 requests. After I did this > and restarted IIS the xCache cache list no longer got cleared. Not sure > what to do from here as neither eAccelerator or APC have this issue. you should set PHP_FCGI_CHILDREN=1 or greater 1 works but may not be what u want it depends on what shm your're using. APC/XCache is usnig anonymous mmap, they should behavior same on this problem there's same problem in ea if u use anonymouse mmap. See hhttp://trac.lighttpd.net/xcache/wiki/Faq#Whyismycachebeingcleared
on 23.02.2007 15:42
moo XCache wrote: > you should set PHP_FCGI_CHILDREN=1 or greater > 1 works but may not be what u want > > it depends on what shm your're using. > APC/XCache is usnig anonymous mmap, they should behavior same on this > problem > there's same problem in ea if u use anonymouse mmap. > > See hhttp://trac.lighttpd.net/xcache/wiki/Faq#Whyismycachebeingcleared Ok, thanks mOo, I'll take a look at that. That might explain why APC is so unstable on my server using FastCGI. APC is ok for a few minutes but then proceeds to consume all the CPU and RAM until the entire server is in deadlock. A pity really as APC has a really nice admin interface. Can I use any settings other than mmap for xcache.shm_scheme?
on 24.02.2007 13:37
> Can I use any settings other than mmap for xcache.shm_scheme?
not yet, there shall be shmat+futex etc in the futher if someone(or me)
implement it
on 24.02.2007 18:41
Hi moo,
Might still have an issue. I set the PHP_FCGI_CHILDREN variable as you
suggested to this;
PHP_FCGI_CHILDREN = 8
I restarted IIS and verified PHP registered this variable with
phpinfo(); but it seems that the IIS version of FastCGI might not use
the PHP_FCGI_CHILDREN variable as no extra php.exe processes were being
started. If I understand it right FastCGI should start up more php.exe
processes up to the value of PHP_FCGI_CHILDREN (8 in this case), but
this did not happen and I started getting a lot of unable to connect to
FastCGI server errors as the single php.exe process was unable to serve
all the requests. Any ideas?
Here is a list of my process tree;
C:\Systernals\PSTools>pslist -t
pslist v1.28 - Sysinternals PsList
Copyright ⌐ 2000-2004 Mark Russinovich
Sysinternals
Process information for IIS-AID:
Name Pid Pri Thd Hnd VM WS
Priv
Idle 0 0 4 0 0 28
0
System 4 8 584 11554 7144 68
0
smss 52656 11 4 22 4060 448
164
winlogon 18552 13 21 494 43824 9424
6884
lsass 13936 9 31 548 60236 10080
9112
logon.scr 51080 4 1 16 14468 1656
360
services 73752 9 16 299 52752 3460
1552
elementmgr 1756 8 3 70 18828 3664
1456
svchost 35304 8 11 349 45888 5372
4300
inetinfo 37512 8 12 213 50724 9268
4024
hMailServer 46564 8 26 369 80208 7640
7180
svchost 47168 8 15 174 32356 8312
5456
w3wp 44788 8 29 267 85100 15300
12812
php 388 8 2 96 88228 10772
9796
php 47392 8 2 100 88228 10772
9796
php 59940 8 2 100 88228 10772
9796
php 74120 8 2 100 88228 10772
9796
php 95512 8 2 98 88228 10772
9796
I wonder if there is a way of tying xCache to the worker process (w3wp)
rather than the php.exe processes?
on 25.02.2007 05:13
u may have to make the webserver starts only 1 php fcgi first and make php fork 8 childs later do u set env in system properties? a system restart maybe required for it to make effect. just make sure php got the env variable, u may check it with prcview.exe (3rd party tool)
on 25.02.2007 11:24
moo XCache wrote: > u may have to make the webserver starts only 1 php fcgi first > and make php fork 8 childs later > > do u set env in system properties? a system restart maybe required for > it to make effect. just make sure php got the env variable, u may check > it with prcview.exe (3rd party tool) I think there must be a difference in the IIS implementation of FastCGI (at least with IIS 6). With IIS FastCGI the isapi_fcgi.dll launches the extra php.exe processes as needed, but these are not child processes of any existing php.exe processes, they are child processes of the worker process (w3wp.exe) containing the isapi_fcgi.dll ISAPI extension. Unless I am missing something it seems that IIS doesn't use the PHP_FCGI_CHILDREN variable at all, which seems to be confirmed with the testing I've done as all php.exe processes are child processes of the w3wp.exe process, not other php.exe processes. Here is Shane Caraveo's doco on the FastCGI module he wrote for IIS; built on a modified fastcgi 2.2.2 library ------------------------------------------------------------------------ Minimal Configuration to get working ------------------------------------------------------------------------ See the registry section below for details. Also see the IIS or NSAPI configuration information that must be done in addition to this. To configure an interpreter such as PHP, use the following registry entries in HKLM/SOFTWARE/: FASTCGI/.php/ AppPath c:\php\phpfcgi.exe BindPath php-fcgi To get Perl, or some other fastcgi processor (TCL, etc.) working, use: FASTCGI/.fpl/ AppPath c:\perl\bin\perl.exe FASTCGI/.ftcl/ AppPath c:\tcl\tcsh.exe To get a compiled executable working, such as the echo example in the fastcgi distribution, use: FASTCGI/echo.fcgi/ AppPath c:\path\to\echo.exe Under IIS, we cannot map the exe extension (IIS prevents that), so we have to use some other extension (such as .fcgi) and map it internally to .exe. ------------------------------------------------------------------------ configuration for IIS ------------------------------------------------------------------------ add to the application mappings extensions you want to be sent to the fastcgi dll. For authentication to work properly in all instances, you MUST check the 'Check that file exists' checkbox, this has the unfortunate side effect of breaking path_info values. To provide proper IIS security, you should also utilize the impersonation features described below and at www.caraveo.com/fastcgi/ ------------------------------------------------------------------------ configuration for NSAPI (iPlanet, Netscape) ------------------------------------------------------------------------ add to mime.types: type=magnus-internal/x-fastcgi exts=fphp add to obj.conf Init fn="load-modules" shlib="c:/path/to/nsapi_fcgi.dll" funcs="FCGIServiceHandler" shlib_flags="(global|now)" --to the < Object name="default" >-- Service fn="FCGIServiceHandler" type="magnus-internal/x-fastcgi" -- and finally -- <Object name="x-fastcgi"> ObjectType fn="force-type" type="magnus-internal/x-fastcgi" Service fn=FCGIServiceHandler </Object> ------------------------------------------------------------------------ configuring the process manager ------------------------------------------------------------------------ Most keys have defaults, and do not need to be set in the registry. Requird keys will be marked so. create the registry keys: HKEY_LOCAL_MACHINE\Software\FASTCGI MaxPostData REG_DWORD 0 (Byte limit for pre-reading the post data) CustomVars REG_BINARY 0 (newline deliminated, null terminated list of custom environment names, can be used to specify additional environment names that the web interface should look for in addition to the defaults) ThreadPoolSize REG_DWORD 10 (IIS ONLY, 10 is default if not specified) BypassAuth REG_DWORD 0 IIS ONLY, if 1 and IIS is configured to use isapi_fcgi.dll as a filter, and IIS is configured to use BASIC authentication, this will force all authentication requests to use the IIS anonymous user. This in effect allows scripts to implement their own authentication mechanisms. Impersonate REG_DWORD 1 IIS ONLY, if 1, IIS security tokens will be used to impersonate the IIS authenticated (or anonymous) users. This is on by default. setting to zero dissables this feature. Don't dissable it unless you are not worried about security. StartServers REG_DWORD 5 Global value, used if no server specific setting IncrementServers REG_DWORD 2 Global value, used if no server specific setting MaxServers REG_DWORD 25 Global value, used if no server specific setting Timeout REG_DWORD 600 Global value, used if no server specific setting. How long (seconds) extra servers (number above StartServers) are kept alive before being terminated create a key for each extension: HKEY_LOCAL_MACHINE\Software\FASTCGI\.php REQUIRED inside that key, add the following values: BindPath REG_SZ "php-fcgi" REQUIRED AppPath REG_SZ "c:\php\phpfcgi.exe" Args REG_SZ "" StartServers REG_DWORD 5 IncrementServers REG_DWORD 2 MaxServers REG_DWORD 25 Environment REG_BINARY (newline deliminated, null terminated, for adding additional environment variables ie. PHP_FCGI_MAX_REQUESTS=25) Filter REG_DWORD 0 If set to 1, this fastcgi server will be treated as a FastCGI FILTER. A Filter server receives the file to be filtered from the web server. for more information, see documentation at fastcgi.com Timeout REG_DWORD 600 How long extra servers (number above StartServers) are kept alive before being terminated If the fast cgi application is started by an external process manager you only need to use the BindPath. You can set BindPath to a ip address/port if you need to use an interpreter on a different machine. Multiple extensions can have the same BindPath, for instance, mapping .pl and .cgi to perl.exe. If IncrementServers is not defined, it defaults to 1/2 StartServers. If MaxServers is not defined, it defaults to 25. How the process manager works ------------------------------------------------------------------------ It's fairly simple and needs to be further fleshed out. At startup, it starts "StartServers" number of executables for each binding. When running, if none are available, it starts "IncrementServers" more executables, up to "MaxServers". ------------------------------------------------------------------------ building ------------------------------------------------------------------------ Download the devkit from www.fastcgi.com, and expand into the fastcgi directory build the fastcgi development kit ------------------------------------------------------------------------ testing ------------------------------------------------------------------------ You can use the stress test application to test the isapi_fcgi.dll against the php test scripts. stresstest -m /path/to/isapi_fcgi.dll -d /path/to/php4source -t 10 IIS debugging info at: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfcnotes_tn063.asp
on 25.02.2007 13:26
sorry, you're right, PHP_FCGI_CHILDREN isn't supported by php-fcgi win32 version u may try zend's php winenabler, it's commercial however hope if someone make/patch a win32 multi threaded php-fcgi like mod_php for apache/iis
on 25.02.2007 21:55
moo XCache wrote: > sorry, you're right, PHP_FCGI_CHILDREN isn't supported by php-fcgi win32 > version > u may try zend's php winenabler, it's commercial however > > hope if someone make/patch a win32 multi threaded php-fcgi like mod_php > for apache/iis That is a real shame :( I think Zend have discontinued WinEnabler. Have a feeling there is a replacement product, but can't remember what it is. Anyway, I was really looking for an Opcode cache for the PHP Installer I created for IIS to replace APC that is stable for both PHP 4 and 5. Looks like I'll have to stay with EA for PHP 4 and continue to sit on the fence for PHP 5. Haven't tested Microsoft's new FastCGI module with xCache yet. Hopefully I'll have more luck with it.

