title: Issues with connections to database under low load (dotnet core)
body: <p>I'm trying to load test a basic API, I've started getting some strange issues coming out of the database connection.
  I've now narrowed it down to the SQL connection itself. (I'm using <code>SELECT 1</code> to test connection only)</p>
  
  <p>under very low load (15 calls per second) everything works exactly as expected.</p>
  
  <p>under low load (25 calls per second) the first 4-5 calls come back at an okay speed, then slowing down rapidly. A lot of calls timing out due to no connection in the pool.</p>
  
  <p>under medium load (50 calls per second) everything locks up entirely, nothing comes back. And I start to get strange things like <code>A network-related or instance-specific error occurred while establishing a connection to SQL Server.</code> coming up. Cannot get a connection from the pool again. </p>
  
  <p><code>exec sp_who2</code> on the server shows no connections from dotnet either.</p>
  
  <p>To make it worse the only way to recover from this is to bounce the entire service.</p>
  
  <p>I have ruled out the server itself because this is happening on a powerful SQL server on-prem, an azureSql database, and a local service running on docker.</p>
  
  <pre><code> int selected = 0;
   var timer = Stopwatch.StartNew();
   using (SqlConnection connection = CreateNewConnection())
   {
        try
        {
            connection.Open();
            selected = connection.QueryFirst&lt;int&gt;("SELECT 1");
            timer.Stop();
        }
        catch (Exception e)
        {
            Console.WriteLine("Failed connection");
            Console.WriteLine("fatal    " + e.Message);
            responseBuilder.AddErrors(e);
        }
        finally
        {
            connection.Close();
        }
   }
  
   responseBuilder.WithResult(new {selected, ms = timer.ElapsedMilliseconds});
  </code></pre>
  
  <p>I've even tried disposing, and forcing the connection close manually to understand what is going on.</p>
  
  <p>This is running dotnet core, and dapper (I get the same issues even without dapper)</p>
  
  <p>I've also tried upping the max connection pool limit to absurd numbers like 1000, and there was no effect.</p>
  
  <p><strong>edit</strong></p>
  
  <p>After trying a bit more, I decided to try with Postgres. Which works perfectly at over 1k calls per second. 
  Am I missing something on in sql server itself? or on the connection?</p>
  
  <p>Something to point out, These are shotgun calls. So a batch gets fired off as fast as possible, then wait for each request to return after.</p>
  
  <p>Also this is using linux (and environments are docker k8s)</p>
  
  <p>Someone wanted to know how connections got created</p>
  
  <pre><code>    private IDbConnection CreateNewConnection()
      {
          var builder = new SqlConnectionStringBuilder()
          {
              UserID = "sa",
              Password = "012Password!",
              InitialCatalog = "test",
              DataSource = "localhost",
              MultipleActiveResultSets = true,
              MaxPoolSize = 1000
          };
          return new SqlConnection(builder.ConnectionString);
      }
  </code></pre>
  
  <p><strong>Another note</strong></p>
  
  <p>Not shotgunning (waiting for the previous call to complete, before sending another) seems to have a decent enough throughput. It appears to be something with handling too many requests at the same time</p>
  
  <p><strong>Version Information</strong>
  dotnet <code>2.1.401</code>
  SqlClient <code>4.5.1</code></p>