Server stability issues for PHP/eAccelerator/Apache
Hi all
We have had ongoing server difficulties, using Apache 2.0.59, PHP 5.1.6, and eAccelerator 0.9.5. It was my intention to use FastCGI (as per a previous post) but on our troublesome server, this has worsened things, so I'm giving up on that for the moment. We are sadly not in a position to move servers, as presently we don't have a spare to move to. I'd therefore like to ask advice from forum users as to the things I might try changing to improve our stability. One solution we have found is to deploy a script that stops and starts the service every two hours, although this isn't desirable over the long term, of course. Without this, we get errors like "FATAL: erealloc(): Unable to allocate 126581 bytes" in the Apache error log.
We are unfortunately not in a position to upgrade PHP, as we are using an old version of the symfony framework and need to upgrade this first before it will work with the 5.2 branch. We intend to do this, but don't have time to do so at present. One thing however I am trying is to turn off the eAccelerator optimiser, as I've heard it can cause stability issues. On a careful basis I intend to expand the restart window to see if crashes start happening again.
Does anyone think that installing the latest version of Apache might help? I believe this will work with the rest of my stack. However if anyone suggests that the stability is unlikely to originate from this part of the system, I won't disturb our live environment. Also, it is worth my moving to eAccelerator 0.9.5.1? This could be deployed very easily. Would I be right in thinking this would be expected to work with PHP 5.1.6?
Thanks all.

