XF 1.1 memcache, APC and setup on beta 3

wrx1

Active member
I am currently running 2 linode 512 vps servers. 1 for the web side and the other for the DB server. My current config file looks like this.

Code:
<?php

$config['db']['host'] = 'path/to/DB/server';
$config['db']['port'] = '3306';
$config['db']['username'] = 'xxxxxxxx';
$config['db']['password'] = 'xxxxxxxxxxx';
$config['db']['dbname'] = 'xenforo';

$config['superAdmins'] = '1';

##memcache on DB server
$config['cache']['enabled'] = true;
$config['cache']['frontend'] = 'Core';
$config['cache']['frontendOptions'] = array('caching'  =>  true,
                                            'automatic_serialization' => true,
                                            'lifetime'    => 5400
);
$config['cache']['backend'] = 'Memcached';
$config['cache']['backendOptions'] = array(
    'backendOptions'=>array(
            'servers' =>array(
                            array(
                                'host' => 'path/to/DB/server', // your memcached server ip /address
                                'port' => 11211        // memcached port
                            )
                        ),
            'compression' => false
    )
);

##APC on webserver
$config['cache']['enabled'] = true;
$config['cache']['frontend'] = 'Core';
$config['cache']['frontendOptions'] = array(
                                        'caching'                      => true,
                                        'automatic_serialization'      => true,
                                        'lifetime'                      => 5400,
                                        'cache_id_prefix' => 'foro'
);
$config['cache']['backend'] = 'Apc';

This worked while running 1.0.4, but now with the upgrade to 1.1b3, the memcache was throwing fatal errors. Unfortunately, I didn't copy down the errors.

So really, my main question is, does this all look right?? I am going to install memcache on my test site and re-enable memcache to see if I can re-create what was happening. It just seems a bit off that it worked in 1.0.4, but now with beta 3 it doesn't work. I currently have memcache off and apc running just fine on my live site, so it is definitely something with my memcache settings.

I should also state that APC is installed on the web server and memcached is installed on the DB server.

Thanks
Russ
 
Ok, a little more info.

Here are the errors when I hit any page.
Fatal error: Uncaught exception 'ErrorException' with message 'Undefined variable: showTrace' in /var/www/localhost/htdocs/library/XenForo/Error.php:76 Stack trace: #0 /var/www/localhost/htdocs/library/XenForo/Error.php(76): XenForo_Application::handlePhpError(8, 'Undefined varia...', '/var/www/localh...', 76, Array) #1 /var/www/localhost/htdocs/library/XenForo/Application.php(295): XenForo_Error::unexpectedException(Object(ErrorException)) #2 [internal function]: XenForo_Application::handleException(Object(ErrorException)) #3 {main} thrown in/var/www/localhost/htdocs/library/XenForo/Error.php on line 76

and in the admin CP

Error Info
ErrorException: MemcachePool::get() [<a href='memcachepool.get'>memcachepool.get</a>]: Server 127.0.0.1 (tcp 11211, udp 0) failed with: Connection timed out (110) - library/Zend/Cache/Backend/Memcached.php:180
Generated By: Unknown Account, 3 minutes ago

Stack Trace

#0 [internal function]: XenForo_Application::handlePhpError(8, 'MemcachePool::g...', '/var/www/localh...', 180, Array) #1 /var/www/localhost/htdocs/library/Zend/Cache/Backend/Memcached.php(180): MemcachePool->get('xf_data_options') #2 /var/www/localhost/htdocs/library/Zend/Cache/Core.php(303): Zend_Cache_Backend_Memcached->load('xf_data_options', false) #3 /var/www/localhost/htdocs/library/XenForo/Model/DataRegistry.php(87): Zend_Cache_Core->load('data_options') #4 /var/www/localhost/htdocs/library/XenForo/Dependencies/Abstract.php(134): XenForo_Model_DataRegistry->getMulti(Array) #5 /var/www/localhost/htdocs/library/XenForo/FrontController.php(125): XenForo_Dependencies_Abstract->preLoadData() #6 /var/www/localhost/htdocs/index.php(13): XenForo_FrontController->run() #7 {main}

Request State

array(3) { ["url"] => string(75) "http://www.mnsubaru.com/misc/style?style_id=0&redirect=/search/87397/" ["_GET"] => array(2) { ["style_id"] => string(1) "0" ["redirect"] => string(14) "/search/87397/" } ["_POST"] => array(0) { } }

Basically, all I did was comment out the apc portion and open up the memcached portion. Now I commented out memcached and opened apc and everything works fine.

So I guess at this point, I want to best utilize what I have. There are a couple of cache threads going, but no real answers to what/how to best utilize them. It looks like XF itself will use APC without having to alter anything in the config file (as a opcode cache).

So I guess my question is, with 2 servers (1 web side and 1 DB server), what is the best caching system to implement to speed everything up?

Thanks
Russ
 
I have a more detailed question, which is the best way to configure XF to work with eAccelerator? If you have a dedicated server (probably VPS too) with cPanel, you can use the EasyApache feature to set up eAccelerator, so it's a supported install, which is great if all your PHP scripts run faster.

Note: cPanel has added a very basic, mostly crippled XCache installation, but I presume this will be expanded in the future.
 
Ok, a little more info.

Here are the errors when I hit any page.
Fatal error: Uncaught exception 'ErrorException' with message 'Undefined variable: showTrace' in /var/www/localhost/htdocs/library/XenForo/Error.php:76 Stack trace: #0 /var/www/localhost/htdocs/library/XenForo/Error.php(76): XenForo_Application::handlePhpError(8, 'Undefined varia...', '/var/www/localh...', 76, Array) #1 /var/www/localhost/htdocs/library/XenForo/Application.php(295): XenForo_Error::unexpectedException(Object(ErrorException)) #2 [internal function]: XenForo_Application::handleException(Object(ErrorException)) #3 {main} thrown in/var/www/localhost/htdocs/library/XenForo/Error.php on line 76

and in the admin CP

Error Info
ErrorException: MemcachePool::get() [<a href='memcachepool.get'>memcachepool.get</a>]: Server 127.0.0.1 (tcp 11211, udp 0) failed with: Connection timed out (110) - library/Zend/Cache/Backend/Memcached.php:180
Generated By: Unknown Account, 3 minutes ago

Stack Trace

#0 [internal function]: XenForo_Application::handlePhpError(8, 'MemcachePool::g...', '/var/www/localh...', 180, Array) #1 /var/www/localhost/htdocs/library/Zend/Cache/Backend/Memcached.php(180): MemcachePool->get('xf_data_options') #2 /var/www/localhost/htdocs/library/Zend/Cache/Core.php(303): Zend_Cache_Backend_Memcached->load('xf_data_options', false) #3 /var/www/localhost/htdocs/library/XenForo/Model/DataRegistry.php(87): Zend_Cache_Core->load('data_options') #4 /var/www/localhost/htdocs/library/XenForo/Dependencies/Abstract.php(134): XenForo_Model_DataRegistry->getMulti(Array) #5 /var/www/localhost/htdocs/library/XenForo/FrontController.php(125): XenForo_Dependencies_Abstract->preLoadData() #6 /var/www/localhost/htdocs/index.php(13): XenForo_FrontController->run() #7 {main}

Request State

array(3) { ["url"] => string(75) "http://www.mnsubaru.com/misc/style?style_id=0&redirect=/search/87397/" ["_GET"] => array(2) { ["style_id"] => string(1) "0" ["redirect"] => string(14) "/search/87397/" } ["_POST"] => array(0) { } }

Basically, all I did was comment out the apc portion and open up the memcached portion. Now I commented out memcached and opened apc and everything works fine.

So I guess at this point, I want to best utilize what I have. There are a couple of cache threads going, but no real answers to what/how to best utilize them. It looks like XF itself will use APC without having to alter anything in the config file (as a opcode cache).

So I guess my question is, with 2 servers (1 web side and 1 DB server), what is the best caching system to implement to speed everything up?

Thanks
Russ

Either Memcached is not running on the DB server, or it is running but on a different port, or you have a firewall blocking traffic. PHP cannot reach the daemon.
 
We use XF1.1b3 and use Memcached, which works flawlessly for us. Here our config.php

