Should I set max pool size in database connection string? What happens if I don't?
SqlSql Server-2008Connection StringConnection PoolingSql Problem Overview
This is my database connection string. I did not set max pool size until now.
public static string srConnectionString =
"server=localhost;database=mydb;uid=sa;pwd=mypw;";
So currently how many connections does my application support? What is the correct syntax for increasing the connection pool size?
The application is written in C# 4.0.
Sql Solutions
Solution 1 - Sql
Currently your application support 100 connections in pool. Here is what conn string will look like if you want to increase it to 200:
public static string srConnectionString =
"server=localhost;database=mydb;uid=sa;pwd=mypw;Max Pool Size=200;";
You can investigate how many connections with database your application use, by executing sp_who
procedure in your database. In most cases default connection pool size will be enough.
Solution 2 - Sql
"currently yes but i think it might cause problems at peak moments" I can confirm, that I had a problem where I got timeouts because of peak requests. After I set the max pool size, the application ran without any problems. IIS 7.5 / ASP.Net
Solution 3 - Sql
For Spring yml config:
spring:
datasource:
url: ${DB-URL}
driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
username: ${DB-USERNAME}
password: ${DB-PASSWORD}
hikari:
auto-commit: true
maximum-pool-size: 200
or
application-prod.properties file:
spring.datasource.hikari.maximum-pool-size=200
Solution 4 - Sql
We can define maximum pool size in following way:
<pool>
<min-pool-size>5</min-pool-size>
<max-pool-size>200</max-pool-size>
<prefill>true</prefill>
<use-strict-min>true</use-strict-min>
<flush-strategy>IdleConnections</flush-strategy>
</pool>