Scaling and firewall mode
One instance on SQLite and local disk suits most teams. To run several replicas, move the database to Postgres and package files to S3, or use firewall mode to keep no package files at all.
Run more than one instance
SQLite and local disk suit one instance. To run several, every replica needs the same database and the same package storage. Put a load balancer in front, and point every replica at one Postgres database and one S3 bucket.
PRATIQUE_DATABASE_URL=postgres://pratique:PASSWORD@db.example.com:5432/pratique
PRATIQUE_S3_BUCKET=acme-pratique
PRATIQUE_S3_REGION=eu-west-1
The database URL must start with postgres:// or postgresql://. In the config file, these
settings go under storage:. See configuration.
| Variable | Purpose |
|---|---|
PRATIQUE_S3_ENDPOINT | Host of the S3 service. The default is s3.amazonaws.com. |
PRATIQUE_S3_REGION | The bucket's region. |
PRATIQUE_S3_PREFIX | A key prefix inside the bucket. |
PRATIQUE_S3_ACCESS_KEY, PRATIQUE_S3_SECRET_KEY | Static credentials. Leave them out to use the AWS credential chain. |
PRATIQUE_S3_INSECURE | Connect without TLS. For local testing only. |
What to know
- Credentials. Without static keys, Pratique uses the AWS environment variables, then the shared config, then an instance or pod role.
- Other S3 services. For MinIO or another S3-compatible service, set
PRATIQUE_S3_ENDPOINTto its host as well. - Moving data. There is no migration from SQLite and local disk yet. Start fresh on the new backends, or stay on one instance.
- Upgrades. Replace replicas one at a time, with no downtime. See upgrade without downtime.
- Background jobs. The threat feed, the hourly recheck, storage cleanup and the other scheduled jobs run on one replica at a time. If that replica stops, another runs the job when it is next due.
- Temp files. Each replica still needs
PRATIQUE_DATAfor files while they are verified, with room for your largest package. - Load balancing. Any replica can serve any request, so you don't need sticky sessions.
- Sign-in throttling is kept per instance, so the limit multiplies by the number of replicas.
- The same file and keys everywhere. Give every replica the same config file, or they apply different
policy, and the same
PRATIQUE_AUDIT_KEY. - The blocked list on Blocked and allowed is reused for 30 seconds. A change shows at once on the replica where you made it, and on the others when their copy is refreshed. What clients are offered is always decided fresh.
Upgrade without downtime
With two or more replicas behind a load balancer:
Set a drain delay
Set
PRATIQUE_DRAIN_DELAYto a bit more than the load balancer needs to notice a failed health check, such as15s. Give the container that long plus 30 seconds to stop:docker stop --time 45, orstop_grace_period: 45sin Compose.Health-check /readyz
Point the load balancer's health check at
/readyz.Replace one replica at a time
Start the new version, wait until its
/readyzanswers, then move on to the next. The first one applies any database migrations, under a lock.
When a replica is told to stop, /readyz fails at once, so the load balancer stops sending it new
requests. It keeps serving for the drain delay, then stops taking connections and lets requests in progress finish,
for up to 30 seconds. Its background jobs move to another replica.
Old and new replicas share the database meanwhile. That is safe because a migration may only add tables, columns with a default, and indexes; tests refuse anything else. Before every merge, CI runs the last release and the new version side by side on the same Postgres and S3, and checks draining. To skip versions, upgrade through each release in turn, or stop every replica first.
A single instance has a few seconds of downtime while its container restarts. npm, pip, uv, Go and Composer retry, so most installs don't notice.
High availability on Hetzner
- Servers. Two small Cloud servers in different locations, each running the image.
- Load balancer. A Hetzner Load Balancer on a private network to the servers, with an HTTP health
check on
/readyz, behind Cloudflare or with its own certificate. - Package files. Hetzner Object Storage, which is S3-compatible:
PRATIQUE_S3_ENDPOINT=fsn1.your-objectstorage.comandPRATIQUE_S3_REGION=fsn1. - Database. Hetzner has no managed Postgres. Use a managed provider, or run Postgres with a replica and failover, or the database stays the one part that can stop everything.
Harden the bucket
Pratique hashes each file from S3 as it serves it, and aborts the download if the hash doesn't match. Still, keep the bucket private and turn on versioning, so a deleted or changed file can be recovered.
Back up
Use pg_dump or your provider's snapshots for the database, and bucket versioning or replication for the
files. pratique backup refuses to run on Postgres, so a backup can't silently miss your data. See
storage.
Firewall mode
By default Pratique works in artifactory mode: it stores every file it delivers, like an artifact repository. In firewall mode it makes the same decisions but keeps no package files, so there is less to own, back up and protect.
server:
mode: firewall
The environment variable is PRATIQUE_MODE=firewall.
What happens to a download
The database stays, with the audit log, hashes, projects and build records. Clients still point at Pratique, because that is what makes every install pass through it.
What changes
- No outage protection. If the registry is down or a package has been deleted, installs fail.
- More upstream traffic. After the short window, each download goes to the registry again. That is slower, and heavy CI can hit the registry's rate limits.
- No private packages. Publishing is refused. Reserved names still never go upstream, so point those scopes at your own registry. See private packages.
- Composer archives with no published hash. The commit each version is built from is still checked, so a moved tag opens an incident. Their bytes aren't, because GitHub can build the same commit into a different zip and there is no stored copy to compare with.
- More than one server. The manifest check reads the short-lived copy, so it only sees files on the server that runs it. See manifest mismatch.
- No S3. Firewall mode keeps no package files, so Pratique refuses to start with S3 storage set.
Switch an existing server
Switching an existing server to firewall mode deletes its stored package files, within the same short window.
- Private packages block the switch. The server won't start in firewall mode while it still hosts private packages, because they exist nowhere else. Move them to your own registry first.
- Going back is safe. In artifactory mode, files are stored again as clients next request them.
- Storage cleanup's page goes away. A saved or file-based cleanup policy still forgets old build records.
Choose a mode
| Artifactory mode (default) | Firewall mode | |
|---|---|---|
| Good for | Teams that also want a package cache and a private registry | Security teams that want the control without owning a repository |
| Malware, quarantine, rules, audit log | Yes | Yes |
| Package files | Stored | Deleted within about 20 minutes |
| Registry down or package deleted | Stored files still install | Installs fail |
| Traffic to the registries | Once per file | Again after each short window |
| Private packages | Hosted | Not hosted. Reserved names still never go upstream |
| Composer archives with no published hash | Pinned by commit and by bytes | Pinned by commit only |
| More than one instance | On Postgres and S3 | No S3. The manifest check only sees each server's own files |
Choose artifactory mode if you host internal packages, need installs to keep working when a registry is down, or run heavy CI. Choose firewall mode if you want the decisions and the audit trail, and would rather not store and back up package files.