---
title: "Magento APC optimisation"
date: "2010-04-10"
modified: "2013-03-04"
path: "/51-magento-apc-optimisation.html"
section: "/ramblings"
aliases:
  - "/51"
  - "/51-magento-apc-optimisation"
  - "/51.html"
  - "/ramblings/51-magento-apc-optimisation.html"
---

Extremely useful Magento optimisation links:

APC Cache - having used this on many server configuration together with the Zend Framework, I can see that implementing this Magento should have big advantages. <http://www.magentocommerce.com/boards/viewthread/8937/>

In the app/etc/config.xml you need after the &lt;global> section:

```
        <cache>
                <backend>apc</backend>
                <prefix>sitename_</prefix>
        </cache>
```

---

<div class="box-warning">
On Debian don't use the object-based "user cache" as suggested here. Simply enable the "file cache" using the values below. You will need to experiment with the size of the segment as Magento can use a lot of the shared memory in only a few minutes. Memcache seems much more stable for object caching.
</div>

## APC Configuration

Edit the file `/etc/php5/conf.d/apc.ini`

```
extension=apc.so

apc.enabled=1
apc.shm_segments=1
apc.shm_size=256
apc.num_files_hint=10000
apc.user_entries_hint=10000
apc.max_file_size=5M

apc.ttl=0
apc.user_ttl=0
apc.gc_ttl=60
apc.stat=1
apc.optimization = 0
apc.cache_by_default=1
apc.enable_cli=1
apc.slam_defense=0
apc.write_lock=1
```

You will need to restart Apache for this to take effect using `apache2ctl graceful`. Once operational you can use the apc.php available in the modules src folder to examine what's happening; you should see something like:

![](/images/apc-screenshot.png)

## Other optimisation around APC

MySQL Specific - in particular, looking at innodb pool size, I've seen dramatic improvements:\
<http://www.magentocommerce.com/boards/viewthread/4168/>

Apache - simply increasing available Apache process solves most issues; assuming there is available memory.
