Opcode Cache

markb1439

Well-Known Member
#1
Hi,

What is the best way to set up an opcode cache for LiteSpeed? I have heard various facts about this, some of which conflict with each other.

In case it's relevant, our Apache setup included suPHP.

Please let me know which opcode cache will give the best performance and reliability, and please advise on the recommended installation procedure for that cache in LiteSpeed.

Thanks.
 

NiteWave

Administrator
#2
for shared-hosting, which php in suExec mode, only eAccelerator works well. and best to use its on-disk cache.

for dedicated server, which php run as nobody, APC and XCache may be better, using its in-memory cache.
 

markb1439

Well-Known Member
#3
for shared-hosting, which php in suExec mode, only eAccelerator works well. and best to use its on-disk cache.
Thanks. I have seen various instructions on how to set this up under LiteSpeed. Can you point me to the proper step-by-step instructions?
 

markb1439

Well-Known Member
#4
I also read this:

wordpress+eaccelerator does not work right when PHP suEXEC is enabled (in fact I know PHP suEXEC causes several issues for several programs I used so I have disabled it)
Is this true? We run mostly WordPress, but we also need suEXEC.
 

NiteWave

Administrator
#5
I have seen various instructions on how to set this up under LiteSpeed
I recommended this one:
http://www.litespeedtech.com/support/forum/showthread.php?t=4431

Haven't heard of eAccelerator + php suExec + wordpress not working ...

regarding wordpress, page cache is more important than opcode cache. One wordpress plugin "wp super cache" is recommended to install, it generates static pages for guest visitor. it'll boost the performance a lot. there may be other similar plugin, but we know this one works well.
 

markb1439

Well-Known Member
#6
Thank you.

That link shows configuration after installation...is there a definitive guide to installing eAccelerator? I am confused about using the prebuilt binary (how to do that if I have already built a matching PHP binary).

Also, we will be using WP Super Cache. Do we also need an opcode cache, or will the difference be nominal?

Thanks,

Mark
 

markb1439

Well-Known Member
#7
To install eAccelerator, can I just add that option in EasyApache, and then build the matching PHP binary? Or do I need to do something else?

Thanks,

Mark
 

markb1439

Well-Known Member
#9
Thank you for the clarification. I had heard that it was necessary to install EA separately, so I am glad this is not the case.

In my situation (suPHP), which EA cache scenario would you recommend (/dev/shm, etc.), and how often to clear the cache? Is there a certain cron directive you recommend (deleting the directory daily, clearing out old files, etc.)?

Thanks.
 

mistwang

LiteSpeed Staff
#10
You can use command as often as you want
"find /dev/shm -type f -mtime +1 -delete"

It removes files more than 1 day old. For eAccelerator, you may not need to clean it, it should take care of it itself.
 

markb1439

Well-Known Member
#13
Thank you.

I hope someone will be willing to answer a few followup questions. There are so many pieces of information on eAccelerator available, it's hard to put them all together.

1) I understand that the use of 1MB shm setting is to force eAccelerator to use the disk cache as much as possible. Can this also be achieved with these parameters:

eaccelerator.keys = "disk_only"
eaccelerator.sessions = "disk_only"
eaccelerator.content = "disk_only"

2) We are not sure that eAccelerator is helping much. On WordPress sites with WP Super Cache, we see no noticeable improvement. On Magento we sometimes see improvement, but the gains are inconsistent. Sometimes the sites load quickly, sometimes they don't.

3) How important is it to cache in /dev/shm? Is that significantly faster than elsewhere (e.g., /tmp)

4) We have created /dev/shm/ea, but of course it disappears on reboot. What is the best method for making sure this directory remains.

5) In CentOS (openvz), to create /dev/shm in fstab, should it be:

Code:
none                    /dev/shm                tmpfs        0 0
or

Code:
shm                    /dev/shm                tmpfs        0 0
6) In an suEXEC environment (Apache compiled with suPHP and Suhosin), is it risky to set the eAccelerator cache at 777? Should we set more restrictive permissions and give ownership to the web server user? If so, what are the proper settings?

Sorry for so many questions. Since there isn't a step-by-step guide to installing and using eA with LiteSpeed, I'm trying to piece it all together.

Thanks,

Mark
 
Last edited:
#14
eAccelerator's officical and latest document:
http://eaccelerator.net/browser/eaccelerator/trunk/README

1.these configuration options no longer exist in latest 0.9.6.1

2.the improvement may only be noticeable in high traffic, you can benchmark (apache ab)wordpress or magento homepage to simulate high traffic. note: need disable wp super cache before the benchmark. otherwise, php engine and eAccelerator even not run since of page cache.

3./dev/shm is your memory. usually it's faster than disk. so if /dev/shm is occupied with files, you'll see free memory decrease. need be careful to utilize this resource. for sites which traffic is not so high, and page cache(for example wp super cache) is enabled, it may not be much difference between /tmp and /dev/shm. in this case, /tmp is recommended, to leave more free memory to kernel.

4.run a command during boot up. for example, add 2 lines to /etc/rc.local
mkdir /dev/shm/ea
chmod 777 /dev/shm/ea

5.looks no difference. the OS default should be OK

6.in suExec mode, php process run under user's account, and opcode cache is created by php process. /dev/shm/ea has to be set as 777, since all user accounts may create directory and files(cache) under it. however each file(the opcode cache) owned by different accounts, not easy to overwrite each other -- the cache location is based on the inode of the php file. -- my answer on this may not be that right, please refer eAccelerator document or search net for more discussion.
 
Last edited:

markb1439

Well-Known Member
#16
>> To install eAccelerator, can I just add that option in EasyApache,
>> and then build the matching PHP binary?

yes, this way.
I've heard that the latest version of eAccelerator (0.9.6, which I believe is included in EasyApache), does not support caching of user objects...it only optimizes and caches PHP scripts. Is this true? If so, is it better not to compile eAccelerator in EasyApache, and instead to manually install an older version such as 0.9.5.3?

Thanks,

Mark
 
Top