how to prevent azure from scaling out additional instances until they are ready?

前端 未结 4 1888
小蘑菇
小蘑菇 2021-02-04 06:04

We are having issues with an Azure Application Service. One of our webservices (MVC) caches data from the database at startup (Application_Start) - this takes approximately 3 m

相关标签:
4条回答
  • 2021-02-04 06:37

    My recommendation would be to use an Azure Load Balancer with a health probe

    0 讨论(0)
  • 2021-02-04 06:38

    There is a lot of good information, in the link https://www.jan-v.nl/post/warming-up-your-app-service that was included in one of the comments.

    Based on that information the functionality that you require is not available in the free tier.

    I would approach the problem differently. Why does it take 3 mins to load the data from the database? Since it is only loaded on start it should be data that does not change often.

    Could you:

    • Optimise the reading of data from the database?
    • Reduce the amount of data you read from the database?
    • Export the data to a file, and read it from a file?
    0 讨论(0)
  • 2021-02-04 06:52

    You can do this in Azure with other resource type than classic VM like an App Service. App Services scale up and down with instances that share the same memory pool and thread pool.

    0 讨论(0)
  • 2021-02-04 07:01

    Do try to reduce the data you need to load on app_start and try to lazy load data into Cache on first request. Some times even after doing all of this we do end up with large sets of data that is necessary on start.

    There are two ways we can approach this.

    One, assuming you are using in-memory caching and every instance of the app needs to hydrate its in-memory cache on App_Start. Try to use a external cache provider like Azure Cache for Redis, your new instance can just point to this external cache without having to reload the data.

    Two, you can depend on Application Initialization Module which was introduced in IIS 7.5 (installed on Azure App Services' IIS). To use this feature, you need to add applicationInitialization section under web.server section of web.config. This will help you not make the instance available until the warm-up process is completed. More info on how to use ApplicationInitialization is available in this blog post

    The best case would be to use the combination of both, applicationInitialization will point at a page in your application which checks if the external cache is available and hydrated, if yes, complete, else hydrate the external cache.

    0 讨论(0)
提交回复
热议问题