APC (Alternative PHP Cache) is open source opcode caching mechanism.
I will not talk about which one is better, XCache or APC, i found out that some of them work little bit different in different environments and with different scripts. And this is probably why you did not came here to read about. We will see how to speed up some work.
Personally, i don’t like APC much but my clients do, so i needed to find out some new ways of optimizing caching to work on high load servers which also include memcached and other boys and girls.
As observed from most servers configuring APC with low memory can be a drag on performance causing high executing times. If you install APC without tuning it there can be a lot of fragmentation and this is very bad with cache hit ration no more than 20%.
Let say we have WordPress installed on server with APC and we have 20-30 plugins enabled with 2-3 themes, then 30MB of APC is not enough. After increasing apc.shm_size size to 128 we had 99% cache hit ratio and from 200 request rate per seconds we came to 300 requests per second which is good.
After configuring APC to do job like it should we significantly improved memory usage because there was no need for nginx to run raw PHP, we had everything in op code already.
If you have more than 8GB ram then depending on what you host on server you can add to apc.shm_size at least 1GB ram.
APC config preview :
apc.enabled = 1 apc.shm_segments = 1 apc.shm_size = 128M apc.optimization = 0 apc.num_files_hint = 512 apc.user_entries_hint = 1024 apc.ttl = 0 apc.user_ttl = 0 apc.gc_ttl = 600 apc.cache_by_default = 0 apc.slam_defense = 0 apc.use_request_time = 1 apc.mmap_file_mask = /tmp/apc-accountname.XXXXXX ;OR apc.mmap_file_mask = /dev/zero apc.file_update_protection = 2 apc.enable_cli = 0 apc.max_file_size = 8M apc.stat = 1 apc.write_lock = 1 apc.report_autofilter = 0 apc.include_once_override = 0 apc.rfc1867 = 0 apc.rfc1867_prefix = "upload_" apc.rfc1867_name = "APC_UPLOAD_PROGRESS" apc.rfc1867_freq = 0 apc.localcache = 1 apc.localcache.size = 512 apc.coredump_unmap = 0 apc.stat_ctime = 0