Azure SQL frequent connection timeouts

Viewed 7784

We're running a web app (2 instances) on Azure, backed by a SQL Azure database. At any given time there are 50-150 users using the website. The database runs at S2 performance level. The DTU is around 20% on average.

However, a few times every day I suddenly get hundreds of errors in my logs with timeouts, like this:

An error occurred while executing the command definition. See the inner exception for details.

The wait operation timed out.

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. This failure occurred while attempting to connect to the routing destination. The duration spent while attempting to connect to the original server was - [Pre-Login] initialization=1; handshake=21; [Login] initialization=0; authentication=0; [Post-Login] complete=1;

We're using EF6 for queries with the default command timeout. I've configured this execution strategy:

SetExecutionStrategy("System.Data.SqlClient", 
            () => new SqlAzureExecutionStrategy(10, TimeSpan.FromSeconds(15)));

The database (about 15GB total) is heavily indexed. These errors occur all over the place, usually dozens to hundreds within 1-2 minutes.

What steps can I take to prevent this from happening?

1 Answers
Related