knackforge
May 2, 2014
Alternative PHP Cache (APC) is one of the best PHP accelerators around for a while.
Wikipedia ideally describes the same as below,
Alternative PHP Cache is a free, open source (PHP license) framework that caches the output of the PHP bytecode compiler in shared memory, thus reducing parsing and disk I/O overhead for later requests; and a shared memory cache for user data. For an application consisting of a large source code base such as Drupal, a 3x increase in page generation speed is possible as a result.
As mentioned the compiled bytecode is loaded into the RAM to speed up the execution of consecutive requests.
Almost for every Drupal site, we use APC to keep the response time within the ideal range. But knowing how much RAM to block for APC helps to leverage the best framework and possibly prevents underutilizing the expensive resource (RAM).
While working on my recent projects, I came across a script, apc.php
which helps to find the answer to this question. Since it is being shipped with an official framework package, it is trustworthy and needs no configuration to get started.
We prefer Ubuntu LTS for our Drupal servers. In our case, apc.php
was found at /usr/share/doc/php-apc/apc.php.gz
.
Utility commands like locate
(# locate apc.php
) could help to return its absolute path, in case it's different in your distribution.
On decompressing the .gz with gunzip
or similar the actual script can be recovered. Move the same to the document at the root of your Web server. Now with your domain name, say http://example.php/apc.php you can see the stats and arrive at the ideal memory needed for your site.
Another essential stuff to note is Hits & Misses.
In our case, it is 98.9%, close to ideal. Based on this value, we might consider revising the configuration as needed.
Just like how your fellow techies do.
We'd love to talk about how we can work together
Take control of your AWS cloud costs that enables you to grow!