|
| 1 | +--- |
| 2 | +title: Database Configuration |
| 3 | +--- |
| 4 | + |
| 5 | +For production deployments, run Permify with PostgreSQL instead of in-memory storage. |
| 6 | + |
| 7 | +## Production Default: Pgcat |
| 8 | + |
| 9 | +For multi-replica Permify deployments, use pgcat in session mode and connect Permify through pgcat. |
| 10 | + |
| 11 | +```yaml |
| 12 | +database: |
| 13 | + engine: postgres |
| 14 | + writer: |
| 15 | + uri: postgresql://postgres:DB_PASSWORD@pgcat:6432/permify?plan_cache_mode=force_custom_plan&default_query_exec_mode=cache_describe |
| 16 | + reader: |
| 17 | + uri: postgresql://postgres:DB_PASSWORD@pgcat:6432/permify?plan_cache_mode=force_custom_plan&default_query_exec_mode=cache_describe |
| 18 | + max_connections: 1 |
| 19 | + min_connections: 0 |
| 20 | +``` |
| 21 | +
|
| 22 | +See full setup guide: [Database Pooling with Pgcat](/setting-up/installation/pooling) |
| 23 | +
|
| 24 | +## Supported PostgreSQL versions |
| 25 | +
|
| 26 | +- PostgreSQL `13.8+` is supported. |
| 27 | +- Permify validates PostgreSQL version during startup and returns an error for older versions. |
| 28 | + |
| 29 | +For Watch API usage, also enable: |
| 30 | + |
| 31 | +- `track_commit_timestamp = on` |
| 32 | +- See Watch API setup: [Watch API requirements](/api-reference/watch/watch-changes) |
| 33 | + |
| 34 | +## Recommended runtime settings (direct Postgres) |
| 35 | + |
| 36 | +```yaml |
| 37 | +database: |
| 38 | + engine: postgres |
| 39 | + uri: postgresql://postgres:DB_PASSWORD@postgres:5432/permify?sslmode=require |
| 40 | + auto_migrate: true |
| 41 | + max_connections: 20 # typical range: 15-25, tune to DB limits and workload |
| 42 | + min_connections: 2 # typical range: 1-3 |
| 43 | + max_connection_lifetime: 30m |
| 44 | + max_connection_idle_time: 5m |
| 45 | +``` |
| 46 | + |
| 47 | +## Related guides |
| 48 | + |
| 49 | +- [Database Pooling with Pgcat](/setting-up/installation/pooling) |
| 50 | +- [Watch API requirements](/api-reference/watch/watch-changes) |
| 51 | +- [Configuration reference](/setting-up/configuration) |
0 commit comments