Why do we need to set Min pool size in ConnectionString

前端 未结 2 2016
灰色年华
灰色年华 2021-01-04 03:51

For SQL connection pool, why do we need to set up a min pool size? As connections will be saved in the connection pool and reused, why do we need to keep live connections sp

相关标签:
2条回答
  • 2021-01-04 04:10

    why do we need to keep live connections specified by the min pool size

    As you may know that connection creation is resource intensive job. So, you may chose to set this to a small number such as 5 if your application needs consistent response times even after it was idle for hours. In this case the first user requests won't have to wait for those database connections to establish. You can read the details of pooling here.

    0 讨论(0)
  • 2021-01-04 04:21

    Opening and maintaining connections is expensive, so if you know that you need multiple connections (always) it's better to specify the MinPoolSize because then it's ensured that these connections are available.

    Also, from MSDN:

    If MinPoolSize is either not specified in the connection string or is specified as zero, the connections in the pool will be closed after a period of inactivity. However, if the specified MinPoolSize is greater than zero, the connection pool is not destroyed until the AppDomain is unloaded and the process ends. Maintenance of inactive or empty pools involves minimal system overhead.

    0 讨论(0)
提交回复
热议问题