Emberstore logoEmberstore

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.

Three servers share one MySQL or MariaDB database. Gateways send webhooks only to the lobby server, which has webhook.enabled true and runs the listener, reconciliation, expiry and the dashboard. Every server delivers rewards to its own online players.

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.yml and config.yml on 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: 5

Give 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

JobRuns on
Menus, checkouts, player commandsEvery server
Delivering rewards and take-backs to online playersThe server the player is on, every sync-interval-seconds and on join
Renewal remindersThe server the player is on, each reminder sent once
Webhook listenerThe server with webhook.enabled: true
Reconciliation, order expiry, ending timed itemsThe server with webhook.enabled: true
Web dashboardOnly the server with webhook.enabled: true. It refuses to start anywhere else while network mode is on.
Sale, refund and dispute noticesThe 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 this page