Trying to use APC but it seems to be clearing out?

Discussion in 'PHP' started by NUTNDUN, Jun 17, 2011.


    NUTNDUN Member

    I am very new to Litespeed but I must say I have been hugely impressed by it's performance. We went from a dedicated server with server loads around 1 to a vps hybrid and using Litespeed and server loads barely go over .30.

    I am trying to use some sort of cache and have found a lot of conflicting information in what can or can't be used.

    I would like to use APC or xcache. I have them both installed and they both work to an extent. Both seem to reset after so many seconds or minutes almost like the web server is restarted.

    I am only trying one at a time, as I know you can't have two opcode caches running at the same time. I also have php suexec enabled for users home directory in the configuration for litespeed.

    It is a CentOS server using Cpanel. Any help would be appreciated.
  2. webizen

    webizen Well-Known Member

    For either opcode cache to work, php suEXEC needs to be disabled (Admin Console -> Configuration -> Server -> General -> Load Apache Configuration File -> PHP suEXEC => No)

    NUTNDUN Member

    I did turn the suEXEC option off last night and was using xcache and it still seemed like it was resetting every 30 seconds to a minute. When I first set it like that last night it seemed like it was working good and had over 35,000 hits showing and then it reset and after that it seemed to reset about every minute.
  4. webizen

    webizen Well-Known Member

    With PHP suEXEC off, PHP runs as Webserver user (dedicated hosting) instead of individual account user. Opcode cache would _not_ work in the shared hosting environment. It resets frequently in shared environment as you described.

    Please turn suEXEC off and see issue re-appears.

    NUTNDUN Member

    Ok, I turned suEXEC off and turned xcache back on.

    About every 10 minutes or so it is like it is resetting. All of the hits that are showing on the xcache admin along with memory usage get cleared out and starts over again.

    Here are my settings displayed in xcache admin:
    Version 1.3.2
    Modules Built cacher
    Readonly Protection N/A
    Cache Init Time 2011-06-17 14:15:29
    Cache Instance Id 28592
    Opcode Cache enabled, 134,217,728 bytes, 1 split(s), with 8192 slots each
    Variable Cache enabled, 33,554,432 bytes, 1 split(s), with 8192 slots each
    Shared Memory Schemes mmap

    Directive Local Value Master Value
    xcache.admin.enable_auth On On
    xcache.cacher On On
    xcache.coredump_directory no value no value
    xcache.count 1 1
    xcache.gc_interval 300 300
    xcache.mmap_path /dev/zero /dev/zero
    xcache.readonly_protection 1 1
    xcache.shm_scheme mmap mmap
    xcache.size 128M 128M
    xcache.slots 8K 8K
    xcache.stat On On
    xcache.test no value no value
    xcache.ttl 3600 3600
    xcache.var_count 1 1
    xcache.var_gc_interval 300 300
    xcache.var_maxttl 7200 7200
    xcache.var_size 32M 32M
    xcache.var_slots 8K 8K
    xcache.var_ttl 3600 3600

    NUTNDUN Member

    I just upped the size of the shared memory to 64MB and set the xcache.size to 48MB to see if that makes any difference. The kernel was set to 32MB originally. I am only guessing that it was clearing it out because of filling the shared memory?

    NUTNDUN Member

    The new memory settings at first seemed like it was working but it still ends up resetting itself. I don't know it if it litespeed that is restarting or what might be causing it. I don't know enough to figure out what to look for that would be causing it.

    NUTNDUN Member

    I wanted to try APC also and it is doing the same thing. Resetting way before the ttl setting would kick in.
  9. NiteWave

    NiteWave Administrator

    what's the APC settings in php.ini ?

    NUTNDUN Member

    Here are my settings for APC:

    and here are my settings I have for xcache:
    zend_extension = /usr/local/lib/php/extensions/no-debug-non-zts-20060613/
    auto_globals_jit = Off

    xcache.admin.user = "adm"
    xcache.admin.pass = "pw"

    xcache.shm_scheme = "mmap"
    xcache.size = 96M
    xcache.count = 1
    xcache.slots = 4K
    xcache.ttl = 3600
    xcache.gc_interval = 300
    xcache.readonly_protection = Off
    xcache.mmap_path = "/dev/zero"
    xcache.cacher = On

    ;var settings
    xcache.var_size = 4M
    xcache.var_count = 1
    xcache.var_slots = 4K

    ;var ttl settings
    xcache.var_ttl = 3600
    xcache.var_maxttl = 7200
    xcache.var_gc_interval = 300

    It doesn't matter which one I use, they both clear out after a while and well before the ttl setting is reached. I think it has something to do with the number of processes in some way from what I read on the xcache website in the faq section.
  11. NiteWave

    NiteWave Administrator

    maybe you refer:

    then how many litespeed processes are running on your server?
    #pstree -p | grep litespeed

    what you observed is just the reason why on shared hosting environment, only eAccelerator is recommended. all php processes can share the opcode cache under a single disk folder, like /tmp/eaccelerator. usually, php suExec is enabled in such environment. APC and XCache only keep opcode cache in memory. so each group of php processes will have its own cache.

    NUTNDUN Member

    Here is the output of the command you posted:

    pstree -p | grep litespeed
    | `-litespeed(20210)-+-lsphp5(1343)---sh(5522)---convert(5523)

    php suEXEC has been disabled since it was mentioned two days ago.
  13. NiteWave

    NiteWave Administrator

    ok, this suggest me might that reason ....
    please post the lsphp5's setting:
    Server -> External App -> lsphp5: View

    NUTNDUN Member

    Here are the settings:

    Name lsphp5

    Address uds://tmp/lshttpd/lsphp5.sock

    Notes Not Set

    Max Connections 35


    Initial Request Timeout (secs) 60

    Retry Timeout (secs) 0

    Persistent Connection Yes

    Connection Keepalive Timeout Not Set

    Response Buffering No

    Auto Start Yes

    Command $SERVER_ROOT/fcgi-bin/lsphp5

    Back Log 100

    Instances 1

    suEXEC User Not Set

    suEXEC Group Not Set

    Run On Start Up Not Set

    Max Idle Time 10

    Priority 0

    Memory Soft Limit (bytes) 450M

    Memory Hard Limit (bytes) 500M

    Process Soft Limit 200

    Process Hard Limit 200
  15. NiteWave

    NiteWave Administrator

    change "Max Idle Time" 10 to -1

    NUTNDUN Member

    Ok, will try it and let you know how it goes.

    NUTNDUN Member

    I thought for sure it was good to go because that was the longest it lasted without being reset. It got up to about 69,000 hits and then it cleared out again.
  18. NiteWave

    NiteWave Administrator

    APC or xcache is associated with a lsphp5 process(or a group of processes:a parent process, a few child processes). in example of above case, it's lsphp5 which pid=1343. if in some reason, this process is killed and a new lsphp5 process is started by its parent litespeed(in above example, pid=20210), then you'll notice opcode cache is cleared.

    so monitor lsphp5's pid at the same time while monitoring the cache hits number. if the pid changes, the issue is turned to be how to keep it longer and what's reason it's killed and restarted again.
  19. cmanns

    cmanns Well-Known Member

    We've used Xcache for over 4 years with fastcgi. Over a year now with lsws

    Set max requests to like 2k or so, set a few more instances. Set xcache to /dev/shm with 64mb mem

    We get great performance in an env with dosenz of suexec php users. We get about 2-3 tops per vhost so they cache hit good. Also set childs lower and parents 2-4.

    APC and EA suck. I've tried them on and off over the years, xcache gives us lowest php exec and low cpu usage.

    NUTNDUN Member

    I agree xcache is much faster. I have been running eaccelerator for a little bit and it seemed to do the same reset but not as often. I just switched it back to xcache and the page loading is almost twice as fast.

    If it only resets once an hour I can live with that. I will tweak the settings some more over the next couple of days and maybe even try some of the settings that you mentioned.

    I did change these settings:


    and I still have keep alive set to -1.

Share This Page