Magento – Long response time for Mage_Core_Model_Session_Abstract_Varien::start

performancesession

So I have been noticing in New Relic on a lot of our sites, a lot of our long page loads are happening due to Mage_Core_Model_Session_Abstract_Varien::start. I have done some research and haven't really seen anyone else talking about this.

We use Nginx, PHP FPM, Redis for Caching and Memcache for sessions. Some of my ideas are that maybe it is something else that is taking forever and it just appears that loading the session is the problem. Or somehow there is some custom code adding a lot of data to the session causing huge sessions.

I am not that knowledgeable in terms of sessions and how they are managed, however I found some articles talking about Session locking. However I don't think that people would be opening so many pages at the same time.

Some of these loads are like 20 – 30 seconds. I am just curious if anyone else has noticed this or had more knowledge on how to analyze these types of long requests due to sessions.

Best Answer

This is most likely related to a phenomenon regarding filesystem sessions. Despite what you're reporting via using Mecached for sessions I have only ever seen this myself when in fact I was using filesystem.

This has been covered before over here:

https://magento.stackexchange.com/a/3721/336

In fact a screenshot of a cachegrind reveals the exact point at which the session startup is taking an inordinate amount of time is in Mage_Core_Model_Session_Abstract_Varien::start as you correctly pointed out:

enter image description here

In the referenced thread there was the suggestion that this effect may be lessened with an in-memory session storage - but no concrete data exists that I know of to support the theory. If you're in fact using memcached then it stands to reason that the PHP-level session lock would prevent future requests to the session storage from being granted until the lock is released.

In general this is usually seen only on requests requiring access to session information, so architecting your frontend theme will be beneficial to limit the amount of access needed to avoid potential locks when a user has another tab or another long-running request in progress when deciding to move away.

HTH, Cheers.

Related Topic