February 14, 2008

eAccelerator is Good :)

One of the servers we've had for a while was running a bit slow.  After a few hours of searching, I've found out that one of the PHP scripts was running a mailer and it was just dragging the system down.  Although most of the load was through exim, our mailer, I found that apache was hogging up a bit of resources as well.  Since our server load was high and we were getting a decent number of visitors hitting on our vBulletin as well as a PHP lyrics script that I partially wrote for our Vietnamese lyrics website.  I went to search on how to optimize PHP scripts and I came up with eAccelerator.

The process of getting, untarring, building and installing took less than 20 minutes.  Of course, it may have taken a bit more in real time since I was eating and watching a movie at the same time.  I tried to put the eaccelerator.ini file inside of my /etc/php.d folder, but it didn't work out too well.  In fact, it didn't work at all :).  So I went with the putting it inside of my php.ini file.  Of course, I went with the default settings for my php.ini file:

[code lang="php"][eAccelerator] extension="eaccelerator.so" eaccelerator.shm_size="0" eaccelerator.cache_dir="/tmp/eaccelerator" eaccelerator.enable="1" eaccelerator.optimizer="1" eaccelerator.check_mtime="1" eaccelerator.debug="0" eaccelerator.filter="" eaccelerator.shm_max="0" eaccelerator.shm_ttl="0" eaccelerator.shm_prune_period="0" eaccelerator.shm_only="0" eaccelerator.compress="1" eaccelerator.compress_level="9"[/code]

I restarted apache and saw an immediate decrease in load!  It was averaging about 2.7 before and about 2.3-2.4 afterward.  I would venture to make a guess that eAccelerator does work and it did take some load off of the server when it needs it the most.  As to shm_size, I just set it to 0 and let the system take care of whatever size it needs.  I have a newer server that has a lot of RAM, so I gave it about 128MB of shared memory.  If the server becomes too slow for some reason, I'll start playing around with this number to see if there's an optimal size.

Filed under Blog, Servers, Web Development by A.K.

Spread the Word!

Permalink Print Comment

Leave a Comment