Database Connection Pool Sizing & Concurrency Headroom Calculator
calculate_pool_headroomCalculate optimal connection pool sizing, idle timeouts, and client headroom from server RAM and concurrency profiles to prevent PgBouncer, HikariCP, or Prisma pool out-of-memory crashes.
Instructions
Calculates optimal connection pool sizing, idle timeouts, and client headroom based on server RAM and concurrency profile. Use when sizing PgBouncer, HikariCP, or Prisma connection pools to avoid server out-of-memory crashes; for checking transaction isolation hazards, use audit_transaction_isolation instead. Stateless read-only edge call (max 32 KB, 60 RPM): accepts 'server_ram_mb' and 'max_concurrent_clients' ('workload_profile' defaults to 'high_concurrency_oltp'), supports '?demo=true' or L402 (10 sats), and returns HTTP 400 if invalid.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| server_ram_mb | Yes | Total available RAM in megabytes dedicated to the database server instance. | |
| workload_profile | No | Workload operational characteristics: high-concurrency OLTP, heavy analytical OLAP, or serverless edge burst. | |
| max_concurrent_clients | Yes | Peak anticipated concurrent client connections or serverless worker threads. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| memory_headroom_mb | Yes | Estimated unallocated memory buffer in megabytes remaining for query sorting. | |
| recommended_min_idle | Yes | Recommended standby idle connection count for warm latency response. | |
| connection_timeout_ms | Yes | Recommended pool connection acquisition timeout in milliseconds. | |
| recommended_max_connections | Yes | Calculated optimal max pool size to avoid database thrashing and memory exhaustion. |