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 8, 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. It requires additional configuration for the deployment and isn't a particularly elegant approach.
Refactor our code to put data in a database instead of the session. We can then load the user's data from the database if we associate it with a cookie...