Make the database connection pool size configurable #11

Closed
opened 2026-10-12 14:29:33 +02:00 by pepa · 0 comments
Owner

Part of preparing the app for hosting many customers as one container per customer.

Problem

src/main.rs creates the pool with a fixed max_connections(10). With one instance per customer on a shared PostgreSQL server, a hundred instances may open up to 1000 connections, far above the PostgreSQL default of 100.

Suggested fix

  • Add an optional max_connections key to the [database] section of the config (default 10, so existing installations behave the same), and add it to config_sample.toml.
  • Consider also setting a small min_connections and an idle timeout so idle instances release their connections.
  • Document that many instances on one server need either a low limit per instance or PgBouncer in front of PostgreSQL.

Done when

  • The pool size can be set per instance in the config.
  • Unit test for parsing the new key, with and without it.
Part of preparing the app for hosting many customers as one container per customer. ## Problem `src/main.rs` creates the pool with a fixed `max_connections(10)`. With one instance per customer on a shared PostgreSQL server, a hundred instances may open up to 1000 connections, far above the PostgreSQL default of 100. ## Suggested fix - Add an optional `max_connections` key to the `[database]` section of the config (default 10, so existing installations behave the same), and add it to `config_sample.toml`. - Consider also setting a small `min_connections` and an idle timeout so idle instances release their connections. - Document that many instances on one server need either a low limit per instance or PgBouncer in front of PostgreSQL. ## Done when - The pool size can be set per instance in the config. - Unit test for parsing the new key, with and without it.
pepa closed this issue 2026-10-12 15:47:37 +02:00
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ITsolved/rezervovator#11