Multi-instance deployments
Run multiple Teldrive API and worker processes against shared PostgreSQL.
Use multiple instances only for a measured availability or capacity requirement.
Shared configuration
Every instance must share:
- PostgreSQL database and schema;
security.signing-key;security.data-key;encryption.keysand active version;- Telegram application identity.
Worker roles
Default API + worker process:
jobs:
run-workers: trueAPI-only process:
jobs:
run-workers: falseAt least one instance must keep workers enabled.
load balancer ──► API 1 (workers off)
├► API 2 (workers off)
└► Worker (workers on)
│
▼
PostgreSQLPostgreSQL pools
Each process owns a pool. Budget the aggregate maximum, not just one instance:
database:
max-connections: 10
min-connections: 1Bot rotation
Single instance:
telegram:
bot-rotation-backend: memoryMultiple coordinated instances:
telegram:
bot-rotation-backend: databaseSSE
events.max-connections-per-user is per API instance. The load balancer and proxy must support long-lived SSE connections on every instance.
Encryption-key rollout
For a new content key:
- distribute the new key version to every instance;
- verify all instances start;
- switch the active version everywhere;
- retain old key versions for old files.
Upgrades
Back up PostgreSQL before migrations. Avoid prolonged mixed-version deployments unless the release explicitly supports them.
See Upgrading.
Before scaling
Multiple instances do not fix Telegram rate limits, proxy buffering, slow clients, an undersized PostgreSQL server, or excessive per-instance concurrency. Measure the bottleneck first.