-
Notifications
You must be signed in to change notification settings - Fork 301
Description
https://hackage.haskell.org/package/persistent-2.7.3.1/docs/src/Database-Persist-Sql-Run.html#createSqlPool calls createPool with 1 stripe and a 20s idle timeout on resources. I would say that
a) This is much too small
and, to contradict myself somewhat
b) There is no one-size-fits-all.
I would at least bump this up to 5 minutes. Anything but a heavily loaded site essentially negates any benefit of using a pool, constantly forming new connections. I've instrumented the use of a 20s timeout in a pool at work, and while we are constantly serving requests, in the last hour we've opened 160 new database connections.
Methodology
I simply added a Prometheus.incCounter call to the function passed to create in resource-pool.
Here is our traffic (average requests/s with a 1h look back)

Here is a a counter of new database connections (average new connections per second).

And here is a graph showing every time the new connection counter increases:
