DocsFeatures
View as MarkdownScaling and high availability
Autoscaling and scale to zero on Free and Launch, storage autoscaling on Dedicated, moving between plans, read replicas, pooling, high availability across data centers and PostgreSQL settings.
KeelDB scales in two ways, and uses these names for them:
| Name | What changes | Plans | Restart |
|---|---|---|---|
| Autoscaling | CPU and memory of the running database, live | Free, Launch | None |
| Storage autoscaling | The size of the disk, online | Dedicated (Free and Launch pay per GB up to their limit) | None |
A Dedicated database keeps the size you chose; KeelDB does not resize it by itself.
Autoscaling on Free and Launch
Free, Launch and Scale databases are sized in compute units: 1 CU = 1 vCPU and 4 GB of RAM (on Scale the vCPU is guaranteed). The autoscaler moves each database between the minimum and maximum of its range, in these steps: 0.25, 0.5, 1, 1.5, 2, 3, 4, 6, 8, 10, 12, 14 and 16 CU.
| Plan | Minimum | Maximum | Notes |
|---|---|---|---|
| Free | 0.25 CU | 2 CU | Above 0.5 CU only while the shared server has room. Uses its own 100 CU-hours a month, within the organization's 300 |
| Launch | 0.25 CU, or the minimum you choose | 2 CU by default, up to 16 CU as the elastic pool has room (4 until your first paid invoice) | Billed per CU-hour |
| Scale | 0.25 CU, or the minimum you choose | 4 CU by default, up to 16 CU as the elastic pool has room (4 until your first paid invoice) | Billed per CU-hour, a full vCPU guaranteed per CU |
The elastic pool. Free, Launch and Scale databases run on a pool of shared servers in US East that grows and shrinks by itself. A sleeping database holds only its data on its server; a running one holds what it runs. When paying customers need room the pool adds a server, from collected revenue or within the budget KeelDB sets aside for it, and when servers stay mostly idle it moves whole projects (a database with its branches) to the others and removes one, at most one server a day; a move never deletes the old copy before the new one has run. A database moves by a restore from its backups onto the other server, so it is offline while that runs (about 30 seconds plus about 17 seconds per GB of the project's data). The pool first removes a server whose databases are all asleep. A database that is awake when its server is removed gets up to 20 minutes to fall asleep and then moves while asleep; if it stays awake (a Scale database whose scale to zero is set to never, for example), it turns read-only for about a minute while its last changes are archived, so no committed change is lost, and then is offline while it is restored. A database grows within the free room of the server it runs on; a minimum larger than our smallest server starts is placed on a larger server the pool adds for it. Free databases never make the pool add a server.
How it decides, every few seconds:
- Up, at once: when CPU use is above 85% of the allocation, or the memory working set is above 75% of it, or the database is under CPU or memory pressure. It can jump several steps.
- Down, one step at a time: after 5 quiet minutes for CPU and 15 for memory, at least 2 minutes after any change and 5 minutes after an increase, and only when the working set fits easily in the smaller size.
- Short bursts need no scaling: a database has no CPU cap, so it can use idle CPU on its server for a moment while its allocation guarantees its share.
- After running out of memory, the database keeps at least one step more than the size it ran out at for 24 hours. If it ran out at the warm size (see below), it stays at its minimum and skips the warm size for 24 hours instead. If it happens twice at the maximum within a day, the database's Activity log says so.
- Room on the server: an increase never takes more than the server has free; the activity log says
capacity_limitedwhen it held one back, and the database grows further as room frees on its server. A Free database above 0.5 CU goes back to 0.5 CU when its server is busy or a paid database there needs the room. - Spend limit: on Launch and Scale, when a hard spend limit applies (one you turned on, or the new organization limit before the first paid invoice), increases stop where they would pass it (
budget_limitedin the activity log), and at the limit a database above its minimum goes back to its minimum at once. With alerts only, the default once you have paid an invoice, nothing stops. - Free CU-hours: when a Free database has fewer than 10 of its 100 CU-hours left, or its organization fewer than 10 of its 300, the database goes back to 0.5 CU at most.
The Metrics charts on the database's Overview page show the CPU and memory it uses against its allocation, minute by minute; the same data comes from GET /databases/{id}/metrics/compute. Autoscaling never restarts the database.
The range
Free databases always scale between 0.25 and 2 CU. A Launch database scales between 0.25 and 2 CU, and a Scale database between 0.25 and 4 CU, unless you choose another range in its Settings, or with min_cu and max_cu in the API:
- each end is one of the steps 0.25, 0.5, 1, 1.5, 2, 3, 4, 6, 8, 10, 12, 14 or 16 CU, the maximum at most 8 CU above the minimum, and at most 4 CU until your organization's first paid invoice;
- the minimum sets the settings that need a restart and what an always-on database costs at least, so a new range restarts PostgreSQL once, and it must fit your spend limit when one applies;
- the maximum is a ceiling, not a promise: up to 16 CU as the elastic pool has room. When the pool can give one database less, the console's range picker and
GET /plansoffer the lower maximum ("more when shared capacity grows"), and a larger maximum is refused; the database grows within the free room of the server it runs on, and stays at its size while that server is full; - the minimum is what the database starts and wakes at, so it must fit within the room a server keeps for starting databases: three quarters of what one server sells, rounded down to a step, on a server the pool runs or one it can add for you. A minimum no such server starts is refused with the most you can choose now.
Scale to zero
| Plan | Behavior |
|---|---|
| Free | Always: after 5 idle minutes the database shrinks to a small warm size; after 60 more idle minutes it sleeps fully |
| Launch | The same by default. Choose another idle time (1 minute or more) or never |
| Dedicated | Never. Dedicated databases are always on |
- Idle means no client connections. A client connected through the
-poolerhost counts as long as it stays connected. - The warm size keeps the database's memory warm on a fraction of a CPU, so the next connection only has to grow it back. It always keeps room for the database's buffer cache (a quarter of the minimum size's memory). On Launch it is billed at its CU equivalent (about 0.125 CU at the 0.25 CU minimum) for at most 60 minutes.
- A full sleep stops the database. The next connection wakes it: the proxy holds the connection until the database is ready, so clients only see a slower first connection. See Waking a sleeping database.
- Caches refill after a wake, a restart or a failover, because every database preloads the pages it used before (
pg_prewarm). - A sleeping database holds only its storage, so a shared server holds many more databases than run at once. When a server gets busy (more than 70% of what it can run), Free databases that have been idle at the warm size for more than 10 minutes sleep fully sooner, oldest first. Launch databases keep their warm size. New databases are admitted only while a quarter of each server stays free for sleeping databases to wake into, and a server's memory is never promised twice.
With the API, on Launch:
curl -X PATCH https://keeldb.com/api/v1/databases/k7m2x9qa4pz1 \
-H "Authorization: Bearer $KEELDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"scale_to_zero_minutes": 15, "on_limit": "hold_min"}'scale_to_zero_minutes: null keeps the database always on. on_limit decides what happens at a hard spend limit, when one applies: hold_min keeps the database at its minimum, suspend stops it.
While a Free or Launch database sleeps, operations such as restart and backup return 409 conflict. Connect to it to wake it.
Storage
- Free: 1 GB per database, shared with its branches (the database's data, what each instant branch has written on its own, and all the data of a point-in-time branch or a branch from a snapshot); Free branches don't count toward the organization's 10 Free databases. At the limit the database and its branches become read-only.
- Launch: you pay for what you store, up to 100 GB per database (lower while a smaller cloud server is part of our shared fleet, as the console shows); each branch has the same limit. At the limit it becomes read-only.
- Dedicated: each size includes storage, and storage autoscaling grows the disk as you need it, up to the size's maximum storage (2 TB at most). Storage above the included amount is billed per provisioned GB.
When a database becomes read-only at a limit, writes fail with an error and reads keep working. The console explains why and what to do: free space, or move to a plan or size with more room. Space comes back only when data is really removed, for example by dropping a table you no longer need; DELETE marks rows as free for reuse but does not shrink the files.
Storage autoscaling on Dedicated
On by default. Every minute KeelDB checks each disk:
- It grows the disk when it is 80% full, or when the trend of the last 6 hours would reach 90% within 6 hours.
- The new size is the largest of: 1.25 times the current size, the used space divided by 0.65, and the current size plus 10 GB, rounded up to 10 GB. It never passes the size's maximum storage.
- Disks grow online, without a restart. They never shrink, because no provider can shrink a disk.
- All copies of an HA database grow together.
- We alert you at 85%, 90% and 95% of the maximum. At 95% of the maximum the database becomes read-only so it never runs into a full disk; free space to continue, and contact support if you need more room.
Turning storage autoscaling off, or choosing a maximum below the size's, is not available yet.
Change plan, size or topology
Change a database's plan, size or topology from its Settings page, or with the API:
curl -X PATCH https://keeldb.com/api/v1/databases/k7m2x9qa4pz1 \
-H "Authorization: Bearer $KEELDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"plan": "dedicated", "size": "perf-8", "topology": "ha2"}'A change keeps the same database id, hostnames and credentials.
- Between Free and Launch, the change is applied to the running database and PostgreSQL restarts once with the new limits.
- To, from or within Dedicated, today, the change is also applied in place with one restart of PostgreSQL: Dedicated databases run on KeelDB's shared servers with their vCPU and memory reserved until Dedicated servers open. The answer's
noticesays so.
Once Dedicated servers open
A move between the shared servers and Dedicated servers then copies your data, and the API answers 202 with the move (see Move to another plan):
- From Free or Launch to Dedicated, KeelDB creates the Dedicated servers and copies your data to them while your database keeps serving reads and writes, which takes about 1.5 hours per TB. When the copy has caught up, KeelDB switches over: new connections wait for a few seconds, writes pause, open sessions are closed, and clients reconnect to the same hostname. The old copy stays as a read-only copy for 24 hours so the move can be rolled back, then it is deleted.
- From Dedicated back to Launch, the same in the other direction: a Launch copy follows the Dedicated database until it has caught up, then KeelDB switches over. At the switch the Dedicated servers are deleted; the primary's storage volume is kept for 24 hours, then deleted. A database that moved to Dedicated less than 7 days ago may have to wait until the backups of its earlier time on Launch are deleted; the move says so in its
error. - Cancel a move before its switch-over from the Settings page, with
DELETE /api/v1/databases/{id}/move, or with the MCP toolcancel_tier_move.
Billing: the old plan is billed until the switch, the new one from then on (a Dedicated target from the moment its servers exist, once it is ready). If we fail or cancel the copy, the target is not billed. If you cancel the move, or delete the database during it, after its Dedicated servers exist, their started hours are billed, as for a Dedicated database deleted before it was ready; the console says which applies before you confirm.
Changing the size or topology of a Dedicated database on its own servers is not available yet: create a new database with the size you want and copy your data (see Migrate), or contact support.
Rules:
- A move to Launch needs the data to fit in 100 GB. A Launch database moves back to Free with its branches when they fit Free (Moving back to Free).
- A move to Dedicated needs the data to fit in the size's maximum storage.
- Moves to a paid plan need a payment method and count toward the limits for new organizations.
- One move at a time. A database with branches, or one that is not running, can't move to or from Dedicated; delete its branches first.
- A database with snapshots, or with a backup schedule on, can't move: its snapshots are kept with the copy the move retires. Delete them (restore one into a new database first to keep it) and turn the schedule off. Until a move has switched over, new snapshots and schedules are refused; cancel the move before its switch-over to take one sooner.
- A size or topology that can't be placed right now shows
waiting for capacity.
Read replicas
Launch and Dedicated databases can have up to 3 read replicas: extra read-only copies that stream changes from the primary. The -ro host spreads connections across them. On ha2 and ha3, the standbys serve the -ro host too, even with no replicas.
curl -X PATCH https://keeldb.com/api/v1/databases/k7m2x9qa4pz1 \
-H "Authorization: Bearer $KEELDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"read_replicas": 2}'- Billing: on Launch, replicas use CU-hours (a replica's minimum is half the primary's); on Dedicated, each replica is one more node of the database's size.
- On Dedicated, replicas are spread across data centers where possible.
- Replicas can lag behind the primary. Send reads that must see the latest write to the primary.
- A new replica is copied from the primary.
Connection pooling
Every database has a PgBouncer pooler in transaction mode on its -pooler host, on by default. It lets thousands of short-lived clients share a small number of PostgreSQL connections: 1,000 clients on Free, 10,000 on Launch and Dedicated. HA databases run one PgBouncer per copy.
Turn it off from Settings or with {"pooler_enabled": false}. While it is off, the -pooler host connects directly to the primary. See Connecting for transaction mode caveats and Connection limits for pool sizes.
High availability
High availability is a Dedicated feature. Each HA topology keeps its copies in different data centers of the region, so losing a whole data center does not lose the database.
In US East, ha2 keeps its two copies in two availability zones of AWS in Northern Virginia, once Dedicated servers open; until then the size picker shows it as waiting for capacity, because reserved capacity holds one copy. ha3 waits for a third zone.
| Topology | Copies | Replication | Data loss when a data center is lost | Target time to recover |
|---|---|---|---|---|
single | 1 | None | None if it waits for its data center; up to 60 seconds of changes where it is restored from backups in another data center | Relocated after 15 minutes, plus the restore, or when its data center returns if it waits |
ha2 | 2, in two data centers | Synchronous when the two data centers are within 10 ms, otherwise asynchronous | None when synchronous; when asynchronous, the changes the standby had not received yet, usually under a second | Under 2 minutes |
ha3 | 3, in three data centers | Synchronous | None | Under 2 minutes |
These are design targets; the SLA has the full table.
ha2: synchronous where the data centers are close
When the two data centers that can host your size are within 10 ms of each other, an ha2 database keeps one copy in each and replicates synchronously: every commit is confirmed by the standby (one round trip between them more per commit), so losing a data center loses nothing.
When the closest pair is farther apart, making each commit wait that long would slow every write, so there ha2 replicates asynchronously: commits don't wait for the standby, which is usually less than a second behind. If the primary's data center fails, the standby takes over with what it has, so the changes it had not received are lost. Two more cases can lose data: changes made while the standby was already down, and, if a network failure cuts the primary off from the rest of the region, the changes the cut-off primary accepted (up to about 30 seconds).
If a few writes must never be lost on an asynchronous ha2, confirm them in your application (for example, write them again after a failover if they are missing), or use ha3 when it is offered.
ha3
ha3 needs three data centers that can host the size. It shows waiting for capacity until they can.
Failover
- Automatic. When the primary's server or data center fails, KeelDB promotes a standby, usually within one to two minutes. Hostnames don't change, so clients reconnect to the new primary through the same host. Make sure your app retries failed connections and transactions.
- Planned changes such as resizes switch over to a standby first, so writes pause only for seconds.
- After a server or a data center is lost, an
ha2database keeps running on its surviving copy. Once Dedicated servers open, KeelDB replaces the lost copy automatically: a server unreachable for 5 minutes is replaced in a data center that is up, and the new copy catches up from the primary.
Manual failover
You can promote a standby yourself, for example to test how your app handles failover. This works on any database with at least one standby or read replica.
curl -X POST https://keeldb.com/api/v1/databases/k7m2x9qa4pz1/operations \
-H "Authorization: Bearer $KEELDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"kind": "failover"}'The response contains a job_id to poll. In the console, use Fail over on the Overview page.
Single-copy databases and a data center loss
Free, Launch and Dedicated single databases have one copy. In US East:
- Free and Launch databases run on our shared server at AWS in Northern Virginia. When that server stops responding and our checks from Ashburn, Piscataway and Cloudflare confirm the loss (about 3 minutes), KeelDB creates a replacement server of the same kind at once, normally in another availability zone of Northern Virginia. It restores each database from its backups, with the same hostname and password, onto the replacement or another of our shared servers that has room: Launch databases from 15 minutes after the server stopped responding, Free databases from 30 minutes. Changes since the last archived write-ahead log are lost: up to 60 seconds on Launch and 5 minutes on Free. If the server comes back before the first restore starts, it keeps serving and the replacement is removed. The replacement has the same room as the server it replaces, so the databases stay on it.
- Dedicated
singledatabases run at AWS in Northern Virginia. Once Dedicated servers open, a failed server is replaced automatically: after 5 minutes unreachable, its storage volume is attached to a new server, or, if the volume was lost with it, the database is restored from its backups. If its whole availability zone is lost, the database is restored from its backups in the other zone after 15 minutes, with the same hostname and password; up to 60 seconds of changes can be lost.
To keep a single-copy database where it is instead, set Data center loss to Wait for the data center to return in its Settings, or send {"relocation": "wait"} to the API. It then stays down until its server or data center returns, and nothing is restored elsewhere. High-availability databases keep a copy in another data center and don't have this setting.
Today: for Free and Launch databases the console shows this choice once we switch it on; until then their Settings describe what happens, and the API already accepts {"relocation": "wait"}.
PostgreSQL settings
Settings are derived from your plan and size. Settings that need a restart come from the minimum of the CU range, so autoscaling never restarts PostgreSQL to change them.
Free and Launch, from the CU range (the values shown are for the default range, 0.25 to 2 CU):
| Setting | Rule | Value |
|---|---|---|
max_connections | Free 100; Launch 200 per CU of the smaller of the maximum and 8 times the minimum, from 100 to 1,000 | 100 (Free), 400 (Launch) |
shared_buffers | 25% of the minimum's memory, at least 128 MB | 256MB |
effective_cache_size | 75% of the minimum's memory | 768MB |
maintenance_work_mem | 5% of the minimum's memory, 64 MB to 1 GB | 64MB |
work_mem | What the minimum's memory leaves after shared_buffers, split across 3 operations per connection, 1 MB to 64 MB | 2621kB (Free), 1024kB (Launch) |
archive_timeout | How often the write-ahead log is archived when it is quiet | 300s (Free), 60s (Launch) |
Dedicated, from the size:
| Size | max_connections | shared_buffers | effective_cache_size | maintenance_work_mem | work_mem |
|---|---|---|---|---|---|
std-2 | 100 | 512MB | 1433MB | 102MB | 4096kB |
std-4 | 200 | 1024MB | 2867MB | 204MB | 4096kB |
std-8, perf-8 | 400 | 2048MB | 5734MB | 409MB | 4096kB |
perf-16 | 800 | 4096MB | 11468MB | 819MB | 4096kB |
perf-32 | 1,000 | 8192MB | 22937MB | 1638MB | 4096kB |
perf-64 | 1,500 | 16384MB | 45875MB | 2048MB | 4096kB |
perf-128 | 2,000 | 32768MB | 91750MB | 2048MB | 5592kB |
perf-192 | 2,000 | 49152MB | 137625MB | 2048MB | 8388kB |
Dedicated databases archive the write-ahead log at least every 60 seconds and set effective_io_concurrency = 200. perf-32 and larger keep the write-ahead log on a disk of its own.
Every plan also sets:
| Setting | Value |
|---|---|
wal_compression | on |
random_page_cost | 1.1 |
idle_in_transaction_session_timeout | 10 minutes |
log_min_duration_statement | 1 second |
pg_stat_statements.track | all |
pg_stat_statements.max | 5000 |
Databases are created with UTF8 encoding, the C.UTF-8 locale and data checksums.
You can override settings that a regular role may change, per transaction (SET LOCAL work_mem = '64MB'), per session, or as defaults for your database:
ALTER DATABASE shop SET work_mem = '8MB';Defaults set this way apply to new connections.