Delicious
Digg
Reddit
Google
Technorati
Stability Apache 2/&PHP
Hi,
I think this stability issue is really a Apache2/PHP issue. After playing with Apache2 for the last year, I found that pretty incredible but true. I've found numerous posts about this on the web. Basically at this point PHP.net does not support Apache2 (mostly because of the extensions that have to be re-written to be thread safe).
You can see the warning from PHP.net for both Unix and Windows versions of Apache 2.
http://www.php.net/manual/en/install.unix.apache2.php
http://www.php.net/manual/en/install.windows.apache2.php
In fact they say that stack is more stable on Windows, see below (but still not 100%):
If you feel you have to use a threaded MPM, look at a FastCGI configuration where PHP is running in its own memory space.
And finally, this warning against using a threaded MPM is not as strong for Windows systems because most libraries on that platform tend to be threadsafe.
My recommendations would be:
1) Run PHP with FastCGI:
See: http://www.sitebuddy.com/php/php_apache_fast_cgi_install
Using FastCGI is kind of like running with Apache1 (each PHP request has its own "space" separate for the next php request). To make up for the loss in speed (CGI is a lot slower then the module version of PHP) use eAccelerator.
2) Run with Apache1
3) Run with IIS
I might have been lucky but I've been running some PHP4 sites with IIS5 for years without any major issue. I got into Apache2 on Windows mostly for the Clean URLs and for the fun of it...
Very helpful - thanks!
Chris - many thanks indeed. After all the research I've done on this - about KeepAlive, RequestsPerChild and the like - I'm surprised I haven't come across the advice from the PHP team before (and the myriad of commentators on the topic). And like you, I am even more surprised that there is no guaranteed stable PHP module in Apache 2 on the NT-based versions of Windows. I had specifically used Apache 2 because it was the first line of Apache web server releases approved by the Apache team (AFAIAA) to run on Windows.
I was planning on upgrading to Apache 2.2.4 and then using a custom php module (compiled by the good people at Apache Lounge) to link to PHP 5.1.6. However I am changing my mind now - from what you say, and the related web links I have now discovered as a result, I don't think this will help.
Anyway, thank you for your advice. I am less keen to use IIS as I am not convinced about the solidity of PHP5 upon it and the completeness of mod_rewrite replacements, although I'll go down this route if I have to. Apache 1.3 is a possibility, but I thought that it wasn't particularly recommended for a Win environment? In any case support for it is waning fast, in my view, if it hasn't waned completely already.
Now if I were to discount these two items, it leaves the FastCGI option (we already use eAccelerator, so reliability is more important than speed at present). I didn't manage to get FastCGI working on a dev server, but found the alternative FCGI perfectly easy to install and I've had no troubles with it under low load. Unfortunately setting this up in a new Apache instance on our live server stopped the existing instance (threading problems and server instability are equally likely - it's an old box) so I am tempted to schedule some downtime next week to stop the live server entirely and to test FCGI in isolation.
One last question - and I have a feeling the answer is going to be 'no' - is it possible to use Apache in prefork mode on Windows? If this is possible but would require recompilation, there may well be someone on the net who has created this binary already. I have just installed Apache2 on Linux (sadly not available for live apps) and it just *feels* much more solid.
I agree, being sort of new
I agree, being sort of new to this Apache2/PHP stack, I'm amazed that if you start searching on the web, what you will found on this topic. I don't remember where it was but one of "my founds" was this blog of one of the PHP core developer(?), on which he was defending strongly that PHP runs fine of Apache 1 and that was that...
I guess we have a lot of recycling going on the web since Apache2/PHP is probably running millions of web sites.
Don't give up on the FastCGI. Just follow my instructions here:
http://www.sitebuddy.com/php/php_apache_fast_cgi_install
I use method b.2)
For the "prefork mode" on Windows the best is to ask Steffen at ApacheLounge. He's real nice and if it's possible I'm sure he will do it. I'm suspecting he would have to port the old Apache 1 code to Apache 2 and this could be some serious work (days, weeks, months ?).
FCGI feedback
Well, out of interest we went live with FCGI yesterday, and things have been *much* better. Not only are we not getting random crashes, but the response time feels more zippy too. I suspect the problems I was having configuring it were down to my trying to serve from the same location as another Apache instance running Apache2Handler. Perhaps it should have been obvious that the two were going to conflict! In the end I opted for some downtime, and after much fiddling with settings (and longer downtime than I had originally promised!) I got it working. No out-of-hours calls were received last night, which was rather nice.
Thanks Chris again for your assistance. Meanwhile using prefork on Windows would be interesting, but now that things appear to be working, I think I will leave them alone. I'd much prefer to be using Linux, but it remains to be seen whether I will be allowed to specify this for our next web server ;)
Excellent, I'm glad you
Excellent, I'm glad you persevered and got FCGI working.
This is a evolving situation, for the first time a SiteBuddy user (pellmell) reported a stable stack (Apache+PHP+eA) !
He's running Apache 2.0.59 PHP 5.2.2 eA 0.9.5.1 with some decent traffic without stability issues for the first time.
See his post: update - more stable, too!
He will post back in a few weeks to let us know if it's still stable (might be time to go back to the PHP as a module with those versions 522 & 0951).
I'm suspecting they have fixed a few thing with PHP 5.2.2 and maybe the latest eA helped (0.9.5.1)
Well, we're getting there
As an update, we're not 100% stable yet. We've had the main Apache process crash out a couple of times while running mod_fcgid, and we're still looking into the cause. Any thoughts from folks here would be much appreciated. For a little over a weeks worth of traffic, we get:
For info, we are running with the following options:
KeepAlive On
MaxKeepAliveRequests 200
KeepAliveTimeout 5
ThreadsPerChild 125
MaxRequestsPerChild 10000
Win32DisableAcceptEx
EnableMMAP off
EnableSendfile off
I wonder whether bringing the ThreadsPerChild down might help? AFAIK the threads are created and are unused, since all the traffic goes through FCGI. I am tempted to turn off KeepAlive too. If we completely run out of ideas, I will try replacing FCGI with FastCGI. Any thoughts how I might trace the core issue?
Addendum
As an addendum, we have the following PHP modules (php -m). The starred items are loaded by me, the others I presume are compiled in to the Window 5.1.6 binary:
bcmath, calendar, com_dotnet, ctype, date, dom
eAccelerator *
ftp, hash, iconv
json *
libxml
oci8 *
odbc, pcre, Reflection, session
SimpleXML, SPL, standard, tokenizer, wddx
win32service *
xml, xmlreader, xmlwriter
xsl *
zlib
I have run thisfor quite
I have run this
for quite some time now, since 2007-04-30.
It has never been any problems, ever since first install of this setup.
================================
Windows XP Home
Apache 2.2.4
PHP 5.2.1 ( php5apache2_2.dll )
eAccelerator095_i284.dll
================================
here is my server setup:
http://okay.mine.nu/
Today I visited here for download
and prepare for PHP 5.2.2 upgrade.
What I REALLY Miss is some information
what is the best/latest/working version of 5.2.2 eAccelerator??
Maybe it is some history of Release notes
- at least some Dates when these different modules were made ....
I am talking about this 'djungle of files':
- eAccelerator0951_5.2.2_VS_2005.dll
- eAccelerator0951_5.2.2.dll
- eAccelerator095_i284_5.2.2.dll
I just want some hint which DLL I should use.
Preferably the latest stable and working version.
I do not have too much time to try them all, one by one.
Maybe someone else have lots of time.
And can tell us?
Regards
and very much thank you
for this service and builds for Windows!
/halojoy
Which eA to use....
The latest DLL is:
- eAccelerator0951_5.2.2.dll
- eAccelerator0951_5.2.2_VS_2005.dll is the exact same code compiled with Visual Studio 2005 SP1. This requires installing the VC runtime distributable available here (its probably installed on the computer of most):
Microsoft Visual C++ 2005 SP1 Redistributable Package
If you use eAccelerator0951_5.2.2_VS_2005.dll & eAccelerator0951_5.2.2.dll and see a difference let us know.
- eAccelerator095_i284_5.2.2.dll is the previous version and should not be used anymore since eAccelerator0951_5.2.2.dll is rported to be running fine by many (including sitebuddy.com)
When a release a new DLL they are not tested. We just release to many version to test and don't have the time. So we will usually keep the "last know version to work".
So that we need feedback from you and others to know when a DLL works (or not) usually if two regular users say it works, I assume it does.
At this point eAccelerator095_i284_5.2.2.dll (which was eA code 095 with fix i286 applied) will be retired since eAccelerator0951_5.2.2.dll is working. Thanks for pointing this out.
Cheers,
Chris