Slow platform v3 start on Azure App Service

There is an Azure-specific problem: the platform can start very slow on Azure App Service. This problem is seemingly unstable: sometimes the platform starts normally and sometimes even not at all.
In case if not started the user will see at the platform admin page errors like: “Service Unavailable”, “500.37 ANCM Failed to Start Within Startup Time Limit”.
The causes of such behavior are:

  1. The platform does a lot of work every start: check modules versions, files in probing path, copy modules files to probing path if they absent or have inappropriate versions, and so on.
  2. But the Azure storage is really very slow when it works with multiple access to many relatively small files.

We’ve done small research to ensure the storage slowness.
To illustrate the problem we wrote a very simple example that creates copies of some relatively small file (~150KB) 1000 times and prints the time taken. This application was run on different plans several times to eliminate performance fluctuations.
For different service plans the times taken (in seconds) are:

Run No B1 S3 P1v2 Local (SSD)
1 00:00:18.8450372 00:00:14.6353618 00:00:11.2104404 00:00:01.8153389
2 00:00:17.7225685 00:00:13.9479451 00:00:11.2437652 00:00:01.7990957
3 00:00:16.9386537 00:00:14.0766875 00:00:11.3728342 00:00:01.8051906
4 00:00:20.0357201 00:00:15.5558658 00:00:11.4233102 00:00:01.8282917
5 00:00:18.4655201 00:00:13.3437957 00:00:10.9581675 00:00:01.8282917

Times in the last column was measured on a local machine and given for comparison.
As you can see, more powerful plans accelerate IO operations, but the speed much slower than just on a local machine with SSD storage.

What is the solution?

  1. From v3.27.0 there is an option VirtoCommerce:RefreshProbingFolderOnStart to avoid checking the probing path at the platform startup. This can decrease startup time at least by a third. If the option set to false and the probing path exists, the platform will start with the current probing path content on an “AS IS” basis. It is assumed that the probing path contains consistent module files. If the probing path is absent, then the platform will start as usual, with module discovering/copying, with no look at the option value.
  2. Of course, you can also just increase startup timeout in web.config by setting startupTimeLimit to a bigger value.
  3. Strong recommendation to use premium plans with dedicated SSD.