Sizing and scaling
Resources for a tprm.mlab.sh instance, what grows with use, what can be scaled and what high availability looks like in practice.
Resources
The system requirements are a minimum of 2 cores, 2 GB RAM and 10 GB disk; 4+ cores, 4-8 GB RAM and 50 GB+ are recommended. Most of the memory goes to the two databases, not the app.
| Component | What drives its size |
|---|---|
app | Concurrent requests. JSON request bodies are capped at 2 MB in memory; document uploads and downloads are streamed in 8 MiB parts, so a 2 GB file costs no more memory than a small one. |
mysql | Size of the register: providers, contracts, assessments, incidents. The app opens 4 to 24 connections. |
clickhouse | Activity log, kept 365 days then dropped automatically. ClickHouse's own memory use dominates on a small host. |
| Disk | MySQL and ClickHouse volumes, request logs (never pruned by the app, see Request logs), Docker logs, and silo_data if documents are stored locally. |
| S3 | Documents: up to S3_MAX_UPLOAD_MB (2048 MB) per file. |
To keep ClickHouse from taking memory away from MySQL on a small host, cap the containers with compose limits (example, adjust to your host):
clickhouse:
mem_limit: 2g
mysql:
mem_limit: 2gWhat can scale
| Component | How |
|---|---|
app | Vertically. One container serves an instance; Actix-web runs one worker per available CPU, so more cores serve more concurrent requests. |
| MySQL | Replace the mysql service with a managed or replicated MySQL 8 and set DB_HOST / DB_PORT. See the FAQ. |
| ClickHouse | Replace the clickhouse service with your own, set CH_HOST. It must accept the native protocol on port 9000 (not configurable) and run a supported version (see ClickHouse version). |
| Documents | Any S3-compatible service; durability and replication are the provider's. |
Why not several app containers
Running more than one app container against the same database is not a supported
configuration. In 1.7.0:
- each running instance holds a place on the license, and the instance id is stored in the database (see Places);
- the license state, the SSO sign-in flows (10 minutes) and the login failure counters live in the memory of the process;
- profile pictures are written to the container's local
uploadsvolume.
Separate entities or branches run separate instances, each with its own databases and a place on the same license key.
High availability
There is no active-active mode. What keeps an instance available:
| Failure | What happens | Mitigation |
|---|---|---|
app crashes | restart: unless-stopped restarts it; it serves again once MySQL and ClickHouse answer and migrations are checked. | Monitor restarts (Monitoring). |
| MySQL down | Requests fail; at start-up the app waits for it. | Managed or replicated MySQL. |
| ClickHouse down | At start-up the app waits for it. While running, activity cannot be recorded or shown. | Restart; external ClickHouse if needed. |
| mlab.sh unreachable | Runs on the kept license for up to 7 days (status offline), then pauses without touching data. | Restore outbound HTTPS to mlab.sh, or route it via MLAB_LICENSE_URL. |
| Identity provider down | SSO sign-in fails; sessions already open continue. | Local administrators keep a password, even in SSO only mode. |
| Host lost | Instance down. | Cold standby, below. |
Cold standby
A second host, prepared but not running the stack, restored from backup:
Install Docker on the standby host with the same docker-compose.yml, .env and
image tag.
Replicate backups to it: the MySQL dump, the ClickHouse export or volume
snapshots, and uploads. Documents stay in the S3 bucket, reachable from both
hosts. See Backup and restore.
To fail over: make sure the primary is stopped, restore the latest backup, start the stack, and move the DNS name (or the proxy's upstream) to the standby. The restored database carries the instance id, so the standby takes the primary's place on the license.
Never run the primary and the standby at the same time with the same database copy: both would claim the same instance id. Data written after the last backup is lost; the backup interval is your recovery point.