Walkthrough: Configuring a shared session state database using the Redis provider
In a shared session state, all data that can be shared across multiple sessions, for example, the data related to contacts, is collected and saved to the session state database.
A contact can make multiple parallel visits to a website, in which case each visit has its own private session state. However, some data can be shared between visits, such as contact related information.
Information that is shared between parallel visits by the same contact is stored in the shared session state store. This data is still private to the contact, but it is accessible from all current sessions made by the same contact.
This walkthrough describes how to use Redis as your out-of-process shared session state store using the Sitecore session state provider for Redis.
This walkthrough describes how to:
-
Deploy a shared Redis session database
-
Configure Sitecore
-
Configure a dedicated Redis Session Processing server
-
Adjust the Redis provider settings
Sitecore does not support Redis Cluster.
Deploy a shared session database
The Sitecore ASP.NET session state store provider for Redis enables you to use Redis as your session state store. The provider supports the SessionEnd
event, which the xDB needs to track website visits.
Do not make changes directly to the configuration files. Instead, you must create apatch file that performs the required changes during runtime.
To deploy a Redis session database:
-
Choose between Azure Redis or Redis on premise. You can provision Azure Redis by using the instructions on the Microsoft Azure website or with Azure PowerShell.
-
Go to the
<sitename>\Website\App_Config
folder, open theConnectionStrings.config
file, and add the following connection string:RequestResponse<add name="sharedSession" connectionString="_host_:_port_number _" />
-
Configure the connection string so that it points to your session database.
-
Save your changes.
Configure Sitecore
The default shared-session store uses the in process provider, which stores data in memory and is implemented in the internal ASP.NET class InProcSessionStateStore
:
<sharedSessionState defaultProvider="inProc">
<providers>
<clear/>
<add name="inProc"
type="System.Web.SessionState.InProcSessionStateStore"
/>
</providers>
To configure Sitecore to instead use the shared session state provider for Redis:
-
In your website root folder, go to
App_Config\Sitecore\Marketing.Tracking
folder. -
Open the
Sitecore.Analytics.Tracking.Config
file. -
Locate the line where you can define the default shared session state provider using the following path:
sitecore/tracking/sharedSessionState
. -
Update the
sharedSessionState
section to use Redis as thedefaultProvider
(notinProc
). You must also, change the name attribute value toredis
, as shown in the following example:RequestResponse<sharedSessionState defaultProvider="redis"> <providers> <clear /> <add name="redis" type="Sitecore.SessionProvider.Redis.RedisSessionStateProvider, Sitecore.SessionProvider.Redis" connectionString="sharedSession" pollingInterval="2" applicationName="shared" /> </providers> </sharedSessionState>
Do not make changes directly to the configuration files. Instead, you must create a patch file that performs the required changes during runtime.
Adjust the Redis provider settings
Use the Redis provider settings reference to configure your session state. If you have configured everything correctly, session records appear in your Redis session database after the first web request.
Set lockAgeMilliseconds="15000"
for shared session state provider to enforce contact locking for minimum time required. Value should be equal to sitecore/tracking/sharedSessionState/config/maxLockAge (default=5000) + Analytics.MaxAcceptedClockDeviation (default=10000)