Multi-server networks
Share one store between several servers behind a proxy, with one shared MySQL or MariaDB database.
On a network, every server can open /store and take checkouts, while one server receives the payments. Orders, stock, code uses, subscriptions and waiting rewards are shared through one database, and a reward is delivered on whichever server the player is playing on.
Requirements
- MySQL or MariaDB storage on every server, all pointing at the same database. SQLite and H2 belong to one server, so with them network mode stays off and the console says so.
- The same
categories/,promotions.ymlandconfig.ymlon every server (apart from the per-server keys below).
Setup
Shared database
Set storage.type to mysql or mariadb and fill in the same connection details on every server. See Storage.
Turn network mode on
network:
# Share orders, stock and rewards between several servers through MySQL or MariaDB
enabled: true
# Unique name of this server on the network
server-id: "survival"
# Seconds between checks for rewards waiting for players on this server
sync-interval-seconds: 5Give every server its own server-id. It is saved on each order, so you can see where it was made.
Pick the payment server
On exactly one server, keep webhook.enabled: true. On all the others set it to false. Point webhook.public-base-url (and your reverse proxy) at that one server.
Compare the fingerprint
On startup each server logs a line like "Network mode on as server survival. Shared files fingerprint: ...". The fingerprint covers the category files, promotions.yml and config.yml without the per-server keys (network.server-id and the webhook and dashboard sections). If two servers show different fingerprints, their files differ.
What runs where
| Job | Runs on |
|---|---|
| Menus, checkouts, player commands | Every server |
| Delivering rewards and take-backs to online players | The server the player is on, every sync-interval-seconds and on join |
| Renewal reminders | The server the player is on, each reminder sent once |
| Webhook listener | The server with webhook.enabled: true |
| Reconciliation, order expiry, ending timed items | The server with webhook.enabled: true |
| Web dashboard | Only the server with webhook.enabled: true. It refuses to start anywhere else while network mode is on. |
| Sale, refund and dispute notices | The server with webhook.enabled: true |
Stock, per-player limits and code uses are checked inside the shared database while the order is created, so two players on two servers can never both buy the last unit.
On a single server, leave webhook.enabled: true. Turning it off there also stops reconciliation and the task that ends timed items.