Search code examples
azurecachingautoscalingazure-webapps

How to handle in memory cache with Azure App service auto scale


I have a Web app hosted in azure App service. The application has an in-memory cache. Planning to enable the auto-scale in app service when the server traffic is high. What will happen to the in-memory cache? What is the best way to handle this?


Solution

  • Well, you will have n in-memory cache instances. That might be ok, but you might want to look at a distributed cache like Azure Redis Cache or another ready made distributed implementation of IMemoryCache as found here (assuming you use .Net):

    • Distributed SQL Server cache
    • Distributed Redis cache
    • Distributed NCache cache

    If you keep using the in-memory cache, each new web app instance will start with an empty cache and it will fill based on the requests to that particular instance.