Forum Caching system

TransAmDan

Forum Admin
Staff member
In my quest to make the forum pages lad faster I have been installing things behind the scenes.
There are a fee which VBulletin will use as a caching system. There is eAccelerator, XCache, APC and Memcache. Reading a few threads on what others have used it was down to APC and XCache. Reading little more I came to the conclusion APC was a good start to try.

Linux is in a few different flavors so I need to find the install instructions for the CentOS that we are using. CentOS does seems fairly easy to install things.

APC (Alternate PHP Cache) is an free and open source cache for PHP code. The main goal of this module is to provide robust framework for caching and optimizing PHP code.
First, we need to install required packages called pecl, phpize and apxs commands, to installAPC using YUM package manager tool.


Install Dependency Packages for APC
First, we need to install required packages called pecl, phpize and apxs commands, to installAPC using YUM package manager tool.

yum install php-pear php-devel httpd-devel pcre-devel gcc make


Install APC Using PECL

Now we have all the needed packages to install APC. Here we use PECL command to install it. Please select default settings when asked.

pecl install apc


Run the following command to enable APC extension in Apache configuration.

echo "extension=apc.so" > /etc/php.d/apc.ini



Restart Apache Service for APC
Restart the Apache service to take new changes.

/etc/init.d/httpd restart


Verify APC Installation

Create a file phpinfo.php in Apache web root directory. For example/var/www/html/phpinfo.php.

vi /var/www/html/phpinfo.php

Add the following code to it. save and close.
<?php
// Show all information, defaults to INFO_ALL
phpinfo();?>

Open any browser and type the following URL. You will see APC enabled configuration similar to below.
http://localhost/phpinfo.php


Enable PHP APC administration

To enable APC administration panel, copy the following file.

cp /usr/share/pear/apc.php /var/www/html/

Now open the file
apc.php with VI editor.

vi /var/www/html/apc.php

Now set the username and password in the file apc.php as shown below.
defaults('ADMIN_USERNAME','apc');
// Admin Usernamedefaults('ADMIN_PASSWORD','Set-Password-Here');
// Admin Password - CHANGE THIS TO ENABLE!!!Type the following URL in the browser. You will get administration panel of APC.
http://localhost/apc.php


Screenshot of the APC.PHP output
....
 
Last edited:
I noticed that the uptime of the caching is always zero, Is it being reset somewhere...
Well after a couple of weeks looking into this reading forums. I eventually tried the alternative XCache.
I wont go though all the install instructions, but it was fairly painless. I fiddles with this for about 4 hours. As it always was resetting, and not caching the files for more than about 30seconds. Then asked technical support of the VPS hosting, they didn't have an idea of what was causing it either, but they do have XCache installed on other peoples websites wunning on a simular server.

So eventually I uninstalled Xcache, and out APC back on, as although the both dont work, the APC one feels a little better in the control, and the visual aspect of the stats. Also it was my first choice from all the oddles of forum reading.

I've insteased the TTL variables to 7200 seconds, so basically items should stay in the cache for 2 hours, and then if space is needed in the cache some of these items will be removed to make room for the new. However even when I set my cache to 256Mb, I dont see much more than 30 - 40Mb being used before its gone again. And that UPtime never moves from zero.

So more reading and researching to be done, spent over 10 hours just on this yesterday, that 10 hours was pretty much all at once too.
 
I came across this thread, among many others. Threads just send you off in a tangent, but you may learn something from then. APC with FastCGI - uptime 0, other people do have similar problems, but sometimes they are using a different operating system so the solution isn't the same for me.

Following many threads, many saying the same things, is that Plesk using mod_fcgi instead of mod_fastcgi.

This thread looks interesting, http://forum.parallels.com/showthre...ith-php5-fpm-not-php5-cgi&p=637585#post637585
However I could so all this and its still not the solution. Its the thought of it may work that keeps me going, going down all these routes some dead end, some lead to new paths. I will give it ago later on.
 
Last edited:
Been working on this for many hours today. Trying out various options, disabling php5 in Plesk, along with deflate, and a few other things that were suggested.

I made a little change to /etc/httpd/conf.d/fcgid.conf editing the variable FcgidProcessLifeTime
This was set to 30 seconds, increased this to 120.

Tried the APC stats page, and it stayed up for 2 mins. This was great, and previously it would only last under a minute.

So i have read up on this variable and changed it to Zero. FcgidProcessLifeTime = 0
This will mean it never times out. So this is the test, its been going for 10 mins now, caching looks great, i can feel a speed increase on the forum, so I've submitted it for a load test, to see if its faster than last week.
However if it never times out, if something goes wrong it may sit in memory wasting it when another process starts, so I will keep an eye on this one.
 
The APc seems to be multi-treading of some kind. If i view the APC stats, there is around 4 different stat results, looking at the processes in memory its running in a 'php-cgi' process. However the caching is working. I will keep an eye on this with the memory limits etc..
 
Back
Top