Scaling and connection pooling
How many database connections the engine uses, how to size it, and when to add a pooler.
The engine is fast; the database’s connection limit is what you size for.
How many connections
Each engine instance keeps:
- a pool per project database: at most 2 connections when it runs as serverless functions, 10 when it runs as a long-lived server; idle connections close after 30 seconds;
- one connection to the registry when there are many projects (Sypnia Cloud), none when the projects come from a file.
Worst case: instances × (active projects per instance × pool size + 1).
| Database | Usable connections (approx.) | Serverless engine, 1 project |
|---|---|---|
db.t4g.micro (1 GB) | 80 | up to ~25 instances |
db.t4g.small (2 GB) | 190 | up to ~60 instances |
db.t4g.medium (4 GB) | 400 | up to ~130 instances |
On Lambda, reserved concurrency is the dial: it caps instances, so it caps connections. The template sets 5; raise it together with the database.
Adding a pooler
When many projects share one server, or one project needs high concurrency, put a pooler between the engine and Postgres:
- PgBouncer in transaction mode, on a small instance or container. The engine only uses
set localandset_config(..., true)inside transactions, so transaction pooling is safe. - RDS Proxy works too; it is billed by the database’s vCPUs, so it pays off on larger instances.
Long-running mode
The same binary runs as a server (sypnia-data serve) in a container (ECS, Fargate, Kubernetes, a VM). One process shares one pool across all requests, so connections stay low and steady; scale by CPU. Sypnia Cloud moves to this mode as it grows.
What else scales
- CPU: the costliest thing the engine does is argon2id at sign-in (about 100 ms of one core, on purpose). Everything else is a few milliseconds.
- The schema cache is per instance and refreshed on DDL; very large schemas (thousands of tables) take a second to load on a cold instance.