Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
add to doc
Thiago Araujo da Silva8affbd4a718d
diff --git a/docs/self-hosting/configuration/envars.mdx b/docs/self-hosting/configuration/envars.mdxindex adfd0c011c..ae3d31b346 100644--- a/docs/self-hosting/configuration/envars.mdx+++ b/docs/self-hosting/configuration/envars.mdx@@ -242,6 +242,64 @@ DB_READ_REPLICAS=[{"DB_CONNECTION_URI":""}]</Expandable></ParamField>+#### Connection pool sizing (Optional)++Each Infisical instance keeps its own pool of Postgres connections. The defaults suit a small deployment and+most self-hosters never need to change them, but they become relevant once you run many instances: pools are+**per instance**, so the total number of connections your database sees grows with your instance count.++Work out your total like this:++```+per instance = DB_POOL_MAX+ + (DB_REPLICA_POOL_MAX x number of read replicas)+ + AUDIT_LOGS_DB_POOL_MAX (only if AUDIT_LOGS_DB_CONNECTION_URI is set)++total = per instance x number of instances+```++Then compare that total against your database's `max_connections` (`SHOW max_connections;`). Two things are+easy to miss:++- **Rolling deploys briefly double the total.** Old and new instances both hold pools while the rollout+ completes, so size against roughly twice your steady-state number.+- **Autoscaling sets the ceiling, not your current instance count.** If you autoscale, do the math with the+ maximum replica count, not today's.++Aim to keep the peak comfortably under `max_connections`, leaving headroom for migrations, admin tools, and+your own `psql` sessions. If you are close to the limit, **lower `DB_POOL_MAX`** rather than raising+`max_connections`: each Postgres connection costs memory on the server, and a large number of mostly-idle+connections wastes it. If instead you see queries queueing while your database is idle, the pool is too small+and raising it is the right move.++<Tip>+ Prefer scaling reads with `DB_READ_REPLICAS` over enlarging the primary pool. A connection pooler such as+ PgBouncer or RDS Proxy is only worth the extra hop and failure domain once instance count alone pushes you+ near `max_connections`, and note that a pooler in transaction mode does **not** reclaim connections held+ open inside a transaction.+</Tip>++<ParamField query="DB_POOL_MIN" type="int" default="0" optional>+ Minimum connections kept open in the primary database pool. `0` lets idle connections close, which is+ usually what you want. Raise it only to avoid connection-setup latency on bursty traffic, and be aware that+ a non-zero value holds connections open on the server even while the instance is idle.+</ParamField>++<ParamField query="DB_POOL_MAX" type="int" default="10" optional>+ Maximum connections in the primary database pool. Must be at least `1` and greater than or equal to+ `DB_POOL_MIN`.+</ParamField>++<ParamField query="DB_REPLICA_POOL_MIN" type="int" default="0" optional>+ Minimum connections kept open per read replica pool. Applies to each replica in `DB_READ_REPLICAS`+ individually.+</ParamField>++<ParamField query="DB_REPLICA_POOL_MAX" type="int" default="10" optional>+ Maximum connections **per read replica**. With three replicas and the default of `10`, each instance can+ open up to 30 replica connections in addition to its primary pool.+</ParamField>+### Audit Log PostgreSQL (Optional)<ParamField query="AUDIT_LOGS_DB_CONNECTION_URI" type="string" optional>@@ -252,6 +310,16 @@ DB_READ_REPLICAS=[{"DB_CONNECTION_URI":""}]Base64-encoded CA certificate for the audit log PostgreSQL database connection. Only needed if `AUDIT_LOGS_DB_CONNECTION_URI` is set.</ParamField>+<ParamField query="AUDIT_LOGS_DB_POOL_MIN" type="int" default="0" optional>+ Minimum connections kept open in the audit log database pool. Only used when+ `AUDIT_LOGS_DB_CONNECTION_URI` is set.+</ParamField>++<ParamField query="AUDIT_LOGS_DB_POOL_MAX" type="int" default="10" optional>+ Maximum connections in the audit log database pool. Only used when `AUDIT_LOGS_DB_CONNECTION_URI` is set.+ This pool is separate from the primary pool, so it adds to your per-instance total.+</ParamField>+### ClickHouse (Optional)ClickHouse can be used as an alternative audit log storage backend for high-volume deployments. See the [ClickHouse Setup Guide](/documentation/platform/audit-logs-clickhouse-setup) for more details.diff --git a/docs/self-hosting/deployment-options/aws-native.mdx b/docs/self-hosting/deployment-options/aws-native.mdxindex d13b6fc63c..c7207b1d4a 100644--- a/docs/self-hosting/deployment-options/aws-native.mdx+++ b/docs/self-hosting/deployment-options/aws-native.mdx@@ -1354,7 +1354,9 @@ After completing the above steps, your Infisical instance should be running on A- Scale ECS tasks horizontally (increase desired count)- Scale RDS vertically (larger instance class)- Enable RDS Performance Insights for query analysis- - Consider connection pooling (PgBouncer)+ - Tune the per-task connection pool with [`DB_POOL_MAX`](/self-hosting/configuration/envars#connection-pool-sizing-optional). Connection pools are per task, so `DatabaseConnections` scales with your task count and rolling deploys briefly double it. Lowering `DB_POOL_MAX` is usually the cheaper fix.+ - Offload reads to replicas with `DB_READ_REPLICAS`+ - Consider a connection pooler (RDS Proxy or PgBouncer) only once task count alone pushes you near `max_connections`</Accordion><Accordion title="ECS Exec not working">