Magento Cache/Session cluster challenge

Image for post
Image for post

Using Redis, Magento will be able to share its cache and sessions between multiple applications(web) instances. As an added benefit, storing the cache and sessions in Redis provides a notable speed boost.

M2 provides support for Redis out of the box for both cache and sessions. Configuration M2 app/etc/env.php config file must be modified so that Magento will use Redis for sessions and cache. Add session and cache Redis connections to the configuration in env.php. Replace any existing cache or session sections.

By default M2 using file system as a storage. Magento Full Page Cache If you use Full Page Cache functionality, you will need to configure it to store the cache in Redis also.

Important If you use one Redis instance for more than one type of caching, the database numbers must be different. It is recommended that you assign the default caching database number to 0, the page caching db to 1, and the session storage db to 2.

With Amazon Web Service(AWS) you can use ElastiCache for Redis. Your Magento 2 can works seamlessly with AWS Redis service without any code changes.

You can use red replica with magento 2/1(for one you need update Cm_Cache_Backend_Redis library) you need just add to magento configuration to magento configuration file /etc/env.php

'load_from_slave' => 'tcp://redis-slave-read-ip:6379',

Maagento will Perform reads from a different server.
you can also try this option

'retry_reads_on_master' => true,If ‘retry_reads_on_master’ is truthy then reads will be retried against master when slave returns “(nil)”,null value

With AWS Elastic Cache you can easily create rides cluster

Image for post
Image for post

AWS provide two Endpints. Primary for master and Reader andpoint for multiple slaves.

You can use a single reader endpoint to connect to your multiple Redis read replicas. Feature allows you to direct all read traffic to your ElastiCache for Redis cluster through a single, cluster-level endpoint.

Written by

Magento/APP Cloud Architect. Melting metal server infrastructure into cloud solutions.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store