underscoreio / essential-slick

Essential Slick Pandoc Source
https://underscore.io/books/essential-slick/
39 stars 8 forks source link

Talk of connection poolling somewhere? #43

Open d6y opened 9 years ago

d6y commented 9 years ago

Dave notes:

Slick 3 uses HikariCP by default. You can do nothing and get basic connection pooling for free.

d6y commented 8 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

d6y commented 8 years ago

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.