Code:
$config['cache']['backend'] = 'Memcached';
$config['cache']['backendOptions'] = array(
    'backendOptions'=>array(
            'servers' =>array(
                            array(
                                'host' => '127.0.0.1', // your memcached server ip /address
                                'port' => '11211'    // memcached port
                            )
                        ),
            'compression' => false
    )
);

This line in your INI-file looks awkward:
Code:
'host' => 'path/to/DB/server', // your memcached server ip /address

hth
 
Either Memcached is not running on the DB server, or it is running but on a different port, or you have a firewall blocking traffic. PHP cannot reach the daemon.
Well, I know it is running but I will have to double check the port and the firewall.

We use XF1.1b3 and use Memcached, which works flawlessly for us. Here our config.php

Code:
$config['cache']['backend'] = 'Memcached';
$config['cache']['backendOptions'] = array(
    'backendOptions'=>array(
            'servers' =>array(
                            array(
                                'host' => '127.0.0.1', // your memcached server ip /address
                                'port' => '11211'    // memcached port
                            )
                        ),
            'compression' => false
    )
);

This line in your INI-file looks awkward:
Code:
'host' => 'path/to/DB/server', // your memcached server ip /address

hth
I just changed out the IP in that line so I didn't post the true IP address.

The one thing that I noticed is that the error is calling out memcached on localhost, when really it is running on my 2nd server. So someplace it skipped over my set IP address and is trying to connect to 127.0.0.1. So under the host line, do I have to have a IP address (xxx.xxx.xxx.xxx), or can I have a web address (internal.myserver.com)?? That might be my problem since I am calling a web address instead of the actual internal IP, so I will try and change that around and give it another shot.

Thanks for the help so far.
Russ
 
Ok, I have it figured out, and at the end of the day, it turns into a bug in the documentation.

This thread is correct.
http://xenforo.com/community/thread...emcached-do-not-look-right.21073/#post-268028

This is the wrong code.
Code:
$config['cache']['backendOptions'] = array(
  'backendOptions'=>array(
          'servers' =>array(
                          array(
                              'host' => 'path/to/db/server', // your memcached server ip /address
                              'port' => 11211        // memcached port
                          )
                      ),
            'compression' => false
    )
This calls out 'backendOptions' in 2 places.

Now this is what I am running.
Code:
$config['cache']['backendOptions'] = array(
          'servers' =>array(
                          array(
                              'host' => 'path/to/db/server', // your memcached server ip /address
                              'port' => 11211        // memcached port
                          )
                      ),
            'compression' => false
);

There is a NOTICABLE difference in speed.

After consulting with a programmer friend, we came to the conclusion that with APC in the confige file, it was overwriting the memcached cache. So the site didn't freak out. Now I can run with the APC commented out and utilize the XF use of APC for opcode, and use memcached for backend caching on the DB server.

So this is my current config file which is running just fine and I am getting data stored in both caches.
Code:
<?php

$config['db']['host'] = 'path/to/db/server';
$config['db']['port'] = '3306';
$config['db']['username'] = 'XXXXXX';
$config['db']['password'] = 'XXXXXX';
$config['db']['dbname'] = 'xenforo';

$config['superAdmins'] = '1';

##memcache on DB server
$config['cache']['enabled'] = true;
$config['cache']['frontend'] = 'Core';
$config['cache']['frontendOptions'] = array('caching'  =>  true,
                                          'automatic_serialization' => true,
                                          'lifetime'    => 5400,
                                        'cache_id_prefix' => 'foro'
                                            );
$config['cache']['backend'] = 'Memcached';
$config['cache']['backendOptions'] = array(
          'servers' =>array(
                          array(
                              'host' => 'path/to/db/server', // your memcached server ip /address
                              'port' => 11211        // memcached port
                          )
                      ),
            'compression' => false
);

##APC on webserver
// $config['cache']['enabled'] = true;
// $config['cache']['frontend'] = 'Core';
// $config['cache']['frontendOptions'] = array(
//                                        'caching'                      => true,
//                                        'automatic_serialization'      => true,
//                                        'lifetime'                      => 5400,
//                                        'cache_id_prefix' => 'foro'
// );
// $config['cache']['backend'] = 'Apc';

So in closing, the the docs for memcached are not correct and the linked thread from above will work.

Thanks again for the help in turning on the lightbulb.

Russ
 
Top Bottom