Very slow startup of an app slot (high CPU)

Josh Levett 20 Reputation points
2025-11-24T11:19:44.88+00:00

We've recently been having issues with slot deployments to our UAT environment timing out.
I'm not aware of any configuration changes that were made before the issue started occurring, but we do see a significant increase in the CPU usage from the starting slot.

Our CD pipeline is effectively broken as no deployments can take place, we have to wait for hours before then manually swapping the slot.

In this graph you can see the difference between the running slot (pink) and the staging slot (blue)User's image

I'm not seeing any errors in the log stream during this time either, and the resource the slots use doesn't exceed 70% CPU

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
{count} votes

Answer accepted by question author
  1. Praneeth Maddali 2,265 Reputation points Microsoft External Staff Moderator
    2025-11-28T02:51:59.0866667+00:00

    HI @Josh Levett

    Thank you for sharing additional information in the private chat. Based on your input, now have a clear understanding of the situation from our deep investigation.

    What’s happening

     Your staging slot is experiencing a known .NET and App Service file-locking issue that occurs when the site runs from a package (ZIP deploy / Run-From-Package). During startup, IIS attempts to shadow-copy assemblies, but if DLLs are locked, shadow-copy fails. As a result, IIS restarts the w3wp process, causing the slot to remain in a “Stopped” state for several minutes, which leads to repeated auto-swap failures, 100% CPU spikes, and long delays.

    The symptoms you mentioned match this issue:

    • The 40% “missing” CPU is due to the staging w3wp not being fully registered
    • The slot frequently switches between Stopped and running states
    • CrashDumpAnalyzer crashes because the dump file is locked by the hung worker process

    To resolve the issue promptly, implementing any of these three options will provide an immediate solution

    1. The recommended and simplest approach is to disable Run-From-Package on the staging slot, and on the production slot if desired. Please add the following app setting to both slots.

      WEBSITE_RUN_FROM_PACKAGE = 0

      This adjustment allows the package to extract as expected, rather than remaining read-only, and fully resolves the locking issue.
    2. If you wish to retain Run-From-Package for its advantages, such as supporting immutable deployments, please include the following:

      MSDEPLOY_RENAME_LOCKED_FILES = 1

      MSDeploy will rename any locked files rather than causing the deployment to fail.
    3. To completely disable shadow-copying, regardless of whether Run-From-Package is used, please add the following setting to your web.config file:
         <hostingEnvironment shadowCopyBinAssemblies="false" />
      

    Reference :

    https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-8.0#shadow-copy

    https://learn.microsoft.com/en-us/azure/app-service/deploy-run-package

    https://learn.microsoft.com/en-us/azure/app-service/deploy-best-practices#handle-locked-files-during-deployment

    https://learn.microsoft.com/en-us/azure/app-service/troubleshoot-http-502-http-503

    Kindly let us know if the above comment helps or you need further assistance on this issue.

    Please "upvote" if the information helped you. This will help us and others in the community as well.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.