Opcode Cache

Discussion in 'Install/Configuration' started by markb1439, Feb 5, 2011.

  1. markb1439

    markb1439 New Member

    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.
  2. NiteWave

    NiteWave Administrator

    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.
  3. markb1439

    markb1439 New Member

    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?
  4. markb1439

    markb1439 New Member

    I also read this:

    Is this true? We run mostly WordPress, but we also need suEXEC.
  5. NiteWave

    NiteWave Administrator

    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.
  6. markb1439

    markb1439 New Member

    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
  7. markb1439

    markb1439 New Member

    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
  8. NiteWave

    NiteWave Administrator

    yes, this way.
  9. markb1439

    markb1439 New Member

    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.
  10. mistwang

    mistwang LiteSpeed Staff

    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.
  11. markb1439

    markb1439 New Member

    Thank you.

    On a system with 16 GB RAM (Running LSWS 2-CPU), what size would you recommend setting for /dev/shm?
  12. mistwang

    mistwang LiteSpeed Staff

    depends on amount of free memory left on your server.
  13. markb1439

    markb1439 New Member

    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: Feb 9, 2011
  14. NiteWave

    NiteWave Administrator

    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: Feb 10, 2011
  15. markb1439

    markb1439 New Member

    Thank you very much for taking the time to provide all of these answers. :)
  16. markb1439

    markb1439 New Member

    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
  17. NiteWave

    NiteWave Administrator

    right - "The key and content cache and the session functions have been removed" from http://eaccelerator.net/wiki/Release-0.9.6

    however, read above release note of 0.9.6, 0.9.5.3 not support php 5.3 yet. not bad to try 0.9.5.3 as long as it's working well with your applications.

Share This Page