Distributed sessions

As we have seen in the preceding section, there are several moments when Spring Social stores things in the HTTP session. Our user profile is also stored in the session. This is a classical approach to keeping things in memory as long as a user is navigating the site.

However, this can prove troublesome if we want to scale our application and distribute the load to multiple backend servers. We have now entered the cloud era, and Chapter 7, Optimizing Your Requests will be about deploying our application to the cloud.

To make our session work in a distributed environment, we have a few options:

  • We could use sticky sessions. This will ensure that a specific user will always be redirected to the same server and keep its session. ...

Get Spring MVC: Designing Real-World Web Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.