I have a website that is hosted on a Linux Web App in Azure. It has an SQL Server, a blob and application insights. For some reason, this site takes a whopping 20+ minutes to boot. I know Umbraco can be slow to boot in Linux, but this is ridiculous on a P2V3 plan.
So I created new resources in Azure as closely matching the original as possible with the idea to reproduce the slow boot time and systematically try different things to find out what is causing the slow boot.
To my surprise, with the same code base, the same blob content, the same database (copy), the boot time is about 20 seconds(!). I have just one theory at this point: because we don’t use docker (yet) and we do a zipDeploy, no files are ever cleaned up because zipDeploys only add or override. And the largest folder by far is the mediaCache. Yes, it should be moved to the blob, but that’s not important right now. (Edit: the media cache folder has 138698 files…)
So I’m wondering: what does Umbraco do with the physical mediaCache files on boot? Do they get loaded in the cache? Does Umbraco run over all the files on boot? I know from the past that the media cache can cause Umbraco to load slowly and since my new environment does not have any media cache files yet and boots so incredibly fast, the media cache files might be the culprit. Any ideas what Umbraco does with the files on boot?
I think try and download the media cache locally and see if that impacts boot time. At that point you can also run a profiler to confirm that this is causing the issue.
Yeah my thoughts exactly, lets see if I can replicate the slow boot reliably. But I know from the past that deleting the media cache files would speed up boot times.
Ok I seem to have found the issue. We use an Azure blob for the media, so we use the Umbraco.StorageProviders.AzureBlob and Umbraco.StorageProviders.AzureBlob.ImageSharp packages and configure Umbraco according to the documentation:
However, we named our container ‘media’ and that seems to be an issue. In the container, a folder ‘media’ and a folder ‘cache’ should be created, but for some reason, when the container is also names ‘media’, the ‘cache’ folder is never created and all cache is placed on the default umbraco/data/temp folder. Because there are so many files, Azure takes a long time to start because it probably needs to copy over all those small files, which takes ages.
Renaming the container to ‘umbraco’ and deleting the umbraco/data/temp files solved all issues and Umbraco boots in 40 seconds now…
Another update; the issue wasn’t the name of the Azure blob container. It was a coincidence with some other changes that made it seem that naming the blob ‘media’ didn’t work.
The real issue is the order in which extensions are registrered in the Program.cs file: