• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.5 Memcache Issues

#1
I keep having issues with memcache timeout. It is often causes my max users to get exceeded as well, and eventually results in service crashes. Do I have a config wrong?

Code:
ErrorException: MemcachePool::get(): Server 127.0.0.1 (tcp 11211, udp 0) failed with: Network timeout (0) - library/Zend/Cache/Backend/Memcached.php:180
Generated By: Unknown Account, 48 minutes ago

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

array(3) {
  ["url"] => string(36) "http://stratics.com/forums/uhall.35/"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}
Code:
Zend_Db_Adapter_Mysqli_Exception: Too many connections - library/Zend/Db/Adapter/Mysqli.php:333
Generated By: Unknown Account, 50 minutes ago

#0 /var/www/vhosts/stratics.com/library/Zend/Db/Adapter/Abstract.php(315): Zend_Db_Adapter_Mysqli->_connect()
#1 /var/www/vhosts/stratics.com/library/XenForo/Application.php(728): Zend_Db_Adapter_Abstract->getConnection()
#2 [internal function]: XenForo_Application->loadDb(Object(Zend_Config))
#3 /var/www/vhosts/stratics.com/library/XenForo/Application.php(971): call_user_func_array(Array, Array)
#4 /var/www/vhosts/stratics.com/library/XenForo/Application.php(1002): XenForo_Application->lazyLoad('db', NULL)
#5 /var/www/vhosts/stratics.com/library/XenForo/Application.php(1607): XenForo_Application::get('db')
#6 /var/www/vhosts/stratics.com/vault/core/controller/db/xf.php(33): XenForo_Application::getDb()
#7 /var/www/vhosts/stratics.com/vault/core/controller/start/vw.php(65): vw_DB_Controller_XF->ready()
#8 /var/www/vhosts/stratics.com/vault/core/controller/start/vw.php(74): vw_Start_Controller->init()
#9 /var/www/vhosts/stratics.com/library/vw/XenForo/CodeEventListener.php(76): vw_Start_Controller->fire()
#10 /var/www/vhosts/stratics.com/library/vw/XenForo/CodeEventListener.php(28): vw_XenForo_CodeEventListener::init()
#11 [internal function]: vw_XenForo_CodeEventListener::init_dependencies(Object(XenForo_Dependencies_Public), Array)
#12 /var/www/vhosts/stratics.com/library/XenForo/CodeEvent.php(90): call_user_func_array(Array, Array)
#13 /var/www/vhosts/stratics.com/library/XenForo/Dependencies/Abstract.php(215): XenForo_CodeEvent::fire('init_dependenci...', Array)
#14 /var/www/vhosts/stratics.com/library/XenForo/FrontController.php(127): XenForo_Dependencies_Abstract->preLoadData()
#15 /var/www/vhosts/stratics.com/index.php(13): XenForo_FrontController->run()
#16 {main}

array(3) {
  ["url"] => string(46) "http://stratics.com/forums/uo-traders-hall.41/"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}
 
#4
This is my config for Xenforo Memcache.

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

                        // memcached port
                        'port' => 11211,
                )
        )
);
This is my MYSQL config.

Code:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
max_allowed_packet      = 56M
max_connections         = 250
wait_timeout            = 120
innodb_buffer_pool_size = 512M
query_cache_size        = 32M
join_buffer_size        = 1028K
tmp_table_size          = 128M
max_heap_table_size     = 128M
thread_cache_size       = 4
table_cache             = 400
Using netstat.

Code:
[root@stratics etc]# netstat -n | grep -c TIME_OUT
0
[root@stratics etc]# netstat -n | grep -c TIME_WAIT
181
[root@stratics lib]# netstat -tap | grep memcached
tcp        0      0 0.0.0.0:memcache        0.0.0.0:*               LISTEN      677/memcached
tcp        0      0 localhost:memcache      localhost:46407         ESTABLISHED 677/memcached
tcp        0      0 localhost:memcache      localhost:46427         ESTABLISHED 677/memcached
tcp        0      0 localhost:memcache      localhost:46070         ESTABLISHED 677/memcached
tcp        0      0 localhost:memcache      localhost:46521         ESTABLISHED 677/memcached
tcp        0      0 localhost:memcache      localhost:46507         ESTABLISHED 677/memcached
tcp        0      0 localhost:memcache      localhost:46509         ESTABLISHED 677/memcached
tcp        0      0 localhost:memcache      localhost:46449         ESTABLISHED 677/memcached
tcp        0      0 localhost:memcache      localhost:46493         ESTABLISHED 677/memcached
tcp        0      0 localhost:memcache      localhost:46072         ESTABLISHED 677/memcached
tcp        0      0 localhost:memcache      localhost:46543         ESTABLISHED 677/memcached
tcp        0      0 localhost:memcache      localhost:46431         ESTABLISHED 677/memcached
tcp        0      0 localhost:memcache      localhost:46497         ESTABLISHED 677/memcached
tcp        0      0 localhost:memcache      localhost:46134         ESTABLISHED 677/memcached
tcp        0      0 localhost:memcache      localhost:46513         ESTABLISHED 677/memcached
tcp        0      0 localhost:memcache      localhost:46409         ESTABLISHED 677/memcached
tcp6       0      0 [::]:memcache           [::]:*                  LISTEN      677/memcached
Memcached config

