Magento – Moving from file session to DB session

cookiesession

We are moving out site from single dedicated server to AWS. AS part of the AWS implementation we will be using a load balancer across multiple web hosts (to a single DB). In order to support this configuration we need to move from file based session data to DB but in testing this breaks the site.

The process we are testing is to change local.xml to DB session and then clearing session/cache of server. Going to the site root works, but as soon as you try logging in or go through checkout you are prompted with the Magento installation screen?!? Same happens when you go to the admin page.

So, it appears that it's working for HTTP but not HTTPS? Also noticed that no cache is being created in var – the cache folder is created but no subfolder/files. Permissions are 777 on var.

Any help appreciated.

Best Answer

We are moving out site from single dedicated server to AWS

I'm sorry to hear that.

In order to support this configuration we need to move from file based session data to DB

Not quite. You need to move to a distributed session store, not necessarily database driven sessions. This will be one if many things you'll need to address when running a distributed architecture.

Using MySQL for session storage is not a good idea, it's not designed for this purpose, thankfully there are excellent alternatives.

Redis is the perfect choice, it's native to newer releases and pluggable via Cm_RedisSession in older releases.

This is what you need, https://github.com/colinmollenhour/Cm_RedisSession

After install and configuration, be sure to flush the config cache and you'll be good to go.

Also noticed that no cache is being created in var

Cm_Cache_Backend_Redis to the rescue, https://github.com/colinmollenhour/Cm_Cache_Backend_Redis


Then once you've figured out cache storage and session access, you'll have to address shared media storage, deployment, monitoring, software versioning, automation, fail over, SPOF analysis and much more.

Related Topic