1

We had an issue whereby our pages took a long time to load. Upon dissecting the time taken by various layers to service the request on NewRelic, we found that the method Cm_RedisSession_Model_Session::read took around 30 seconds to complete.

That is also the default timeout to wait for the lock.

/* Try to break the lock after this many seconds */
const DEFAULT_BREAK_AFTER           = 30;

We look at the writes that take place once the lock is acquired, and it's more towards storing the PID and the request details.

    // This process has the lock, save the pid
    if ($this->_hasLock) {
        $setData = array(
            'pid' => $this->_getPid(),
            'lock' => 1,
        );

        // Save request data in session so if a lock is broken we can know which page it was for debugging
        if ($this->_logLevel >= Zend_Log::INFO) {
            if (empty($_SERVER['REQUEST_METHOD'])) {
                $setData['req'] = $_SERVER['SCRIPT_NAME'];
            } else {
                $setData['req'] = "{$_SERVER['REQUEST_METHOD']} {$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}";
            }
            if ($lock != 1) {
                $this->_log(sprintf(
                    "Successfully broke lock for ID %s after %.5f seconds (%d attempts). Lock: %d\nLast request of broken lock: %s",
                    $sessionId, (microtime(true) - $timeStart), $tries, $lock, $this->_redis->hGet($sessionId, 'req')
                ), Zend_Log::INFO);
            }
        }
        $this->_redis->hMSet($sessionId, $setData);
    }

Upon searching, we found several articles describing the same issue, and that one of the solutions is to simply disable the locking.

https://astrio.net/blog/redis-slow-session-magento/

https://willparsons.tech/redis-session-locking/

Our question is simply - would we encounter issues if we we're to disable locking for Cm RedisSession read?

Our setup consists of multiple, load balanced, auto-scalable Magento frontend nodes operating on a single Magento instance having multiple stores.

2
  • disable locking and see
    – MagenX
    Oct 25, 2017 at 7:52
  • Asking around before we do so to avoid any unforeseen issues, but yeah the gut feel is that everything's gonna be all right.
    – boyan
    Oct 25, 2017 at 9:16

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.