Code:
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS=""
 
#5
MYSQLtuner output

Code:
[root@stratics sysconfig]# mysqltuner

>>  MySQLTuner 1.2.0 - Major Hayden <major@mhtx.net>
>>  Bug reports, feature requests, and downloads at http://mysqltuner.com/
>>  Run with '--help' for additional options and output filtering

-------- General Statistics --------------------------------------------------
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.5.44-MariaDB
[OK] Operating on 64-bit architecture

-------- Storage Engine Statistics -------------------------------------------
[--] Status: +Archive -BDB +Federated +InnoDB -ISAM -NDBCluster
[--] Data in MyISAM tables: 2G (Tables: 135)
[--] Data in InnoDB tables: 5G (Tables: 1209)
[--] Data in PERFORMANCE_SCHEMA tables: 0B (Tables: 17)
[--] Data in MEMORY tables: 869K (Tables: 27)
[!!] Total fragmented tables: 1214

-------- Security Recommendations  -------------------------------------------
[OK] All database users have passwords assigned

-------- Performance Metrics -------------------------------------------------
[--] Up for: 1h 11m 11s (577K q [135.227 qps], 11K conn, TX: 7B, RX: 123M)
[--] Reads / Writes: 97% / 3%
[--] Total buffers: 816.0M global + 3.7M per thread (250 max threads)
[OK] Maximum possible memory usage: 1.7G (45% of installed RAM)
[OK] Slow queries: 0% (141/577K)
[OK] Highest usage of available connections: 29% (74/250)
[OK] Key buffer size / total MyISAM indexes: 128.0M/2.3G
[OK] Key buffer hit rate: 98.9% (394K cached / 4K reads)
[OK] Query cache efficiency: 47.5% (476K cached / 1M selects)
[!!] Query cache prunes per day: 297150
[OK] Sorts requiring temporary tables: 0% (3 temp sorts / 11K sorts)
[!!] Joins performed without indexes: 3810
[!!] Temporary tables created on disk: 47% (5K on disk / 10K total)
[OK] Thread cache hit rate: 92% (893 created / 11K connections)
[!!] Table cache hit rate: 4% (400 open / 9K opened)
[OK] Open file limit used: 7% (88/1K)
[OK] Table locks acquired immediately: 99% (147K immediate / 147K locks)
[!!] InnoDB data size / buffer pool: 5.5G/512.0M

-------- Recommendations -----------------------------------------------------
General recommendations:
    Run OPTIMIZE TABLE to defragment tables for better performance
    MySQL started within last 24 hours - recommendations may be inaccurate
    Enable the slow query log to troubleshoot bad queries
    Adjust your join queries to always utilize indexes
    When making adjustments, make tmp_table_size/max_heap_table_size equal
    Reduce your SELECT DISTINCT queries without LIMIT clauses
    Increase table_cache gradually to avoid file descriptor limits
Variables to adjust:
    query_cache_size (> 32M)
    join_buffer_size (> 1.0M, or always use indexes with joins)
    tmp_table_size (> 128M)
    max_heap_table_size (> 128M)
    table_cache (> 400)
    innodb_buffer_pool_size (>= 5G)

[root@stratics sysconfig]#
 
#7
Add/replace with;
CACHESIZE="256"
OPTIONS="-l 127.0.0.1"
... and restart. See if that makes a difference?

A 64Mb memcache is too small for a 5Gb DB. I'd even CACHESIZE="512" if you have the free RAM.
I'll try that out and let you know.

Code:
memcache

memcache support => enabled
Version => 3.0.8
Revision => $Revision: 329835 $

Directive => Local Value => Master Value
memcache.allow_failover => 1 => 1
memcache.chunk_size => 32768 => 32768
memcache.compress_threshold => 20000 => 20000
memcache.default_port => 11211 => 11211
memcache.hash_function => crc32 => crc32
memcache.hash_strategy => consistent => consistent
memcache.lock_timeout => 15 => 15
memcache.max_failover_attempts => 20 => 20
memcache.protocol => ascii => ascii
memcache.redundancy => 1 => 1
memcache.session_redundancy => 2 => 2

memcached

memcached support => enabled
Version => 2.2.0
libmemcached version => 1.0.16
SASL support => yes
Session support => yes
igbinary support => yes
json support => yes
msgpack support => yes

Directive => Local Value => Master Value
memcached.compression_factor => 1.3 => 1.3
memcached.compression_threshold => 2000 => 2000
memcached.compression_type => fastlz => fastlz
memcached.serializer => igbinary => igbinary
memcached.sess_binary => no value => no value
memcached.sess_connect_timeout => 1000 => 1000
memcached.sess_consistent_hash => no value => no value
memcached.sess_lock_expire => 0 => 0
memcached.sess_lock_max_wait => 0 => 0
memcached.sess_lock_wait => 150000 => 150000
memcached.sess_locking => 1 => 1
memcached.sess_number_of_replicas => 0 => 0
memcached.sess_prefix => memc.sess.key. => memc.sess.key.
memcached.sess_randomize_replica_read => no value => no value
memcached.sess_remove_failed => 1 => 1
memcached.sess_sasl_password => no value => no value
memcached.sess_sasl_username => no value => no value
memcached.store_retry_count => 2 => 2
memcached.use_sasl => no value => no value
 
Last edited: