Replication
Run several API replicas behind a load balancer, keep them in sync, and make sure triggered work runs exactly once.
A single API replica serves most projects. Run more when you need higher availability or more throughput. Replicas are stateless towards clients, but they share background work such as function triggers, so they must coordinate.
Turn it on
Start every replica with:
Terminal
--replication=trueThe Helm chart sets it automatically when application.replicas is greater than 1.
With replication on:
- Scheduled, bucket and database events are claimed by one replica, so each runs once.
- Replicas keep their in-memory state, such as loaded functions and triggers, in step.
Requirements
| Concern | What to do |
|---|---|
| Function sources | Use --function-asset-storage-strategy=awss3 or gcs, or point --function-asset-path at a shared volume. |
| Uploaded files | Use the awss3 or gcloud storage strategy, or a shared volume (application.diskAccessMode: ReadWriteMany in the chart). |
| Database | All replicas use the same database. |
| Secrets | All replicas use the same master key or secrets. |
| Load balancer | Any. WebSocket connections (realtime, firehose) must be allowed. |
Things that run on every replica
systemtriggers withREADY, because every replica starts.- In-memory response caches (
--bucket-cache). Each replica has its own cache and invalidates it on its own writes, so cached reads can be stale for up to--bucket-cache-ttlseconds.