XenForo + caching = AMAZING

Coop1979

Well-known member
Tomorrow will mark my 2 week anniversary of migrating our 1.5 million posts from vBulletin to XenForo, and I wanted to start sharing a little bit of data from our experience so far.

One thing I was looking forward to was increased performance, and XF definitely delivered. With APC and Memcache installed on vBulletin, we were seeing maybe 50-60% hits in Memcache. Now the numbers for both APC and Memcache are 100%.

Screen shot 2012-06-11 at 4.24.27 PM.webpScreen shot 2012-06-11 at 4.24.09 PM.webp

With over 900 people on the site right now, our database server is barely flinching, with load averages hovering around 0.08. That is down from between 3.00-7.00 or higher on vBulletin.

The efficiency with which XF operates is nothing short of amazing.

While overall page views are down due to XF cutting out a lot of un-necessary pages that vB would direct users to, Unique Visitors is up over 25% since our switch-over.
 
Yes, memcache + APC = awesomeness. Oh and it looks like you can drop the memory setting on your APC server. After 2 weeks it doesn't appear to be going over 190MB. I believe you have it set for 512MB ever thought about lower it to 256MB?
 
How did you display memcached information in a graph like that?

Thanks.
Inside the memcache package you'll find a memcache.php file.

You need to set the configuration inside of the file
PHP:
define('ADMIN_USERNAME','memcache');// Admin Username
define('ADMIN_PASSWORD','password');  // Admin Password
define('DATE_FORMAT','Y/m/d H:i:s');
define('GRAPH_SIZE',200);
define('MAX_ITEM_DUMP',50);
 
$MEMCACHE_SERVERS[] = 'mymemcache-server1:11211'; // add more as an array
$MEMCACHE_SERVERS[] = 'mymemcache-server2:11211'; // add more as an array
upload it to you webroot and call it in the browser

Another nice implemetion is http://code.google.com/p/phpmemcacheadmin/
 
Thanks ragtek, it's so much like apc.php. memcache.php shows 0.1% misses here, quite good.
 
I'm just setting up my first Xenforo server on a VPS. Thanks to a suggestion from p4guru I used Centmin Mod to install nginx/php-fpm/mariadb(mysql). This automatically installs Memcache and Xcache rather than APC.

Having read this thread I'm wondering if I should rip out Xcache and install APC. I'd be interested to hear words of encouragement or discouragement.

It seems to me that I might as well get the whole thing tuned up as best I can at this stage.
 
I'm just setting up my first Xenforo server on a VPS. Thanks to a suggestion from p4guru I used Centmin Mod to install nginx/php-fpm/mariadb(mysql). This automatically installs Memcache and Xcache rather than APC.

Having read this thread I'm wondering if I should rip out Xcache and install APC. I'd be interested to hear words of encouragement or discouragement.

It seems to me that I might as well get the whole thing tuned up as best I can at this stage.
from centmin mod you can install apc instead of xcache via menu options - it's option #9 on the menu when you re-run centmin.sh. Before installing APC, edit /usr/local/lib/php.ini manually or via centmin mod shortcut and remove the xcache.so and xcache related lines and save php.ini and restart php-fpm. Then run option #9 from centmin.sh run to automatically install APC cache, you can then edit php.ini to adjust memory allocation to APC
 
@p4guru Thanks for the tip, that went super easy. The only slight snag was the script suggested by centmin:

Code:
python /usr/local/nginx/conf/htpasswd.py -b /usr/local/nginx/conf/htpasswd yourusername yourpassword

Kept returning unsupported hash type errors however it appears to have worked anyway. ie there's an encrypted password and my username stored in the htpasswd file and these work when I visit 9919_myapc.php to look at my cache usage data and pie charts.

I now feel like I've got the best possible server set-up for a small VPS. Centmin makes doing this very easy. Thanks again.
 
Just a side note for those who read this thread, but may not have enough ram or are using shared hosting

File Cache
config.php --- Remember to change the PATH (full server path)

PHP:
$config['cache']['enabled'] = true;
$config['cache']['cacheSessions'] = true;
$config['cache']['backend'] = 'File';
$config['cache']['backendOptions'] ['cache_dir'] = '/path/to/cache';
$config['cache']['frontend'] = 'Core';
$config['cache']['frontendOptions'] ['cache_id_prefix'] = 'xf_';

You'll also may want or need to change the prefix if you have more than 1 forum (test forum for example).

When moving your site to either a different directory or server or domain name... You'll want to delete your cache folder and make a new one (system will automatically generate new cache). Before or without doing this, things will not work.
 
I'm just setting up my first Xenforo server on a VPS. Thanks to a suggestion from p4guru I used Centmin Mod to install nginx/php-fpm/mariadb(mysql). This automatically installs Memcache and Xcache rather than APC.

Having read this thread I'm wondering if I should rip out Xcache and install APC. I'd be interested to hear words of encouragement or discouragement.

It seems to me that I might as well get the whole thing tuned up as best I can at this stage.

nginx, php-fpm, APC - I've watched htop and we are using just on 2GB out of 8GB for 1200 members + 8000 guests online viewing 40,000 image attachments and our videos.
The above was peak load for me so far, when some new video hit the scene. Anyway, it's all good. APC kicks ass.

ggs.webp
 
Can someone clarify for me, please, regarding using XenForo with both memcache and APC?

How do you define both in the config file?

PHP:
$config['cache']['backend'] = 'Apc';
$config['cache']['backend'] = 'Memcached';
$config['cache']['backendOptions'] = array(
'compression' => false,
'servers' => array(
array(
// your memcached server IP /address
'host' => 'localhost',
 
// memcached port
'port' => 11211,
)
)
);
 
I am using this:
PHP:
$config['cache']['enabled'] = true;
$config['cache']['frontend'] = 'Core';
$config['cache']['frontendOptions'] = array(
    'caching'                  => true,
    'automatic_serialization'  => true,
    'lifetime'                  => 1800,
    'cache_id_prefix'          => 'xf2_'
);
#Memcached
$config['cache']['backend']='Memcached';
$config['cache']['backendOptions']=array(
      'compression'=>false,
      'servers' => array(
              array(
                  'host'=>'localhost',
                  'port'=>11211,
              )
        )
);
$config['cache']['cacheSessions'] = true;
 
Yeah we've got that - but I'm hearing that there's benefits to having both APC and Memcached installed - which we have. What's the correct configuration for that?
 
I think Xenforo will use APC opcode as long as we have it installed (no need to put it in the config file)?
Correct. I've set up APC over the weekend, and it's caching all PHP pages on my server (including Opencart, phpBB3, Wordpress and Xenforo).
 
Top Bottom