Open d6y opened 9 years ago
Configuring a connection pool is something that developers often get wrong. There are several, possibly counter-intuitive for some, principles that need to be understood when configuring the pool. https://github.com/brettwooldridge/HikariCP/wiki/About-Pool-Sizing
From the mailing list:
Slick's default is to set HikariCP's maxConnections to 5 times numThreads (see here). So by default, we are running with 20 threads and maxConnections=100.
Is it possible for a Slick thread to use more than one connection at a time? If so, what's the intuition behind having it 5 times - how can we determine the right number for us?
Answered by Stefan:
you can have a connection without an associated thread. This happens whenever you pin a session (e.g. for a transaction or streaming results) and give up the database thread to perform a non-I/O action.
and
It's just an estimate that can and should be changed as needed. The number of threads determines how many things you can run in parallel on the database server and the number of connections determines you many things you can keep in memory at the same time on the database server.
Dave notes: