Long time to load first sql connection in .NET.

For some reason, it takes 7 seconds to open a connection to a SQL Server database, subsequent connections come in second. any idea what could be the reason?

I am using C # and asp.net

Its after compilation, I am the entity every time I restart the site, which means that every time it needs to actually create the "first" connection. I understand that setting up a connection pool has an overhead, but I've never seen that I have to take 7 seconds to set it up.

+2


source to share


3 answers


Besides pooling and compiling the CLR, remember that the data and plan caches on the database server can also be cold ...



I've seen first calls on a very "cold" website take 5-10 seconds to respond to a button press (like "search") to data ending on the screen.

+1


source


The first time you need to establish a connection, which has a lot of overhead. Each subsequent connection uses a connection pool (assuming you have the same connection string) and no initial setup is required.



Edit: See this link or this one for information on connection pooling.

+1


source


is it after compilation every time? Is the "timeout" a result of the JIT compilation and not the SqlConnection itself?

0


source







All Articles