How about using redis as an async cache. The strategy looks something like this:
- We first hit the server’s SessionCollectionView to look for the user’s session.
- If it doesn’t exist then we go out to redis and fetch the session. If it exists we merge it in to the local cache.
- After the operation, we update the local cache and also update the redis cache.
This way, if a user is using a websocket they’ll tend to hit the same server. If they don’t, though, for whatever reason, they can reconnect to a different server and have their session restored.
When there’s a local cache miss it would take a bit more time but we would end up with a much more robust / horizontally scalable solution.
It would also help avoid issues when deploying since when we deploy a new version and connect the user to a new server it will be able to restore their session.
What do you think?