PDA

View Full Version : Anyone used eAccelerator for PHP


niktesla
May 29th, 2007, 01:01 PM
I have 2 servers, each is now running an average load of 9, with peaks between 30 and 80 during high traffic periods. When I say peaks I mean it remains in the red (above 30) for like 4-6 hours straight.

My question is, does anyone have any experience with eAccelerator for PHP, and will this bring my load down?

Any other suggestions for handling such a heavy load will also be appreciated.

I'm afraid I'm gonna kill my servers.

Assailant
May 29th, 2007, 01:22 PM
It helps...but the best thing to do is optimize your scripts running on your server.

minnseoelite
May 29th, 2007, 01:25 PM
I have heard of it but I don't use it....Are you using compression like gzip to reduce file size and server load?

Des
May 29th, 2007, 01:47 PM
What type of numbers are you seeing, traffic wise during those peak times?

Adding eAccelerator might help, but it could just be your servers cant handle the load, in which case eAccelerator would just be a bandaid for a much bigger problem.

Other things you can look at is where the biggest strain on your server is at, like if its the db, images, etc.

If it s the database, then you may have to change the index's around, or add some based on how the sql queries are made. For example


SELECT * FROM `images` WHERE `name`= 'stuff';


Make sure you have a index for the `name` column. Also Select * is handy, but it is more effcient to just request the columns you need rather then all of them. Another thing I learned recently is JOIN's take more resources so, smaller quires are better for larger sites.

If its your images then I would suggest getting a dedicated for just them, and nothing else, or use PhotoBucket.

gzip only works for text, so it will help a little bit, but not for images. Another thing you can look into is memcached it is very handy and I've used to drop our average load quite a bit. Not really our load but the queries to the database. If you dont have root there is a pear class that works very similar to memcached. Thats about all that comes to mind, if you give us some numbers, and the type of hardware it would be easier to asses the problem.

niktesla
May 29th, 2007, 01:48 PM
It helps...but the best thing to do is optimize your scripts running on your server.
they're pretty optimized. i just have it doing a lot. data queries out the *ss.

niktesla
May 29th, 2007, 01:49 PM
I have heard of it but I don't use it....Are you using compression like gzip to reduce file size and server load?

I am NOT using gzip compression.

niktesla
May 29th, 2007, 01:57 PM
60k to 70k uniques per day.

100 to 700 users simultaneous at one time.

300k to 500k page impressions per day.

SERVER:
2 Dual Core AMD 265 - dual core - 1.8ghz \ Opteron 265
8 GB RAM
160GB SATA RAID (2 drives RAID1)
OS: CentOS 4

MySQL: Every field that used in querying is indexed. I've done a lot of optimization with MySQL.

My Load is primarily from PHP and MySQL.

I don't know if there is much else I can do on MySQL.

niktesla
May 29th, 2007, 02:00 PM
Another thing you can look into is memcached it is very handy and I've used to drop our average load quite a bit. Not really our load but the queries to the database. If you dont have root there is a pear class that works very similar to memcached. Thats about all that comes to mind, if you give us some numbers, and the type of hardware it would be easier to asses the problem.

I'll do some research on memcached.

niktesla
May 29th, 2007, 02:23 PM
Another thing you can look into is memcached it is very handy and I've used to drop our average load quite a bit.

Should I:
1. install the PHP extension
2. make and install the linux package.
3. Both

