How can I have my App Service always ready?

David Thielen 2,281 Reputation points
2024-04-20T22:19:03.8633333+00:00

Hi all;

I want my app service to always be running, so that when someone hits it, there's no delay. So how can I set it to:

  1. When restarted, it starts up immediately.
  2. In never shuts down due to inactivity.
  3. When Azure needs to apply patches or restart the server for any reason, it first spins up a new instance, then shuts down the existing instance.
  4. Is there any other use cases?

thanks - dave

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,914 questions
0 comments No comments
{count} votes

Accepted answer
  1. SnehaAgrawal-MSFT 18,366 Reputation points
    2024-04-26T06:41:34.3866667+00:00

    @David Thielen To determine the appropriate configuration for your app, Load testing can be a useful tool to help you identify the optimal configuration for your app.you can follow these steps:1. Identify the performance requirements of your app. This includes factors such as expected traffic volume, response times, and resource utilization.

    1. Use load testing tools to simulate traffic to your app. You can use tools like Apache JMeter, LoadRunner, or Azure Test Plans to simulate traffic to your app.
    2. Gradually increase the load on your app until you reach the expected maximum use. This will help you identify the performance bottlenecks and resource constraints of your app.
    3. Measure the response times and resource utilization of your app under different load conditions. This will help you identify the optimal configuration for your app.
    4. Use the App Service Diagnostics tool to monitor the performance of your app in real-time. The tool provides insights into the performance of your app and can help you identify issues and optimize your app.
    5. Adjust the configuration of your app based on the results of your load testing and performance monitoring. This may include adjusting the number of instances, scaling up or down, or optimizing the code and resources.

    Regarding your question about warming up a Blazor server app, you can use the "Always On" feature in Azure App Service to keep your app warm. The "Always On" feature ensures that the app is always running and responsive, even when there is no traffic to the app.

    Here are the steps to enable the "Always On" feature for your Blazor server app:

    Open the Azure portal and navigate to your App Service.

    Click on the "Configuration" tab in the left-hand menu.

    Under "General settings", click on "Application settings".

    Scroll down to the "General settings" section and set the "Always On" option to "On".

    Click on the "Save" button to apply the changes.

    Once you have enabled the "Always On" feature, your Blazor server app will be kept warm and responsive, even when there is no traffic to the app. This can help reduce the startup time and improve the performance of your app.

    I hope this helps! Let me know if you have any further questions.

    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Marcin Policht 11,385 Reputation points MVP
    2024-04-20T22:34:32.73+00:00

    That's the default behavior for the App Service with Always On enabled. As per https://learn.microsoft.com/en-us/azure/app-service/configure-common?tabs=portal

    Always On: Keeps the app loaded even when there's no traffic. When Always On isn't turned on (default), the app is unloaded after 20 minutes without any incoming requests. The unloaded app can cause high latency for new requests because of its warm-up time. When Always On is turned on, the front-end load balancer sends a GET request to the application root every five minutes. The continuous ping prevents the app from being unloaded.

    In other words, you don't have to do anything - except for provisioning an App Service web app and enabling Always On. The other requirements are satisfied by default


    If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

    hth

    Marcin


  2. Lex Li (Microsoft) 4,742 Reputation points Microsoft Employee
    2024-04-20T23:12:28.8766667+00:00

    What you might try is,

    1. Use your own container/Linux to host the application server (Kestrel/Tomcat/Uvicorn or any other), where you can configure the server process to always run and have full control over its behaviors.
    2. Configure the container well, so that even if the server process exits for whatever reason (mostly app crashes), a new process can spin out. There are application server specific documentation on how to achieve this.
    3. Scale out geographically, so that even Azure platform 's regional patching won't affect all your container instances at the same time.

    You cannot get rid of the cold start delay though.

    Overall, the steps can help you reduce the unnecessary delay and most interrupts. But in reality "no delay" is impossible. Even your own web apps need warm up and possibly reload itself when configuration changes or crashed.

    0 comments No comments

  3. SnehaAgrawal-MSFT 18,366 Reputation points
    2024-04-24T12:44:35.08+00:00

    @David Thielen You may refer to this detailed blog for more information on this- The Ultimate Guide to Running Healthy Apps in the Cloud

    0 comments No comments