Magento starts disappearing with memcache enabled

We have a problem when we have sessions accidentally deleted from Magento 1.10 when we have memcache enabled (on the nginx web server).

It doesn't look like we set the cookie expiration time in Magento, for some reason a random time within an hour the session leaves.

If we disable memcache, it works fine.

Ultimately, we will need several servers connecting to the same cached session-based solution, so memcache seems to be the only option. In addition, we are now only caching sessions in memcache, and when I check the memcache statistics, we are nowhere near the threshold limit.

Here are the memcache settings in local.xml :

 <cache> <type>memcached</type> <path/> <servers> <localhost> <host><![CDATA[127.0.0.1]]></host> <port><![CDATA[11211]]></port> <persistent><![CDATA[1]]></persistent> </localhost> </servers> </cache> <session_save><![CDATA[memcache]]></session_save> <!-- db / memcache / empty=files --> <session_save_path><![CDATA[tcp://localhost:11211?persistent=0&weight;=2&timeout;=10&retry;_interval=10]]></session_save_path> <session_cache_limiter><![CDATA[private]]></session_cache_limiter> 

The hard part of all this is that it is very difficult to reproduce, because the session is cleared after an hour. Sometimes it happens in a minute, sometimes 45 ...

We had several people who tried it in all different browsers on several virtual server systems (to resolve conflicts), and they all seem to clear up the same time.

Now the logic will dictate that there is a process that clears memcache, but I don’t know how to check it, and if I did, how to say that it was what cleared it. I looked through the Magento code, but I could not find anything like clearing this or deleting a session from memcache.

However, I found that the β€œfrontend” cookie remains in the browser after the session ends, and when I check the memcache plates, the cookie disappears.

Not all keys / values ​​have disappeared from memcache, in this case only some of them. The mine and 2 or 3 people were completely absent for some reason.

Now, what I ask, not only has anyone come across this, but does anyone have additional ideas on what to try?

I am using the (famous) memcache.php file to monitor the memcache system on the server. Any other ideas / apps I can try?

+4
source share
5 answers

It may or may not be your problem, but it was mine. Putting it here as others may prove to be helpful.

Memcached does not take too long before 30 days (2592000 seconds). Apparently, he interprets numbers that are larger than dates from the era and expires immediately.

Sessions * Magento local.xml elements set PHP environment variables. Any relevant PHP environment variables that are not set in local.xml are set from php.ini (or another .ini.)

So:

In php.ini, if session.gc_maxlifetime is set above 2592000, you will get a non-working memcached.

Therefore, change the line in php.ini to the following:

 session.gc_maxlifetime = 2592000 
+2
source

Disable caching and see if the sessions have disappeared. If this is the case, then caching the content causes session cleaning, use a separate memcache instance on a different port.

Alternatively switch session_save to db and avoid all the clutter at a time.

+1
source

As shown in the figure, Magento will clear sessions when flushing the cache. If you are using a standalone (non-clustered) server, I suggest using tempf as a session repository and memcache for your cache repository. When it's time to add another server, you should start memcache for both. At that time, you can use one to store the session, and the other to store the cache.

0
source

Not sure if this will solve the problem:

 <session_save_path> <![CDATA[tcp://localhost:11211?persistent=0&weight;=2&timeout;=10&retry;_interval=10]]> </session_save_path> 

You need to remove the semicolons to ensure that the specified options are set.

I usually see this when memcached-config was disconnected from the Magento Community Forum.

Another thing, how much memory did you allocate for your memcached daemon ?

Is memory used due to traffic on your site. The default installation of memcached without any changes sets the memory size to 64 MB. If space is used, it simply overwrites the memory. And you do not control those sessions that are thrown away.

0
source

the problem was caused by incorrect SSL key installation

0
source

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


All Articles