Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: configurable DB pool size, queue target and queue interval #1689

Merged
merged 9 commits into from
Aug 10, 2020
Merged
16 changes: 16 additions & 0 deletions config/releases.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Config

# This `releases.exs` config file gets evaluated at RUNTIME, unlike other config files that are
# evaluated at compile-time.
#
# See https://hexdocs.pm/mix/1.9.0/Mix.Tasks.Release.html#module-runtime-configuration

config :omg_watcher_info, OMG.WatcherInfo.DB.Repo,
# Have at most `:pool_size` DB connections on standby and serving DB queries.
pool_size: String.to_integer(System.get_env("WATCHER_INFO_DB_POOL_SIZE") || "10"),
# Wait at most `:queue_target` for a connection. If all connections checked out during
# a `:queue_interval` takes more than `:queue_target`, then we double the `:queue_target`.
# If checking out connections take longer than the new target, a DBConnection.ConnectionError is raised.
# See: https://hexdocs.pm/db_connection/DBConnection.html#start_link/2-queue-config
queue_target: String.to_integer(System.get_env("WATCHER_INFO_DB_POOL_QUEUE_TARGET_MS") || "50"),
queue_interval: String.to_integer(System.get_env("WATCHER_INFO_DB_POOL_QUEUE_INTERVAL_MS") || "1000")
3 changes: 3 additions & 0 deletions docs/deployment_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
***Watcher Info only***

- "DATABASE_URL" - Postgres address *mandatory*
- "WATCHER_INFO_DB_POOL_SIZE" - The size of the database connection pool. Defaults to `10`.
- "WATCHER_INFO_DB_POOL_QUEUE_TARGET_MS" - The maximum time to wait for a DB connection in milliseconds. Defaults to `50`.
- "WATCHER_INFO_DB_POOL_QUEUE_INTERVAL_MS" - The interval in milliseconds to determine whether the queue target period above has been exceeded. Defaults to `1000`.

***Erlang VM configuration***

Expand Down