CodeIgniter Forums
Two memcached servers for sessions - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Two memcached servers for sessions (/showthread.php?tid=78809)



Two memcached servers for sessions - MichalSkoula - 03-13-2021

Hello,
Im using latest CI3.

I have started two memcached instances - 127.0.0.1:12345 and 127.0.0.1:12346

Now in my config.php I have:

PHP Code:
$config['sess_driver']  'memcached';
$config['sess_save_path'] = '127.0.0.1:12345,127.0.0.1:12346'

my php.ini:
Code:
memcached.sess_number_of_replicas = 2
memcached.sess_consistent_hash = on
memcached.sess_remove_failed_servers = on
memcached.sess_server_failure_limit = 3
memcached.store_retry_count = 2

Now when both of the memcached instances are on, it works.
When I turn off the first and keep the second on, it works.

But when I turn off the second and keep the first on, it does not work - it tries for 12 seconds and then I have this error:

Message: session_start(): Failed to read session data: user (path: c:/wamp64/tmp)


RE: Two memcached servers for sessions - MichalSkoula - 03-13-2021

PHP Code:
array (size=2)
  0 => 
    array (size=3)
      'host' => string '127.0.0.1' (length=9)
      'port' => int 12345
      
'type' => string 'TCP' (length=3)
  1 => 
    array (size=3)
      'host' => string '127.0.0.1' (length=9)
      'port' => int 12346
      
'type' => string 'TCP' (length=3

this is dump from:

PHP Code:
var_dump($this->_memcached->getServerList ( )); 



RE: Two memcached servers for sessions - MichalSkoula - 03-14-2021

I see, memcached does not support replication. I should go with redis.