As far as I'm aware, in ASP.NET Core when creating SqlConnection
's they are fetched from a pool of already open such connections, as the operation for opening a single connection is very costly and expensive, so we're effectively re-using these connections.
If we have 10 pooled connections but we end up creating 40 of them and querying the database - what exactly will happen? Will the 40 connections effectively go through the pool of 10 available connections in some FIFO basis? Will new connections be created if all of those in the pool are currently in use, similarly to how a new thread gets added to the thread pool?
How exactly does it all work?
The reason for my interest in learning this is to gauge how likely it is to get a socket exhaustion from opening a ton of connections, but first I need to understand how the pool works.