how database connection pool works when multiple instances of same micro service

11/7/2019

I have one microservice with hickaricp+PostgreSQL and its working fine with max connections 20. we planned to do load test with 500 concurrent request with 4 instances of same micro service. My question is how connection pool connections shared across 4 instances and how many max connections should i keep in hickaricp? what all changes have to done in database side to sustain that load?

-- Madhu
connection-pooling
database
kubernetes-pod
microservices

2 Answers

3/20/2020

The max connection pool is per service instance. In this case you have 50, and 4 instances, so the total concurrent transaction that you can do is 50*4 successfully. If you have more transactions then remaining will wait, in which case time out can happen for these extra.

-- Surendra G
Source: StackOverflow

11/7/2019

If you want to have a shared common pool of conections among all the microservices instances to define a maximum number of concurrent connections to the database you must use an external connection pooler like pgbouncer and make all microservices make request to pgbouncer. This way pgbouncer manages the connections and share all of them

-- JArgente
Source: StackOverflow