High APC Fragmentation

Discussion in 'PHP' started by semprot, Apr 18, 2012.

  1. semprot

    semprot Member

    Hi,

    I use 2-cpu license litespeed.
    I use apc and i have uploaded apc.php.
    my apc.ttl is 0.
    But apc.php shows very high fragmentation every time i refresh apc.php (my site is busy site), it can reach up to 50%.
    what should i do?

    Code:
    apc.cache_by_default	1
    apc.canonicalize	1
    apc.coredump_unmap	0
    apc.enable_cli	1
    apc.enabled	1
    apc.file_md5	0
    apc.file_update_protection	2
    apc.filters	
    apc.gc_ttl	3600
    apc.include_once_override	0
    apc.lazy_classes	0
    apc.lazy_functions	0
    apc.max_file_size	20M
    apc.mmap_file_mask	
    apc.num_files_hint	1000
    apc.preload_path	
    apc.report_autofilter	0
    apc.rfc1867	0
    apc.rfc1867_freq	0
    apc.rfc1867_name	APC_UPLOAD_PROGRESS
    apc.rfc1867_prefix	upload_
    apc.rfc1867_ttl	3600
    apc.serializer	default
    apc.shm_segments	1
    apc.shm_size	256M
    apc.slam_defense	1
    apc.stat	1
    apc.stat_ctime	0
    apc.ttl	0
    apc.use_request_time	1
    apc.user_entries_hint	4096
    apc.user_ttl	7200
    apc.write_lock	1
    

    Attached Files:

    • apc.jpg
      apc.jpg
      File size:
      53.9 KB
      Views:
      7
  2. webizen

    webizen New Member

    try increase apc.shm_size (=> 512M)

    also apc.stat=0
    Last edited: Apr 19, 2012
  3. semprot

    semprot Member

    thanks, apc.stat is 0 now, but once i changed apc.shm_size to 512m, i started getting 503 error on all domains on my server.

    Eventhough i have enough free ram (i think)
    Code:
    root@mybox [/home/xxxxx]# free -m
    total used free shared buffers cached
    Mem: 12001 7501 4500 0 1229 3169
    -/+ buffers/cache: 3102 8899
    Swap: 2047 0 2047
    
    Once i reverted it back to 256m, the 503 error gone. Do you think i need to upgrade my RAM although i have "enough" (IMO) ram?
    Last edited: Apr 19, 2012
  4. webizen

    webizen New Member

    increase memory limit (soft/hard) in lsphp5 external app by 256M
  5. semprot

    semprot Member

    Thanks.. It works.. At least i will try to increase memory limit once i get 503 / high fragmentation again.. :D
    Last edited: Apr 23, 2012
  6. semprot

    semprot Member

    After the litespeed was rebuilt recently, i started getting random 503 errors (not always as old situation) -- even with less traffic.
    even though memory soft & hard limit have been set to 1024mb.

    APC settings are still the same, at least :
    - shm_size is 512mb
    - ttl is 0
    - stat is 0

    Probably some other old litespeed settings were gone?
    Is there any other settings other than memory soft & hard limit that i should check?
    Last edited: Apr 26, 2012
  7. webizen

    webizen New Member

    Pls chk error log & stderr.log for any context
  8. NiteWave

    NiteWave Administrator

    try
    apc.mmap_file_mask=/tmp/APC.XXXXXX
  9. eva2000

    eva2000 Member

    why set ttl = 0 your memory usage will keep increasing, usually for APC i have something like

    Code:
    apc.ttl=7200
    apc.user_ttl=3600
    apc.gc_ttl = 600
    never had any problems with Litespeed and LSPHP + APC

    Of course make sure you aren't using LSPHP with phpSuExec for opcode cache use. I have a mysqlmymonlite.sh script to check for that http://mysqlmymon.com/#litespeedstats

    Code:
    phpSuExec = 0
    Code:
    ------------------------------------------------
    Litespeed Server & LSAPI PHP Info:
    ------------------------------------------------
    Litespeed web server version: 4.1.12
    WHM / Cpanel version: 11.32.2.25
    
    LSPHP phpSuExec status: 
      < phpSuExec >0
      < phpSuExecMaxConn >20
    
    WHM's PHP Handler config:
    /usr/local/cpanel/bin/rebuild_phpconf --current
    
    Available handlers: dso cgi none
    DEFAULT PHP: 5
    PHP4 SAPI: none
    PHP5 SAPI: dso
    SUEXEC: enabled
    RUID2: not installed
    
    PHP 5.3.10 (litespeed) (built: Feb  7 2012 03:02:29)
    Copyright (c) 1997-2004 The PHP Group
    Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
  10. semprot

    semprot Member

    Actually before i set ttl to 0, my fragmentation is very very high. And i read solution to set ttl to 0. And it is fine.
    However after everything is fine, i rebuild the php & litespeed for some reason.
    Now everything is screwed, apc wont work properly.

    I asked on stackoverflow but still no solution.

    http://stackoverflow.com/questions/10352458/apc-apc-fetch-returns-false-often-but-sometimes-success
  11. NiteWave

    NiteWave Administrator

    I read the post on stackoverflow, some valuable info there.
    -- Compiling the APC module with --disable-apc-mmap (Disable mmap support and use IPC shm instead) should fix the issue.
    -- i use SuPHP, not FastCGI
    -- my hosting said he is unable to enable fastcgi on litespeed. what if i still use suphp?

    when you use SuPHP under apache, and converting apache to litespeed, php will run in suExec mode. in this mode, only eAccelerator works well, APC or XCache won't work well. and in memory variable won't be shared at all between lsphp processes. in php suExec mode, lsphp process start/stop frequently. once a process stops, all in memory variables associated with the process will vanish as well. so use memcache or even disk file is the right way to keep variable value between lsphp process.
  12. semprot

    semprot Member

    Thank you your explanation helps me a lot. At this moment i need opcode cache, so i think i will use eaccelerator.

Share This Page