Introducing a two level distributed cache #1819
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
To start I want to say that the default in-memory caching for a single instance works great. It is fast and can handle lots of load. My recommendation is to scale up instead of scale out if it’s possible.
But, I have been looking into the implementation of the distributed cache implementation. Currently it is mainly wrapping the default .NET distributed cache service IDistributedCache. When I tried to use an app service cluster in Azure I ran into some performance issues. Some pages with many blocks added to them didn’t behave well under load tests. After some debugging my conclusion is that the server talks a lot to the cache service. Works great for in-memory caching, but not so good when using a Redis cache or some other cache service that talks over the network.
So my suggestion is to create a simple two level distributed cache. The first level cache is an in-memory cache and the second level is the distributed cache. When something in the second level cache is changed the whole first level cache is invalidated and must be reloaded again.
I have tried to add functionality so that it doesn’t cause breaking changes for those who use the current distributed cache implementation.