Slow Database Connection from Azure Web Application

后端 未结 3 1213
被撕碎了的回忆
被撕碎了的回忆 2021-01-18 07:40

I have developed a Web Application a standard web application to allow users to display and update a set of data from an SQL database.

The Web Application uses a An

相关标签:
3条回答
  • 2021-01-18 07:55

    15 minutes is too short for your app to be recycled (as suggested by CSharpRocks). I dont think its the issue here.

    The delay is because a new Db connection is established upon first call after idle timeout. Typically if a connection is inactive for 4-10 minutes it will be closed. If a minimum pool size is specified, those connections will be kept alive even after idle timout expires.

    Try using this connection string (adjust min pool size as per your needs)

    <add name="DevFEConnectAdo" connectionString="data   
    source=feeunsqldevfeconnect.database.windows.net;initial 
    catalog=feeunsqldbdevfeconnect;persist security info=True;user id=???
    @???;password=???;multipleactiveresultsets=True;Min Pool Size=3;Load Balance Timeout=180;"></add>
    

    Further details Why do we need to set Min pool size in ConnectionString

    List of SQL Connection Properties - documentation

    0 讨论(0)
  • 2021-01-18 08:05

    Web apps are recycled after a few minutes of inactivity. Try enabling the Always On setting located in Settings/Application Settings in the portal to see if this helps with your issue.

    0 讨论(0)
  • 2021-01-18 08:14

    After some time, this eventually got resolved with some help from Microsoft Azure support.

    The detail that I left out was that my Web App was actually pointing to 2 databases - 1 the Application Azure SQL database, I was having the delay problem with - A 'Data Warehouse' we had on an Azure Virtual Machine

    Because of replication between inhouse database servers and the 'Data Warehouse' the Virtual Machine and Web App were all in a Azure Virtual Network.

    The problem was there can be network problems if a Web App inside a Virtual network wants to talk to Azure SQL Databases (which cannot be within a Virtual Network).

    My solution was to

    • configure an Endpoint on the Data Warehouse Virtual Server,
    • take the Web App out of the Virtual network and make it point to the Virtual Server by means of the Endpoint

    At this point all the delays went away and I could take off the MinPool Size settings (and Timeout which I later discovered did nothing anyway).

    0 讨论(0)
提交回复
热议问题