optimal opcode setup for large shared hosting plesk server

Discussion in 'PHP' started by strebel, Nov 3, 2010.

  1. strebel

    strebel Member

    Hey there,
    Looking for suggestions on how best to configure the moving parts to take the most advantage of litespeed and an opcode cache. We need to maintain security but want to maximize performance and reduce cpu load.

    - Litespeed Web Server Enterprise v4.0.17
    -- LSAPI in suExec as lsphp5
    - Plesk 9.5.3
    - Currently eAccel complied thru LS

    Our #1 priority is security hence the suExec, but performance is a very close #2

    Plesk has a toggle for the domain settings to run as Apache, FastCGI, or CGI. We leave it on FastCGI or CGI to spawn the php process as the file owner so it has write permissions without needing 777.

    We are looking for the best way to implement an opcode, APC, eAccell or what have you. So my specific questions knowing that we need to keep suExec and plesk are:

    1. Which opcode works best?
    2. What are the ideal config settings for the opcode?
    3. Allocate 1mb, 10mb or even 10gb of ram for it?
    4. Is the ram allocated on a per vhosts basis or server wide? How is it utilized?
    5. Does the opcode reset when the suExec php process terminates? Is there any way around it?
    6. Anything we can do in plesk to achieve a better setup?

    Some LS specific questions:
    • What are the ideal settings for LSAPI for ram/process on very large shared host? Over 800 vhosts
    • Max children?
    • Max connections? etc.
    Last edited: Nov 3, 2010
  2. NiteWave

    NiteWave Administrator

    in your case, please try eAccelerator and monitor the result.
    the idea is to use opcode cache on disk - only eAccelerator provide on disk cache. only give 1M memory cache. but the disk actually in shared memory area.

    1.need create /dev/shm/ea folder first, and set permission 777
    2.create a cron job to cleanup /dev/shm/ea.

    your case is shared hosting, php suExec enabled.
  3. strebel

    strebel Member

    is 1M kinda meh?

    WordPress will if allowed fill 20-32mb of opcode cache on a single page load.

    Is 1M for each 800 domains (800mb total ram used for cache) better than nothing i guess?
  4. NiteWave

    NiteWave Administrator

    set to 1M --- because can't set lower than 1M. if eAccelerator has a option to disable in memory opcode cache, then let's use it. :)

    in php suExec mode, php process will start/stop frequently. in-memory cache will disappear with the terminated php process. while cache in disk remains there and can be re-used by future php process. eAccelerator will look for in-memory opcode cache first, if not found(since only give it 1M cache), it look for cache on disk.
  5. strebel

    strebel Member

    So are you saying over time that the disk cache will accumulate and grow for each vhost?
  6. NiteWave

    NiteWave Administrator

    since the disk cache actually in memory(in our setting), so it's safe to check it regularly, to prevent it fill up the memory. eAccelerator don't clean up the on-disk cache, so you have to take care of it.
  7. strebel

    strebel Member

    So this is the best scenario then?

    Enable 1M eAccell system wide, which will essentially force a write to disk as 1M fills up fast.

    And periodically clean out the disk cache. how often?
    We have over 800 domains on this box.
  8. NiteWave

    NiteWave Administrator

    you've to watch and decide how often you should clean up the cache.

    du -sh /dev/shm/ea

    show how many space used.
  9. strebel

    strebel Member

    Simple cron to rm -rf /dev/shm/ea/* every couple hours?
  10. NiteWave

    NiteWave Administrator

    should be ok.

    or only delete files created some time ago(1 day, 8 hours or 2 hours etc)
  11. strebel

    strebel Member

    This is no good on a large server with hundreds of vhosts.

    /dev/shm/ea fills up in about a minute. Interrupts, Fork Rate, Load, and Disk I/O all go up and the node becomes unstable. 8cores and 11gb of ram on this machine.

    Any other ideas on how to run a opcode with suExec affectively?
  12. NiteWave

    NiteWave Administrator

    then set cache_dir to /tmp/ea
    you can clean up /tmp/ea daily
  13. strebel

    strebel Member

    Disk iowait is the problem.

    Wait time shoots up as it is trying to read/write from the SAN.. not fast enough.
  14. NiteWave

    NiteWave Administrator

    yeah, network disk not recommended. We experienced very slow disk access when /tmp is NFS in a few customer's servers.
    using local disk, maybe a dedicated partition to store /tmp or for cache_dir only.

Share This Page