These are my dedicated servers. So I have root. Total Access. I AM THE KING. (It's good to be the King.)

Des
May 29th, 2007, 02:51 PM
http://www.jangro.com/a/2007/02/28/website-performance-tools-how-i-installed-memcached/

A very good blog about how to install memcached, and the php extension. Stupid simple direction even I can follow, I know cause I did :P

magnet2
May 29th, 2007, 03:14 PM
memcached is really good, it is very fast and will make sure your server doesn't have a high load. The cool thing is you can simply store any object you want, for any specific time.

You should compile it as a php extension then put a memcached daemon on each box you own (preferably directly connected with eachother). Before you even open a connection to your db, first check the cache, if it's filled use that if not then make a connection.

About mysql, you have to choose your indexes carefully, putting an index on every field is not good. Make sure each table has an auto_increment key.

niktesla
May 29th, 2007, 03:26 PM
Thanks a lot.

http://www.jangro.com/a/2007/02/28/website-performance-tools-how-i-installed-memcached/

A very good blog about how to install memcached, and the php extension. Stupid simple direction even I can follow, I know cause I did :P

niktesla
May 29th, 2007, 03:29 PM
You should compile it as a php extension then put a memcached daemon on each box you own (preferably directly connected with eachother).


So, if I'm understanding you correctly, I do both, compile and install as php extension and as a daemon.

magnet2
May 30th, 2007, 09:12 AM
So, if I'm understanding you correctly, I do both, compile and install as php extension and as a daemon.

You need to install the php extension, because you want to be able to give commands to the memcached daemon with php. A default installation of php does not know any commands to control the memcached daemon.

So first make sure that is working ok, then compile the daemon, then start the daemon (not under root).

memcached -d -m 1024 -l 127.0.0.1 -p 11211 -u user

rob
May 30th, 2007, 09:18 AM
You can also write something fairly quickly to cache all rendered pages to disk and have your web server render the static .html file instead... and just expire/delete the cached file(s) if you update your content. Or have it periodically expire the cache every so often.. we do this on our site instead of using memcached and it's worked pretty good.

magnet2
May 30th, 2007, 09:25 AM
Yep that's a very good solution as well. If you really want to cache everything, you can also use mod_expires (http://httpd.apache.org/docs/1.3/mod/mod_expires.html) which is an apache module. It adds an expires header with all your images, forcing the browser to cache it (longer).

niktesla
May 30th, 2007, 01:04 PM
You need to install the php extension, because you want to be able to give commands to the memcached daemon with php. A default installation of php does not know any commands to control the memcached daemon.

So first make sure that is working ok, then compile the daemon, then start the daemon (not under root).

memcached -d -m 1024 -l 127.0.0.1 -p 11211 -u user

I got the daemon up and running fine, and the php module compiled and installed, but php is not loading the module any calls to the Memcache class reports error that the class is not available.

added extension=memcache.so to php.ini
memcache.so is in /usr/lib64/php4/ with all other working modules

magnet2
May 30th, 2007, 01:14 PM
I got the daemon up and running fine, and the php module compiled and installed, but php is not loading the module any calls to the Memcache class reports error that the class is not available.

added extension=memcache.so to php.ini
memcache.so is in /usr/lib64/php4/ with all other working modules

Are you sure you used the correct php.ini ? Make a php file and use:

<?php echo phpinfo(); ?>

look at the config line, is there memcached there? Search the page for memcached.

Also, after editing php.ini, make sure you restart apache (httpd) first

niktesla
May 30th, 2007, 02:32 PM
Are you sure you used the correct php.ini ?

Yes. because I added eAccelerator and it shows up on my phpinfo() page.

look at the config line, is there memcached there? Search the page for memcached.

"mod_mem_cache" appears in "loaded modules"

"/etc/php.d/memcache.ini" appears in "additional ini files parsed"

This is odd: in "Environment" the "PWD" has a value of "/usr/src/memcache-2.1.2"
same with _ENV["PWD"]=/usr/src/memcache-2.1.2


Also, after editing php.ini, make sure you restart apache (httpd) first

Of course. I'm not NEW :)

niktesla
June 14th, 2007, 02:18 AM
WOW

I finally got it. (Note: PHP version must be 4.3.11 or higher)

Once I rewrote my queries to use the cache, then I activated memcached and eAccelerator my load dropped from 48.2 to 0.54... AMAZING.

I haven't monitored it during my heaviest traffic load yet, but I have a feeling it will be alot lower than it was :)

I can't thank you guys enough for the resources and advice.

Thank you! Thank you! Thank you! Thank you! Thank you!

Memcached + eAccelerator saved my servers.

mincioni
June 16th, 2007, 08:02 AM
Hey,

Did eAccelerator and/or Memcached make a difference in performance?

How much improvement could one expect from each?

Any reliability problems with either one?

Ajay
June 16th, 2007, 08:41 AM
I'm wondering about eAccelerator also, do you think it would benefit a site that doesn't use mysql at all. Right now my load is like 0.33 with around 15k traffic from all my sites.

niktesla
June 16th, 2007, 12:59 PM
Definitely a + for performance. The amount of improvement you can expect depends mostly on the number and complexity of your PHP scripts. eAccelerator does not do anything with or for MySQL, so it's OK to use on you platform.

Basically what it does is cache your PHP scripts so that the system doesn't have to read it from the Harddrive.

I would definitely recommend it.

Ajay
June 16th, 2007, 01:11 PM
good to know, i'm going to give it a shot. thanks for the info.