Jsf sessions in web farm

Creating a JSF application from Spring on Tomcat. The goal is a web farm, and the client asked us to develop our application so that it could be load balanced without relying on sticky sessions in LB.

In .NET, you can configure the SQL Server session store or State State Service. What alternatives exist in the Java world? Is there a standard way to connect another session state store that points to a MySQL database, for example? Does Spring provide any hooks?

+4
source share
1 answer

This is a specific servlet container, which in this case is Tomcat. A servlet container is one that manages sessions and provides sessions. Therefore, JSF and Spring have nothing to do here. They simply transparently retrieve it from the servlet container on request.getSession() , etc.

In Tomcat, you can provide a custom session manager implementation in the webapp Context :

 <Context ...> <Manager className="com.example.SessionManager"> 

.. where com.example.SessionManager implements org.apache.catalina.Manager in accordance with its contract. In this case, you can write code to return the sessions to the database.

However, there are alternatives for your specific requirement, you can choose for Tomcat built-in clustering / replication session functions instead of inventing it with a custommade manager / database. Read more about this at Tomcat Clustering / Session Replication HOW-TO .

+2
source

Source: https://habr.com/ru/post/1301161/


All Articles