Menu

SQL Server Connection Pooling in .NET: How It Works and How to Fix Pool Timeouts
📰

SQL Server Connection Pooling in .NET: How It Works and How to Fix Pool Timeouts

DEV Community: dotnet·LingamSuyambu·9 days ago
#dcRvUMok
#devtodotnet#devto#dev#pool#connection
Long article (771 words) — no AI summary yet.
Reading 0:00
15s threshold

Originally published at SQL & Cloud Lab .

This post was drafted with AI assistance.

"Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool." If you have seen this error in a .NET application, the database is usually fine; the application has run out of pooled connections. Understanding how pooling works makes it easy to find the real cause.

How connection pooling works

Opening a physical connection to SQL Server is expensive: network round trips, authentication and session setup. So Microsoft.Data.SqlClient keeps a pool of open connections and reuses them.

When you call Open() , you get an existing connection from the pool if one is free.

When you call Close() or Dispose() , the connection goes back to the pool instead of being closed.

There is a separate pool for each distinct connection string in each process.

By default a pool holds up to 100 connections ( Max Pool Size ).…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.