@@ -131,3 +131,31 @@ If the upgrade fails for any reason, please run the `helm rollback` command and
131
131
132
132
Once you complete this process, you'll be able to access Coder using the
133
133
external IP address of the ingress controller in your cluster.
134
+
135
+ # ## Scaling Coder & PostgreSQL
136
+
137
+ Each Coder replica maintains a pool of connections to Postgres, capped at a
138
+ maximum of 30 connections by default. This value strikes a balance between
139
+ allowing multiple concurrent requests and using up connections on the Postgres
140
+ database.
141
+
142
+ To reconfigure this value, set the environment variable
143
+ ` CODER_MAX_DB_CONNECTIONS` to your desired value in the `coderd.extraEnvs`
144
+ section of the Helm chart.
145
+
146
+ > **Important**: You must ensure that Coder's maximum connections per replica
147
+ > times the number of Coder replicas is less than the maximum number of
148
+ > connections your Postgres instance allows, assuming Coder is the only
149
+ > application using the Postgres instance (less if other applications will also
150
+ > consume connections). For example, with 3 Coder replicas and the default max
151
+ > connections of 30, you must ensure Postgres is configured to allow 90
152
+ > connections. If Postgres runs out of connections Coder may fail API requests
153
+ > or builds.
154
+
155
+ By default, Postgres allows a maximum of 100 open connections (less 3 reserved
156
+ for superusers). Consult
157
+ [Postgres documentation](https://www.postgresql.org/docs/12/runtime-config-connection.html),
158
+ or your database administrator for information on how to change this value.
159
+
160
+ Consider monitoring the [`go_sql_open_connections`](../../admin/prometheus.md)
161
+ metric to see how many connections Coder uses in different load scenarios.
0 commit comments