From 06fc9c9634d06450dd837ed19ba7b922e73f60fc Mon Sep 17 00:00:00 2001 From: Spike Curtis Date: Wed, 30 Nov 2022 21:27:45 +0000 Subject: [PATCH 1/3] Add docs explaining max postgres connections Signed-off-by: Spike Curtis --- guides/deployments/postgres.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/guides/deployments/postgres.md b/guides/deployments/postgres.md index fbf620af2..6441157c0 100644 --- a/guides/deployments/postgres.md +++ b/guides/deployments/postgres.md @@ -131,3 +131,31 @@ If the upgrade fails for any reason, please run the `helm rollback` command and Once you complete this process, you'll be able to access Coder using the external IP address of the ingress controller in your cluster. + +### Scaling Coder & PostgreSQL + +Each Coder replica maintains a pool of connections to Postgres, capped at a +maximum of 30 connections by default. This value strikes a balance between +allowing multiple concurrent requests and using up connections on the Postgres +database. + +To reconfigure this value, set the environment variable +`CODER_MAX_DB_CONNECTIONS` to your desired value in the `coderd.extraEnvs` +section of the Helm chart. + +> **Important**: You must ensure that Coder's maximum connections per replica +> times the number of Coder replica is less than the maximum number of +> connections your Postgres instance allows, assuming Coder is the only +> application using the Postgres instance (less if other applications will also +> consume connections). For example, with 3 Coder replicas and the default max +> connections of 30, you must ensure Postgres is configured to allow 90 +> connections. If Postgres runs out of connections Coder may fail API requests +> or builds. + +By default, Postgres allows a maximum of 100 open connections (less 3 reserved +for superusers). Consult +[Postgres documentation](https://www.postgresql.org/docs/12/runtime-config-connection.html), +or your database administrator for information on how to change this value. + +Consider monitoring the [`go_sql_open_connections`](../admin/prometheus.md) +metric to see how many connections Coder uses in different load scenarios. From ab931e154f6c89704401ccb967dd25bcbe8bfd60 Mon Sep 17 00:00:00 2001 From: Spike Curtis Date: Wed, 30 Nov 2022 21:30:22 +0000 Subject: [PATCH 2/3] Fix typo Signed-off-by: Spike Curtis --- guides/deployments/postgres.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/deployments/postgres.md b/guides/deployments/postgres.md index 6441157c0..64fdabd65 100644 --- a/guides/deployments/postgres.md +++ b/guides/deployments/postgres.md @@ -144,7 +144,7 @@ To reconfigure this value, set the environment variable section of the Helm chart. > **Important**: You must ensure that Coder's maximum connections per replica -> times the number of Coder replica is less than the maximum number of +> times the number of Coder replicas is less than the maximum number of > connections your Postgres instance allows, assuming Coder is the only > application using the Postgres instance (less if other applications will also > consume connections). For example, with 3 Coder replicas and the default max From 0f7e102f7ce85613951591dac86674c766dc52a3 Mon Sep 17 00:00:00 2001 From: Spike Curtis Date: Wed, 30 Nov 2022 21:33:38 +0000 Subject: [PATCH 3/3] Fix broken link Signed-off-by: Spike Curtis --- guides/deployments/postgres.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/deployments/postgres.md b/guides/deployments/postgres.md index 64fdabd65..2dd1f2504 100644 --- a/guides/deployments/postgres.md +++ b/guides/deployments/postgres.md @@ -157,5 +157,5 @@ for superusers). Consult [Postgres documentation](https://www.postgresql.org/docs/12/runtime-config-connection.html), or your database administrator for information on how to change this value. -Consider monitoring the [`go_sql_open_connections`](../admin/prometheus.md) +Consider monitoring the [`go_sql_open_connections`](../../admin/prometheus.md) metric to see how many connections Coder uses in different load scenarios.