We used to have service requests that our customers reported slow communications between their applications and db servers. Following I would like to share with you several details to detect where might be the issue that is causing this issue.
The first thing that we need to review 3 things:
- Connection Policy that I'm using: Proxy or Redirect. Redirect should be a better improvement in terms having less latency. If you are using Private Link all the connections, currently, will be Proxy.
- Connection Pooling: It is very important to use a connection pooling to reuse previous connection used and reduce the latency to open a new port every time that I'm connecting to Azure SQL Database. Review this video and link Lesson Learned #38: Which is the impact using connection pooling in my application - Microsoft Community Hub
- To measure the connectivity: I would like to suggest to review this Lesson Learned #240: Checking connection and execution latency in Azure SQL DB and Managed Instance - Microsoft Community Hub if you need to run using Cloud Shell please review this script Lesson Learned #236: What? .... How much time you said? (CloudShell version) - Microsoft Community Hub
Once we have how much is the latency about the connection and we followed the best practices, for example, using for, example, accelerated networking in Virtual Machine that your application is running Lesson Learned #223:Hands-On-Labs: How to improve a bulk insert process - Microsoft Community Hub the next step is to understand if the latency is executing the queries, for example, SQL Server Profiler in Azure Data Studio plugin to review the execution of every one.
Finally, once we checked all these details, the next step is to review the wait stats, we have many articles about it:
- Lesson Learned #301:How to check the performance of my database? Resource Consumption and Wait Stats - Microsoft Community Hub
- Lesson Learned #333: RESOURCE_SEMAPHORE Wait Type - Microsoft Community Hub
- Lesson Learned #339: WAITFOR wait type delay - Microsoft Community Hub
- Lesson Learned #337: HADR_SYNC_COMMIT wait type delay in Azure SQL Database - Microsoft Community Hub
- Lesson Learned #218:Hands-On-Labs: What do I need to do in case of high LOG_RATE_GOVERNOR wait time - Microsoft Community Hub
- Lesson Learned #219:Hands-On-Labs: What do I need to do in case of high CPU wait time - Microsoft Community Hub
- Lesson Learned #325: RESOURCE_SEMAPHORE_QUERY_COMPILE in Elastic Database Pool on Server 'XXX' - Microsoft Community Hub
- Lesson Learned #332: High latency on simple query - Microsoft Community Hub
- Lesson Learned #265: Deadlock due to Non-Optimized Queries - Microsoft Community Hub
- Lesson Learned #286: Compilation vs Execution time running a TSQL query - Microsoft Community Hub
- Lesson Learned #253: Retry Logic for Execution Timeout Expired - Microsoft Community Hub
- Lesson Learned #231: Hands-On-Labs: What is Azure SQL working on - Microsoft Community Hub
- Lesson Learned #224:Hands-On-Labs: Checking the performance with Perf Collector Analyzer - Microsoft Community Hub
- Lesson Learned #195: Performance Best Practices for Azure SQL Database and Managed Instance. - Microsoft Community Hub
- Lesson Learned #230: Microsoft Reactor -Azure SQL Developer and DBA Best Practices (Spanish Version) - Microsoft Community Hub
- Lesson Learned #229: Hands-On-Labs - Connection is busy with results for another command - Microsoft Community Hub
- Lesson Learned #104: Enough to measure CPU,DATAIO and TLOG when you are facing a performance issue? - Microsoft Community Hub
We are continuosly working on other lessons learned about slow communication between our applications and db servers.
Enjoy!