Why is my Django Web App with Azure Database for Postgresql slow?

Octopi Nederland B.V 1 Reputation point
2020-12-30T13:50:37.153+00:00

In the past week we have set up a Django web app on Azure App Service which connects to an Azure Database for Postgresql. However, it seems to be very slow for even the most basic API calls (we use Django Rest Framework). Basic API calls take at least 2 seconds but sometimes even take up to 7 seconds from the browser's point of view.

Please note the following:

  • The Azure Web App runs a B1 instance in West-Europe
  • The Azure Database for Postgresql runs Basic 1 VCore and 5GB storage in West-Europe
  • The Azure Database tables contain either no rows or less than 5 rows
  • The web app and the database are part of the same resource group
  • Our subscription is the one month free trial
  • Locally, the most basic API calls have a response time of 20ms from the browser's point of view
  • On Heroku free dyno with Postgresql database, the most basic API calls have a response time of at most 250ms from the browser's point of view

We have looked at the following:

  • Query performance is below 100ms for most queries. Also checked for latency issues by running \timing select; \watch 1 from the web app through Kudu. The result was below 2ms which seems about right according to Azure documentation: https://azure.microsoft.com/es-es/blog/performance-best-practices-for-using-azure-database-for-postgresql/
  • CPU usage for Azure Database never tops 10%
  • CPU usage for Azure Web App never tops 25%
  • Memory usage for Azure Web App never tops 70%
  • The setting Always On is enabled
  • Checked web logs, but since the requests just return 200OK no exceptions are observed.

We have spent the past few days going through documentation on performance issues but none of them seem to work. Since we ran out of ideas to try we would like to request for help through this forum.

Azure Database for PostgreSQL
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,021 questions
{count} votes

2 answers

Sort by: Most helpful
  1. brtrach-MSFT 16,686 Reputation points Microsoft Employee
    2020-12-31T07:08:45.18+00:00

    @Octopi Nederland B.V Wow, thank you for including all of the details and troubleshooting steps that you have already tried. It seems like you have already tried the obvious methods to troubleshoot and have followed best practices when setting up the web app.

    Troubleshooting performance issues in the cloud can be difficult as there are a number of issues that can impact performance and in many cases, there is not a performance SLA.

    With that being said, one final thing that we suggest to you is to navigate to your web app in the Azure portal and select the 'diagnose and solve' blade of your web app. From there, run the 'availability and performance' test and then check the 'web app slow' results. Is there anything in there that stands out to you?

    If not, then you have already gone through all the able approaches to troubleshooting performance that we can provide on the forum. If the diagnose and solve blade did not address the matter, please email me at azcommunity@microsoft.com with a subject of ATTN: Bryan and then in the body include your Azure Subscription ID and the URL of this post.

    We look forward to your reply.


  2. huxaiphaer idris 6 Reputation points
    2022-12-12T18:25:16.563+00:00

    @Octopi Nederland B.V , Did you get a final solution? Am facing a similar issue.

    0 comments No comments

Your answer

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