Key information about session failover are listed below:
- Session failover prevents losing session data by backing up session content in the database.
- If session failover is in place, cluster nodes can restore sessions persisted in the database. After a node shuts down, the remaining nodes can restore its sessions from the database. They continue to serve requests of these sessions without interruption or data loss.
- The SAP Commerce session failover implementation is based on the Spring Session project.
- SAP Commerce session failover is designed with sticky-session load balancing in mind.
- A load balancer with configured sticky sessions assigns clients to specific cluster nodes. It always forwards requests from the same client to the same server.
- SAP Commerce session failover operates in two modes. In synchronous mode, a session is saved to the database after each request has been processed before sending a response. In asynchronous mode, a session is saved by a separate thread with a configurable time interval for the save operation. The session is added to the to-be-saved queue before sending an HTTP response, but the save action is done later.
- HybrisSpringSessionFilter is the main class of the session failover feature. This is seat as the first element of the PlatformFilterChain so that it can wrap session-related objects before session is created or used.
- HybrisSpringSessionFilter uses SessionRepositoryFactory to create SessionRepository for each extension that has session failover enabled.

For details please click here.
Configuring Session Failover
Session failover provides properties that can be setup precisely to meet the requirement of clustered environment. All the default properties are set in platform/project.properties file in Session failover settings section. We can customize or overwrite the properties in local.properties file. Following are the properties for configuring session failover.
Global Properties For Session Failover
- Set the spring.session.enabled property to true. This enables the HybrisSpringSessionFilter global filter. If the property is set to false, no session failover can be performed.
spring.session.enabled =true - Set spring.session.save.async.interval to define interval between session persistence attempts (in milliseconds).
spring.session.save.async.interval=5000 - Set spring.session.save.async.queue.size to define size of a queue of sessions to persist.
spring.session.save.async.queue.size=10000 - Set spring.session.save.async.max.items to define max number of session items being saved in one attempt.
spring.session.save.async.max.items=2000 - Set session.serialization.check.response.error to return the 500 error code if a session is not serializable.
session.serialization.check.response.error=true
Extension Specific Properties
Extension Specific Session Failover Properties
- Set the spring.session.enabled property to true. This enables the HybrisSpringSessionFilter global filter. If the property is set to false, no session failover can be performed.
spring.session.enabled=true - Select the sync or async session failover operation mode for the target extension as below. The async configuration is faster but choosing it can result in session data loss if a node fails before the pending session is saved to the database.
spring.session.<extension_name>.save=syncspring.session.<extension_name>.save=async - Configure the session cookie name and path. It is recommended to configuring the name and path of the cookie to be the same as the JSESSIONID cookie, which is generated without the session failover feature enabled. We can, however, set a different cookie ID as below.
//Configuration with JSESSIONID cookie name:
spring.session.<extension_name>.cookie.name=JSESSIONID
spring.session.<extension_name>.cookie.path=/<extension_webApp_contextPath>
//Configuration with a different cookie:
spring.session.<extension_name>.cookie.name=different_cookie_ID
spring.session.<extension_name>.cookie.path=/<extension_webApp_contextPath> - Make sure hybrisSpringSessionFilter is first in the filter chain bean for the target web extension. We can find the filter chain bean inside a <your_extension_name>-web-app-config.xml file located in a <your_extension_name>/web/webroot/WEB-INF/config/ directory. Following code snippet shows how to modify the bean for an example extension called sessionfailovertest so that the bean includes hybrisSpringSessionFilter:
<bean id="sessionfailovertestPlatformFilterChain" class="de.hybris.platform.servicelayer.web.PlatformFilterChain">
<constructor-arg>
<list> <ref bean="hybrisSpringSessionFilter"/>
<ref bean="log4jFilter"/>
<ref bean="sessionFilter"/>
<ref bean="sessionfailovertestMediaFilter"/>
</list>
</constructor-arg>
</bean>
Place the filter in the filter chain before a session gets created or accessed by the application. It wraps HttpRequest and HttpResponse. Otherwise two conflicting session cookies could be created – one from the application server and another by the session failover feature.