PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, April 21, 2022

[FIXED] Why is connecting to SQL Server very slow?

 April 21, 2022     c#, connection, sql-server     No comments   

Issue

We see that creating new connections takes about 250 milliseconds, which is much slower than expected.

From our application server to the SQL Server, we have about 1 millisecond ping-time, and we are operating inside pretty fast LAN.

Our connection string is:

Data Source=SQLServer;Initial Catalog=Database;Integrated Security=True

I have measured elapsed time around this simple statement

var conn = new SqlConnection(_connectionString);

if (conn.State == ConnectionState.Closed)
{
    var sw = Stopwatch.StartNew();
    await conn.OpenAsync().ConfigureAwait(false);
    sw.StopAndLogIfDelay(20, _log, "Open SQL Server connection");
}

I would not expect 250 milliseconds to connect in a fast LAN. Does anyone have ideas or experience in where the problem could be?


Solution

Setting minimum connections to 50 in th sql-server connection pool solved the immidate problem.

What remains is to investigate why open db-connections takes such a long time in our organisation. I will ally with our network-team to see if we can locate the problem.



Answered By - Torben Nielsen
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing