Revision #10 has been created by Da:Sourcerer on Dec 10, 2013, 5:05:51 AM with the memo:
Corrected filemask for shared memory configuration
« previous (#9)
Changes
Title
unchanged
Getting the Most out of APC for Yii
Category
unchanged
How-tos
Yii version
unchanged
Tags
unchanged
caching, apc
Content
changed
[...]
- [`apc.cache_by_default`](http://php.net/manual/apc.configuration.php#ini.apc.cache-by-default) Controls the default caching behaviour of APC. This can be used together with `apc.filters` for complex cache setups. But in most cases, you'll want this to be **1**.
- [`apc.ttl`](http://php.net/manual/apc.configuration.php#ini.apc.ttl) Controls how long cached opcodes may be cached before being reloaded. Set this to **0** on your productions system so this will never happen. This is most useful together with `apc.stat=0`.
- [`apc.num_files_hint`](http://php.net/manual/apc.configuration.php#ini.apc.num-files-hint) This is a hint for APC to reserve sufficient space for the opcode cache. It helps APC during the initial cache build. It isn't terribly important as it's really just a hint. But while you're at it: Set it to roughly the number of your project's PHP files.
- [`apc.user_entries_hint`](http://php.net/manual/apc.configuration.php#ini.apc.user-entries-hint) Same as `apc.num_files_hint` but for user cache entries, so it is only interesting if you're using APC as a user cache, too. A too high value might result in over-provisioning memory for the cache. This is highly individual, so you'll need to evaluate this yourself.
- [`apc.mmap_file_mask`](http://php.net/manual/apc.configuration.php#ini.apc.mmap-file-mask)
Filemask for the shared memory mechanism. There are three kinds of values this setting can take. Something like `/tmp/apc.XXXXXX` (place exactly 6 `X`'s) will create an mmap'ed file in your `/tmp` directory. `/dev/zero` does the same but without creating a file. The best setting I could find has been **/dev/shm/apcapc.shm.XXXXXX**. For this to work properly, `/dev/shm` must be mounted on a tempfs. The benefit of using shared memory for APC lies in the lockless nature. The downside, however, is that this method for storing APC's content is everything but thread-safe. This is mostly important if you are running PHP in an Apache environment via mod_php with an MPM other than [prefork](http://httpd.apache.org/docs/2.2/mod/prefork.html), as you will experience constant segfaults.
- [`apc.lazy_classes`](http://php.net/manual/apc.configuration.php#ini.apc.lazy-classes) and [`apc.lazy_functions`](http://php.net/manual/apc.configuration.php#ini.apc.lazy-functions) These settings are marked as _experimental_. However, I've found no regressions after using these. If you're feeling lucky and you're using anonymous functions for [`evaluateExpression()`](http://www.yiiframework.com/doc/api/1.1/CComponent/#evaluateExpression-detail), you may want to set these to **1**.
- [`apc.include_once_override`](http://php.net/manual/apc.configuration.php#ini.apc.include-once-override) Setting this to on will speed up `include*` and `require*` calls. However, this setting will introduce changes in the behaviour of PHP. While Yii is content with this being switched on, other applications (such as phpMyAdmin) are not. So watch out for breaking applications.
- [`apc.serializer`](http://php.net/manual/apc.configuration.php#ini.apc.serializer) Starting with version 3.1.7, APC can facilitate a substitute for PHP's native [`serialize()`](http://php.net/serialize) function. This is most interesting in conjunction with the [igbinary serializer](http://pecl.php.net/package/igbinary), which aims to provide a more compact serialization. This _might_ result into smaller cache sizes for you (among with a small speed benefit). But again: Your milage may vary, so evaluate carfully. It should be noted that the two serialization formats are incompatible. So when changing the serializer, clearing caches is advisable.
- [`apc.optimizer`](http://php.net/manual/apc.configuration.php#ini.apc.optimizer) This setting receives mentioning every now and then. But truth be told: It doesn't do anything since [APC v3.0.13](http://pecl.php.net/package-changelog.php?package=APC&release=3.0.13). The APC optimizer got forked into a [separate project](http://pecl.php.net/package/optimizer) which never really took off.[...]