Magento 2 – Slow Admin Login and Saving Products

admin-panelmagento2magento2.1.11slowbackend

I am using Magento 2 Enterprise version 2.1.11 hosted on AWS EC2… 2 server which uses load balancer. I am having slow login query with Admin Login and saving products to database. Everything else works normal.

Checked everything like PHP configurations, Magento settings, Redis Cache, CPU Load and its Memory usage. Everything looks good to me.

Around 350 products, 150 attributes, 3 website/store and fresh project in M2.

not sure how to debug this issue.

Best Answer

I have the same issue after upgrade from 2.1.10 to 2.1.11. The only thing that I've found now is a very slow Redis lib, it takes up to 99% of whole "Admin Login" action time. Make a note - not Redis service, but Redis php lib.
Code ref: Cm\RedisSession\Handler::read

Not sure about products saving, but I think it could be the same. Hope this info will be helpful.

In case I'll find the solution - I post it here.

UPDATE: I've found the solution and the reason of the problem.

Problem reason: It is Magento 2.1.11 bug (not present in 2.1.10) caused by the double calling of \Cm\RedisSession\Handler::read method that initiates locking on the first call - so, the second call should wait till "break_after" config time to get needed data from Redis.

  • The first call is happened in:

    vendor/magento/framework/Session/SessionManager.php:476

  • The second call is happened in:

    vendor/magento/framework/Session/SessionManager.php:483

"break_after" config timings:

  • For BackOffice it is: 30seconds
  • For Frontend it is: 5seconds

(you can clearly see these timings in NewRelic traces)

Solution: Fix present in "2.2-develop" branch and stable version 2.2.2: https://github.com/magento/magento2/commit/aaa60b1b72bdc189b38492bd50b0ffb23101173e#diff-b4aa30666c05e391240357a7a435a7a8