Azure Web App Instance Swap causes app threads to stop

Stavros Koureas 1 Reputation point
2022-08-24T08:11:12.657+00:00

I have a Blazor app written in .NET6 which is generating threads from system.threading.timer to transfer data from multiple tenant-databases to a single group-database. The Application is running fine for up to 4,5,6 hours and then the threads are stopping without showing any error/exception message on the application side or in the webserver side.

By the way, I know that the threads are not working as I have internal logging inside the application for every start and stop of a thread and also from some table data which seems intact.

My service plan is the S1 with one instance and without auto-scaling. Reading couple of Azure Logs I concluded that the application is swapping instances from one to another while is being loaded (not overloaded) and that causes the threads to top, although from the screenshots below seems that something still is active.

Here is the CPU of the instances, as you can notice an instance swapping is happening around 18:10-18:20
234401-image.png

The time that the instance swap happened the application threads were stopped, this can be seen from the database's instance cpu which manipulates.
234355-image.png

In addition, from Azure WebApp logs seems clearly that instance swapping is happening for real even with one instance configured.
234317-image.png

Here are a few questions:

Does it really perform instance swapping and why?
Does the instance swapping causing threads to stop?
If the above are true, is there any way to generate threads that are handled by multiple instances or during swapping?.

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