4 Quick Redis Tips to Optimize Your Sitecore Environment
Redis is a critical component for Session State (both Private and Shared) in a Sitecore environment, and its easy to take a “set it and forget mindset” when it comes to using Redis with Sitecore. However, there is a lot of tuning and practices to optimize Redis for Sitecore. Here are 4 Quick Redis Tips to Optimize Your Sitecore Enviornment:
Contents
Apply Appropriate Hotfixes
Sitecore has a list of Redis hotfixes or tuning in more recent versions to ensure healthy connectivity between Sitecore and Redis. Check out the timeout issues article at: https://support.sitecore.com/kb?id=kb_article_view&sysparm_article=KB0464570. Sitecore Inc. Support may have other Redis hotfixes depending on your situation if you run into further issues.
Tune Your Redis Connection
There are several settings you can add to both your Private and Shared Redis connectionStrings to optimize Redis. A full list of settings can be found at: https://doc.sitecore.com/developers/100/platform-administration-and-architecture/en/redis-provider-settings-reference.html. The most common connection settings are the following:
- operationTimeoutInMilliseconds=”5000″
- retryTimeoutInMilliseconds=”16000″
- connectionTimeoutInMilliseconds=”3000″
- pollingMaxExpiredSessionsPerSecond=”20″
Avoid Excessive Load on the Session State Store
There are several solutions to reduce excessive load on the Session State Store. Two that are often overlooked is the storing of custom objects and using readable MVC controllers. Per Sitecore:
Avoid storing custom objects in the session. The session mechanism can become a bottleneck if there is a large session size. Use custom caches or shared storages instead.
https://support.sitecore.com/kb?id=kb_article_view&sysparm_article=KB0858026
Avoid using session state or explicitly specify to use it in read-only mode wherever possible by utilizing ReadOnly MVC controllers or use the EnableSessionState=”Readonly” attribute on a page directive for ASP.NET Web Forms pages.
https://support.sitecore.com/kb?id=kb_article_view&sysparm_article=KB0858026
A full list of options to tune and other solutions to reduce load on the Session State Store are within the following: https://support.sitecore.com/kb?id=kb_article_view&sysparm_article=KB0858026
Scale Redis Up and Out
While a C1 Redis tier seems adequate from a caching perspective, it only offers “Low Network Bandwidth”. For Production environments you will require at least a C2/Moderate Network Bandwidth to avoid a bottleneck. Check out the Azure Redis Pricing/Tiers here: https://azure.microsoft.com/en-us/pricing/details/cache/
It may also become appropriate to leverage a “full scaled Redis” option in which you have a dedicated Redis for both Private and Shared Sessions. Sitecore MVP Gabe Streza has a great breakdown of how to achieve this in his “Redis Dead Redemption: Redis Cache Timeouts with Sitecore Azure PaaS” article. Of note, this also applies for Redis used by IaaS and Container/AKS platforms.