NealHollingsworth-3512 avatar image
0 Votes"
NealHollingsworth-3512 asked SnehaAgrawal-MSFT commented

Linux App Service stops responding

I've been working on a Flask app (Python 3.8) on Linux. It is currently running on a B1 instance with no other apps. The instance will start without issue, and respond reasonably quickly, but after a short time it appears to stop responding. The app is set to 'Always on', but the log stream shows nothing (no errors, but also no http requests). Some times the app appears to start again and respond as expected, but only after multiple minutes of delay. There doesn't appear to be excessive CPU or memory usage. Am I missing a setting that causes the service to stop? Is there a way to get better logs from the app server (i.e. is it possible requests are not making it to the log stream? Errors from gunicorn? Possible errors from the container?) I'm drawing a bit of a blank on this because there are no apparent errors. Thanks for any help or hints where to look.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

SnehaAgrawal-MSFT avatar image
0 Votes"
SnehaAgrawal-MSFT answered SnehaAgrawal-MSFT commented

Thanks for asking question! You can access the diagnostic logs by accessing the console logs generated from inside the container.
First, turn on container logging by running the below command in the Azure Cloud Shell

az webapp log config --name <app-name> --resource-group myResourceGroup --docker-container-logging filesystem

You can now see the log stream by running below command.

az webapp log tail --name <app-name> --resource-group myResourceGroup

You may also investigate the log files from the browser link: https://<app-name>

To add to this:

  • If the browser has timed out waiting for a response from App Service, this indicates that App Service started the Gunicorn server, but
    the arguments that specify the app code are incorrect.

  • Check that your app is structured as App Service expects for Django or Flask, or use a custom startup command.

  • try capturing a network trace to help identify if responses from the endpoint are slower than expected.

  • If high number of processes are waiting for CPU consider scaling up to a higher SKU.

You may refer to this official doc link:

Let me know if issue persists.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I've enabled all the logging that I can find, and even turned the gunicorn logging level to debug. The result is less than helpful. After some amount of time (it seems to be random but on the order of minutes) something in the stack is failing. The app starts correctly, and will serve pages for a while with out significant delay, but after some amount of time it will respond with a 504, 502, or similar error. No information is logged indicating an error. The server stack simply stops responding. Is there a way to obtain higher log levels from Nginx?

As best I can tell there are only about 4 or 5 processes waiting at any given time (it fluctuates). I have not been able to get a network trace once the server stops responding.

0 Votes 0 ·

Could you please send an email to AzCommunity[at]Microsoft[dot]com referencing this thread, with your subscription ID we would like to work closer with you on this matter.

0 Votes 0 ·