I have a project in Spring Boot (1.5.1.RELEASE) which is using Postgres DB (9.1-901-1).
While I am running this application in production it will create upto 100 number of Idle connection in DB.
So I override the default configuration to control creating 'N' number of idle connection. Please check below configuration:
datasource:
driverClassName: org.postgresql.Driver
url: jdbc:postgresql://localhost:5432/db_name
username: root
password: root
tomcat:
# default value is 100 but postgres' default is 100 as well. To prevent "PSQLException: FATAL: sorry, too many
# clients already", we decrease the max-active value here. Which should be sufficient, by the way
max-active: 10
max-idle: 10
min-idle: 5
max-wait: 30000
time-between-eviction-runs-millis: 5000
min-evictable-idle-time-millis: 60000
jmx-enabled: true
Now Its creating 5 Idle connection to DB.
I am verifying that by executing below query.
select * from pg_stat_activity;
Now My question is, Do I really need 5 Idle connection for Production environment.
What will happen if I change my configuration like below? Will this work without any problem?
max-active: 1
max-idle: 1
min-idle: 0
And also would like to know how PgBouncer will help for this case? Is it necessary to have PgBouncer for Postgres?