Friday, October 29, 2010

Joomla PHP/MySQL Performance Tuning

Hi Friends,

Few days back i was playing with an internal setup of WAMP Server having Apache 2.2.11, PHP 5.3.0 & MySQL 5.1.36 deployed with Joomla 1.5.21 CMS.
For a 500 user base below are Apache & MySQL Parameters for optimal Joomla Performance on a Windows Deployment:
Apache mpm_winnt_module
# ThreadsPerChild: constant number of worker threads in the server process
# MaxRequestsPerChild: maximum number of requests a server process serves

ThreadLimit 1000
ThreadsPerChild 500
MaxRequestsPerChild 0
KeepAlive On
KeepAliveTimeout 60
MaxKeepAliveRequests 100
MaxMemFree 100

MySQL my.ini
key_buffer = 150M
max_allowed_packet = 1M
table_cache = 1000
sort_buffer_size = 1M
net_buffer_length = 8K
read_buffer_size = 1M
read_rnd_buffer_size = 768K
myisam_sort_buffer_size = 64M

These changes are tested & found be working at acceptable levels in my environment. Please consider your deployment sizing & other aspects before adopting above settings.

Apache, WAMP, PHP, MySQL, Performance, Tuning, etc

Thursday, October 28, 2010

Joomla PHP Fatal error: Out of memory

Hi Friends,

Few days back i was playing with an internal setup of WAMP Server having Apache 2.2.11, PHP 5.3.0 & MySQL 5.1.36 deployed with Joomla 1.5.21 CMS.

The first & foremost problem i faced on daily basis was a Apache Crash due to PHP Fatal error: Out of Memory!

Googling around pointed me to increase the memory allocated to PHP in php.ini by changing the parameter
; Maximum amount of memory a script may consume (128MB)
memory_limit 128M
By default, PHP 5.3.0 has 128MB memory allocated. The error logs though pointed to a out of memory crash, it actually didnt have a memory availability issue.

I changed this to 256MB, 512MB & even 1024MB but all the time it crashed :-(
The official parameter description suggested that, if you set this up to -1, there wont be an upper limit capped for PHP.

My next setup test was to change it to -1
; Maximum amount of memory a script may consume (128MB)

memory_limit -1

Well, i wasnt surprised as it still crashed!!
After much digging, i felt that Apache itself wasnt able to handle its memory well on Windows. Many articles i came across also suggested the same.

So in the quest of stablizing Apache on Windows, i started investigating this issue purely from Apache point of view.
An quick overview of mpm_winnt_module parameters on suggested that i needed to have a couple of must needed configurations :-)
  1. ThreadLimit which has a default value of 2500 if not specified, was brought down to 1000
  2. ThreadsPerChild which has a default value of 64 needs to be increased as i had atleast a 500  concurrent user base, so this was changed to 500. Remember, ThreadLimit & ThreadsPerChild go in tandem. You cannot lower ThreadLimit value when compared to ThreadsPerChild.
  3. MaxRequestsPerChild which has a default value of 0, need not be changed as in Windows, we have one parent process managing the other child process which caters to multiple threads. No separate child process forking as possible on Linux/Unix deployments.
  4. KeepAlive should be turned ON. It is very necessary to avoid unnecessary new connections from the same client within a span of 1 minute. The timeout should be turned on with atleast 1 minute.
  5. KeepAliveTimeout which has a default value of 15secs needs to be changed to 60secs i.e. 1minute
  6. MaxMemFree is a directive available in Apache 2.2.x which allows us to specify upto how much free memory will be held by the Apache process without calling the free() function. When not specified this is considered as unlimited, which is generally not good for Apache deployed on Windows Platform as memory leaks are evident. I changed this parameter to 100 in order to force Apache release free memory frequently & avoid leaks. Remember this settings has direct impact to your webserver performance, but if you are seeing too many frequent crashes, this will definitely stabilize the system.
Thats it!
Putting above settings in place along with php memory limit to -1, i was successful in stabilizing the PHP Fatal error + Apache crashes.

Please note that extensive testing was done to arrive at this settings, hence be sure of your implementation requirements & sizing before adopting ;-)

Apache, WAMP, PHP, MySQL, mpm_winnt_module, Joomla, performance tuning, etc.

Wednesday, October 27, 2010

WAMP child process exited with status 3221225477

Hi Friends,

Few days back i was playing with an internal setup of WAMP Server having Apache 2.2.11, PHP 5.3.0 & MySQL 5.1.36 deployed with Joomla 1.5.21 CMS.

The setup was on a Windows 64-bit AMD x86 environment, but i frequently had my Apache go down due to following error: "Parent: child process exited with status 3221225477"

A quick google & it pointed me that it should be related the associated MySQL dll. After going through various articles & bug reports, it made sense to try out one solution!

The solution was to copy libmySQL.dll available under mysql5.1.36\bin to my WINDOWS\system32 folder and then do a complete machine restart.

I did this & believe me there has been no single Apache shutdown reported due to this error :-)
Hope this helps all WAMP or XMPP deployers.

Apache, WAMP, XMPP, PHP, MySQL, Crash, etc