I’m working on a project where we’re in need of a cache inside Service Fabric. Now the cache doesn’t need to be durable just nice, quick and easy to use.
So I came up with the idea of running a Redis cache inside the cluster as a stateless service fabric service. The problem with this is that when the cluster re-balances the services between nodes I will lose the inmemory data in Redis (all of it). What I can do is set the movement cost set to ‘high’, to discourage the cluster from reallocating the service between nodes regularly and causing unnecessary loss of the cache. Great read on how and why the Resource Manager allocations services between nodes here, if you’d like to know more.
It’s worth noting that, if I wanted a durable cache, I could look at using Redis Clustering/Redis as a Service in Azure to prevent this occurring but for what we need it’s overkill.
Either way, I got this up and running and have shared the code here with a ReadMe going into more detail for others that are interested in having a play. Hope it’s useful!