Problem with replica PHP memcached sessions

I installed a couple of Memcached servers for use as a PHP session repository, but despite various settings, I can’t get the session keys to appear on both servers.

My php.ini looks like this:

session.save_handler = memcached session.save_path = "192.168.134.38:11211,192.168.134.234:11211" 

My memcached.ini are options:

 extension=memcached.so memcached.sess_consistent_hash=1 memcached.sess_number_of_replicas=1 memcached.sess_binary=1 

If I started memcached using -vv, I see that the keys are being written to the first server:

 <30 new auto-negotiating client connection 30: Client using the binary protocol <30 Read binary protocol data: <30 0x80 0x0c 0x00 0x28 <30 0x00 0x00 0x00 0x00 <30 0x00 0x00 0x00 0x28 <30 0x00 0x00 0x00 0x00 <30 0x00 0x00 0x00 0x00 <30 0x00 0x00 0x00 0x00 <30 GET memc.sess.key.9bn8cdu9c1j7ko1tmflgr433k1 >30 Writing bin response: >30 0x81 0x0c 0x00 0x28 >30 0x04 0x00 0x00 0x00 >30 0x00 0x00 0x03 0xc6 >30 0x00 0x00 0x00 0x00 >30 0x00 0x00 0x00 0x00 >30 0x00 0x00 0x00 0x00 <30 Read binary protocol data: <30 0x80 0x01 0x00 0x28 <30 0x08 0x00 0x00 0x00 <30 0x00 0x00 0x03 0xcb <30 0x00 0x00 0x00 0x00 <30 0x00 0x00 0x00 0x00 <30 0x00 0x00 0x00 0x00 <30 SET memc.sess.key.9bn8cdu9c1j7ko1tmflgr433k1 Value len is 923 >30 Writing bin response: >30 0x81 0x01 0x00 0x00 >30 0x00 0x00 0x00 0x00 >30 0x00 0x00 0x00 0x00 >30 0x00 0x00 0x00 0x00 >30 0x00 0x00 0x00 0x00 >30 0x00 0x00 0x00 0x05 <30 Read binary protocol data: <30 0x80 0x07 0x00 0x00 <30 0x00 0x00 0x00 0x00 <30 0x00 0x00 0x00 0x00 <30 0x00 0x00 0x00 0x00 <30 0x00 0x00 0x00 0x00 <30 0x00 0x00 0x00 0x00 >30 Writing bin response: >30 0x81 0x07 0x00 0x00 >30 0x00 0x00 0x00 0x00 >30 0x00 0x00 0x00 0x00 >30 0x00 0x00 0x00 0x00 >30 0x00 0x00 0x00 0x00 >30 0x00 0x00 0x00 0x00 <30 connection closed. 

However, the second server just receives connections / disconnects, but nothing is saved:

 <30 new auto-negotiating client connection 30: Client using the ascii protocol <30 quit <30 connection closed. 

So, as soon as you kill the first server sessions, they are lost, and there is no transition to another resource.

Does anyone know what is going on here?

Edit:

We have created several sessions in different browsers, it seems that the keys are distributed but not replicated.

Server 1:

 stats cachedump 12 100 ITEM memc.sess.key.80iie5lhm36mddkekdk488q923 [922 b; 1406287763 s] 

Server 2:

 stats cachedump 12 100 ITEM memc.sess.key.ehd1nsm6icc2qsotbkcp8i9sd7 [874 b; 1406287898 s] ITEM memc.sess.key.d3p0id333ggbd0004n4rcc4890 [875 b; 1406287868 s] ITEM memc.sess.key.7hek9e2aakgqv9sm2bcq5fbfb3 [922 b; 1406287842 s] 
+6
source share
1 answer

It turns out that the version of memcached bundled with Ubuntu 14.04 (2.1.0) does not support the sess_number_of_replicas parameter. We installed the latest version from PECL and this solved the problem.

+7
source

Source: https://habr.com/ru/post/972824/


All Articles