Multi-server Swarm
Run a Redelay project on several Swarm nodes or regions — which data services are node-local and which are not, how requests are routed, when sticky sessions help, and how to read from the nearest replica without losing read-your-writes.
A Redelay project scales out by running its app tier on several Swarm nodes — often in different regions — next to replicated data services. That only pays off if every hop on a request's path stays local. This guide is the checklist.
The one number to keep in mind: a request makes several sequential data calls, so cross-region round trips multiply. A replica 147 ms away from the database primary turned a 59 ms p50 list call into 740 ms — five reads, each crossing the ocean. Measure the RTT between your nodes before placing anything.
1. What is local, what is not
| Service | How a replica connects | Local to the task? |
|---|---|---|
| ClickHouse (replicated tables) | CLICKHOUSE_HOST=clickhouse-{{.Node.Hostname}} | ✅ reads and inserts hit the node's own replica; replication is async (seconds) |
| Redis — cache | REDIS_URL=redis://redis-{{.Node.Hostname}}:6379/0 | ✅ per-node cache; invalidate across nodes with broadcast events |
| Redis — shared (locks, rate limits, coordination) | COORD=redis, REDIS_SHARED_CLUSTER_NODES=redis-a:6380,redis-b:6380,…; auth: REDIS_SHARED_USERNAME + REDIS_SHARED_PASSWORD (ACL user, go-modules ≥ v0.68.0) | ❌ by design: keys are hashed across the cluster, so most calls leave the node |
| MongoDB replica set | MONGO_URI=mongodb://…@mongo-a,mongo-b,mongo-c/?replicaSet=… | ❌ reads go to the primary unless a read opts into Nearest; writes always go to the primary |
| Kafka | KAFKA_BOOTSTRAP_SERVERS= every broker | ❌ producers write to each partition's leader — keep publishing off the request path |
| Object storage / vector DB / LLM | single endpoint | ❌ treat as remote |
{{.Node.Hostname}} is a Swarm template: the task's env var is rendered with
the node it lands on, so one stack file gives every replica its local member.
Name the per-node services to match (clickhouse-<hostname>, redis-<hostname>).
A node gets its own ClickHouse and Redis replica before any app task can land on it. The templated name resolves to nothing on a node without its replica, and the task fails or retries against a name that does not exist. Add the data services first, then the label that lets app tasks in (Adding a node).
2. MongoDB: primary by default, Nearest per read
The client default stays MONGO_READ_PREFERENCE=primary — never flip it
globally. Replication is asynchronous: a blanket secondary preference breaks
read-your-writes for every endpoint at once (the user saves something, the next
request lands on a lagging member, and it seems to vanish).
Opt in per read, where staleness is acceptable:
import rtmongo "github.com/redelay/go-framework/runtime/mongo"
ctx = rtmongo.Nearest(ctx) // catalogue, browse, public lists — not what the user just wrote
items, err := svc.store.List(ctx, params)
crud.MongoCRUDhonours the context preference on every read (FindByID,FindByField,FindOne,Exists,List,ListAll,Count) from go-framework v0.16.6; before that onlyList/ListAll/Countdid.- A raw
*mongo.Collectionignores the context. Wrap it withrtmongo.Coll(ctx, coll)(go-framework v0.17.0), which applies the context's preference through a cached clone:rtmongo.Coll(rtmongo.Nearest(ctx), coll).Find(ctx, filter). Most hot paths use raw collections, and before v0.17.0Nearest(ctx)silently did nothing for them. rtmongo.Secondary(ctx)(SecondaryPreferred) is for reports and exports.- The framework's auth middleware is JWT-only — no database read per request.
Classify every read on a hot path:
| Read | Preference |
|---|---|
| Catalogue, browse, public data, configuration, other users' public data | Nearest |
| The user's own data they may have just written (favourites, lists, prefs, read-state) | primary — or one of the read-your-writes patterns below |
| Anything a write decision depends on (quota, billing, uniqueness, idempotency) | primary |
| Login, refresh, signup, password reset | primary |
Members in a second region: read, don't vote
Replica-set members in another region (across an ocean) are non-voting:
priority: 0, votes: 0. Keep the voters in the primary's region — for
example three voters in Europe, any number of read-only members in North
America. A network split between the regions then leaves the European
majority writable. With voters split evenly (2 + 2), a split leaves neither
side a majority and writes stop everywhere.
Services in the second region read from their nearby member with
rtmongo.Nearest and write to the primary across the ocean. Keep those writes
off hot paths, and run the second region's services with
EVENTS_OUTBOX_RELAY=false: they write outbox rows, and the relays next to the
brokers publish them.
Read-your-writes on a nearby replica
- Recent-write window (simple, built in since go-framework v0.17.0). A
write by user U marks U in shared Redis for
RecentWindow(10 s); U's own reads go to the primary while the mark exists, and to the nearest member otherwise.import ( rtmongo "github.com/redelay/go-framework/runtime/mongo" "github.com/redelay/go-framework/runtime/mongo/recentwrite" ) // at startup: the marker on the shared Redis Cluster; this node's master host rtmongo.SetMarker(recentwrite.New(clusterClient, "myapp:shared:", "redis-fp-"+nodeHostname)) // after authentication (or rtmongo.RecentWriteMiddleware(userIDFromRequest)): ctx = rtmongo.Request(ctx, userID, r.Method) // a write marks U before it runs // a read of U's own data: cur, err := rtmongo.Coll(rtmongo.ForUser(ctx, userID), favourites).Find(ctx, filter)- Mark before the write runs, not after: a read racing the write, and the write's own read-back, must go to the primary.
- Ask once per request, and only if a user-owned read happens.
Requestmemoises it; a hot path that checks per read pays one Redis round trip per read. - Keep the check local. A Redis Cluster without replicas keeps a key on
one master, maybe in another region, and a 147 ms check cancels the
Nearest read it decides.
recentwritewrites the mark to every master (hash tags, in parallel: one round trip, writes only). The check reads the node's own master (REDIS_SHARED_LOCAL_NODE=redis-fp-{{.Node.Hostname}}). - Fail to the primary: Redis down, or no marker set, means user-owned reads stay on the primary. That is slower, never stale.
- Login / refresh / signup carry no user before they run: they read the
primary explicitly, not through
ForUser.
- Causal consistency (exact). Writes use
w: majority; the response carries the operation time, which the client (or a per-user Redis key) keeps. The next request starts a causally consistent session,AdvanceOperationTime/AdvanceClusterTimeto that point, and readsNearestwithreadConcern: majority— the nearby member waits until it has replicated the user's write, so it can never serve something older.
Local writes: zone sharding by home region
Nearest makes reads local; writes still go to the one primary. A replica set has exactly one, so every write from another region crosses to it and waits for a majority to confirm. To write locally in several regions:
- Shard member data by home region. Every collection holding a member's
own rows is sharded on
{home_region: 1, user_id: 1}, and each region is a zone whose shard has its primary and its write majority in that region (two data nodes there; a third, priority-0 member elsewhere keeps a copy and a vote). With one data node in a region its majority needs another region, and the writes cross anyway. - Shared data (catalogue, imports) stays on one shard, written by background jobs, read Nearest everywhere.
- Global uniqueness (emails) can only be enforced on a shard key, so the accounts collection stays unsharded; sign-up from another region pays one crossing.
- Each app talks to its own node's
mongos(mongos-{{.Node.Hostname}}), never a list of routers — a driver spreads load across every router it is given, overseas ones included. - Authentication everywhere. A production cluster runs the same internal auth (one keyFile, or x.509) on every config server, shard member and mongos, and app users are created through mongos. The Docker recipe below runs without auth and is for tests only.
go-framework (≥ v0.18.0) carries the request side:
ctx = rtmongo.WithHomeRegion(ctx, user.HomeRegion) // or rtmongo.HomeRegionMiddleware
coll, filter := rtmongo.Own(ctx, favourites, bson.M{"user_id": uid})
cur, err := coll.Find(ctx, filter) // home shard's primary, one shard
doc, err := rtmongo.StampRegionStrict(ctx, fav) // a struct, bson.M/D or map
_, err = favourites.InsertOne(ctx, doc)
// an upsert: a sharded upsert needs the shard key in its filter, always
_, err = favourites.UpdateOne(ctx, rtmongo.RegionScoped(ctx, filter), update, options.Update().SetUpsert(true))
StampRegion works on structs (it returns a bson.D), maps and bson
documents, and returns an error instead of a silently unstamped document;
StampRegionStrict also fails with ErrNoHomeRegion when the request carries
no region — a document without the shard key lands in the chunk of no zone.
Own always reads the primary (exact: no recent-write window needed), and
adds the region to the filter only with MONGO_HOME_REGION_FILTER=true:
before the shard-key field is backfilled on every document, a filter on it
hides every older row. Backfill, shard, then turn it on.
A query without the shard key still works — mongos broadcasts it to every
shard and merges — so nothing fails; it just waits for the farthest shard.
Make that a test failure with mongotest.AssertTargeted (see "Testing zone
sharding").
3. Request routing: edge → Traefik → task
With proxied DNS (e.g. Cloudflare) holding one A record per node, visitors are spread across nodes without regard to location. Traefik runs on every node (global, host ports) and load-balances each service across all of its tasks Swarm-wide. So a request can enter in one region and be served in another, and there is no "prefer the local task" setting in Traefik's Swarm provider.
Pick one model per project:
| Model | How | When |
|---|---|---|
| A. App tier next to the primary | Constrain the app services to the region of the database primary (node.labels.location == <primary region>); data replicas elsewhere are for failover and for analytics reads. | Default. One region of users, or until latency matters elsewhere. |
| B. Regional app tiers | One service per region (site-api-eu, site-api-us) constrained by node.labels.location, each behind its own Traefik router on a regional host (eu-origin.example.com). At the edge, a geo-steering load balancer (e.g. Cloudflare Load Balancing pools per region, origin Host header override, edge session affinity) sends each visitor to its region. Reads use Nearest + one read-your-writes pattern from §2. | Users on several continents; the data tier is already replicated per region. |
Model B needs both halves: regional routing and Nearest reads. Regional
tasks that still read the remote primary are just as slow; Nearest reads
behind round-robin DNS still cross regions at the edge.
Client-chosen region (alternative to an edge load balancer)
Free, and it picks by each user's measured latency rather than geography:
- One hostname per region, each reaching only that region's tasks: a proxied
A record per region (
eu.example.com→ EU nodes,na.example.com→ NA node) and one Swarm service per region (web-eu,web-na,api-eu,api-na, constrained bynode.labels.location), each behind a router on its regional host. With a single service, Traefik would still balance across every region's tasks. - Regional hosts serve only the API path (
Host(na.example.com) && PathPrefix(/api/)), withX-Robots-Tag: noindex. HTML and SEO stay on the canonical host. - The client chooses: after hydration (or at native app start) it calls a
tiny uncached
GET /api/.../regionon every regional host in parallel, keeps the fastest (stored with a TTL, re-measured in the background), sends API calls there, and on a network error or 5xx switches to the next region (retrying idempotent requests only). - Call the regional proxy, not the Go API, when the web app talks through a Nitro proxy or BFF that adds headers, locale or credentials. The proxy in each region calls its own region's API service over the overlay.
- Cross-origin plumbing: CORS on the regional hosts for the canonical
origin (with credentials if cookies are used); session cookies scoped to the
parent domain (
Domain=.example.com) or bearer tokens; per-IP limits and sessions in shared Redis, so they don't split per region. - The HTML still comes from the canonical host, so keep its origins in the primary's region (§3 model A). Server-side rendering there stays local; only the browser's API calls go regional.
It only pays off when the regional API reads Nearest with a read-your-writes
pattern (§2). The client sticking to one region also gives session-affinity
consistency.
Lessons from a BFF rollout (Nameniac, 2026-10-15)
- Moving session cookies to
Domain=.example.comleaves old host-only copies behind.- A browser holding both sends both. With equal paths the older one comes first, and most cookie parsers keep the first value, so a stale refresh token wins.
- Every write from the canonical host must delete the host-only copy too. Only that host can.
- Migrate once with a marker cookie.
- Repair browsers that already have duplicates: when a name appears twice, keep the last value (the newest) and delete the host-only copy.
- Delete before you set. A response that sets the domain cookie and then deletes the host-only one is fine for browsers, which key by name + domain. A client keyed by name alone (a synthetic probe, a script) applies the delete last and loses the session.
- Server-render calls must forward the page's host. An in-process SSR call
that refreshes the session computes the cookie Domain from its own Host
(
localhost) and sets host-only cookies again. ForwardX-Forwarded-Host. - CSRF:
Sec-Fetch-Site: same-siteis not enough. Every*.example.comis same-site (old., admin., api.). Acceptsame-siteonly with anOriginthat is exactly the canonical origin(s). - CORS preflights must be answered before your guards. A CSRF or
members-only check refuses a bodyless
OPTIONS. Answer exact origins only, with credentials andVary: Origin. - A new route on a catch-all redirect host (e.g. "unknown paths → the old site") gets redirected away until it is on the own-path list. Test the regional routes through the real chain.
- Pre-production gates: a header-routed candidate can't see browser
preflights (an
OPTIONScarries no custom header). Cover the regional hosts at the HTTP level (explicitOrigin,Sec-Fetch-Siteand cookies), plus a router for the candidate on each regional host. - Deploy checks must not assume placement. "Exec into a task on this node" fails the day the scheduler moves it. Attachable overlays are rare; ask from a service pinned to the runner's node.
4. Sticky sessions — what they do and don't fix
Traefik sticky cookies pin a browser to one task:
- traefik.http.services.<svc>.loadbalancer.sticky.cookie=true
- traefik.http.services.<svc>.loadbalancer.sticky.cookie.name=<svc>_srv
- traefik.http.services.<svc>.loadbalancer.sticky.cookie.secure=true
- traefik.http.services.<svc>.loadbalancer.sticky.cookie.httponly=true
| Problem | Sticky cookie fixes it? |
|---|---|
| Per-task in-memory state (local cache, upload in progress, multi-step flow kept in memory) | ✅ |
| WebSocket / SSE reconnecting to the same task | ✅ (though prefer a shared hub — go-modules/ws fans out across replicas) |
Seeing your own Mongo write when the task reads Nearest | ❌ — the write went to the primary; the sticky task's nearby member may still lag. Use §2's read-your-writes. |
| Cross-region latency | ❌ — it pins a task, not a region. Region affinity belongs at the edge (§3 model B). |
| Deploys | ⚠️ a new task gets a new identity, so every sticky user moves at once on each rolling update |
Rule: make app tasks stateless (shared state in Redis/Mongo), choose consistency per read (§2), choose region at the edge (§3). Add a sticky cookie only for genuinely per-task state.
5. Placement
- Constraints are hard; preferences only spread.
placement.preferences: [spread: node.labels.X]balances tasks evenly across label values — there is no soft "prefer this node, fall back to that one". Two replicas over two eligible nodes always land 1 + 1. - Label nodes by role and location (
location=<site>,region=eu|na,api=true,clickhouse=true…) and constrain on labels, not hostnames. - Regional services constrain on the region label, never on one node —
and with as many tasks as eligible nodes, roll them stop-first with a
cap of one per node:
deploy: replicas: 2 # = the region's eligible nodes update_config: order: stop-first rollback_config: order: stop-first placement: constraints: [node.labels.region == na] max_replicas_per_node: 1spreadis only a preference, and start-first places the replacement beside the old task: with start-first and a cap of 2, both tasks ended up on one node after a few rollouts (seen on two services), so one node outage took the region down. With a cap of 1, start-first has no room and wedges ("no suitable node"). Stop-first stops one task while the other node serves, then reuses its slot: always one task per node, no wedge. The cost is a single task during an update or a node outage; failover to the other region's service (Traefik) covers HTTP meanwhile. Services with more eligible nodes than tasks can keep start-first with a cap of 1.node.labels.location == <node>makes that node a single point of failure for the region. Don't reuse a generic role label (api=true) to place a regional service either: it usually places other services too, and a new region's node would start taking them. - Anything that calls third parties from the node's IP is opt-in by label
(
catcher=true,whois=true): rate limits, allowlists and reputation are per IP, and a new node must not start sending traffic it was never set up for. - A service pinned to one region has no automatic fallback. Either run it in two regions (and accept their latency), or keep the failover step written down (relabel the node, redeploy).
max_replicas_per_node: 1keeps tasks on separate nodes; when tasks = eligible nodes, roll stop-first (start-first needs a free slot).- Rolling updates:
update_config.order: start-firstplusSHUTDOWN_PREDRAIN_SECONDS(go-framework ≥ v0.21.0, ~30 s behind Traefik) andSHUTDOWN_DRAIN_SECONDS(≥ v0.15.4), so the old task stays in the proxy's pool until the proxy has noticed the new one, then leaves it before its listener closes.RUNNER_STOP_TIMEOUT_SECONDSmust cover pre-drain + drain + 10 s, andstop_grace_periodthat plusMODULE_DRAIN_TIMEOUT_SECONDS- 15 s (30 + 15 → 55 and 100 s); go-framework ≥ v0.22.0 warns at startup when they do not fit.
6. Events across nodes
- Work queues: one consumer group per handler; Kafka spreads partitions across
replicas. Publishing from a request is a remote call — do it asynchronously
or after the response where possible. A publish waits for the partition
leader and its followers: with brokers in several regions, a publish from
one region to a leader in another that waits for a follower back in the
first crosses the ocean twice (seen: p95 2.2 s). Use the transactional
outbox (
runtime/outbox, go-framework ≥ v0.18.0):ob.Do(ctx, client, fn)stores the events in the same transaction as their data, a relay publishes them in the background — at-least-once, so consumers deduplicate on the event ID. Keep background workers that publish a lot in the brokers' region. Apps on go-events use its per-bus module instead (Outbox, v0.5.0+). - Deduplicate on the consumer side:
EVENTS_DEDUPE=redison a Redis every replica reaches, a stableEventNameon every registration, andeventstest.AssertConsumersNamedin a test (Idempotent consumers). Slow consumer groups get a longer claim (EVENTS_DEDUPE_INFLIGHT_GROUPS) without long in-place waits (EVENTS_DEDUPE_INFLIGHT_WAIT, v0.6.8+).- A row is claimed with a token: a relay whose publish outlived its claim cannot reschedule or delete the row another relay holds; a publish is cut off at half the claim.
- Regional relays (
Region) take only their region's rows. Rows written without a home region (system and worker events) getDefaultRegion, or — without one — need at least one relay withRegion: "", or they wait forever. - After
MaxAttempts(default 20, about 1.3 h of retries) a row is marked dead and kept for inspection; an event that cannot be decoded dies at once. - Alert on
Stats: the age of the oldest pending row, and any dead row. A pending count alone does not tell a backlog from a stuck relay.
- Kafka brokers: one per data node, including the second region's, so each region has local partition leaders for what it consumes. The controller quorum (ZooKeeper / KRaft controllers) stays at three nodes. Publishing still goes through the outbox — a broker in your region does not make the partition leader local.
- Broadcasts (cache invalidation, template reload): every replica must get
every message. go-events v0.4.5 (v0.3.1 on the 0.3 line; avoid v0.4.1–v0.4.4, whose topic checks stall startup for seconds per topic) consumes the known broadcast group prefixes
(
KAFKA_BROADCAST_GROUP_PREFIXES) without a consumer group, so restarts leave nothing behind on the broker.
7. Measure, per replica
Average latency hides a slow replica. Break request histograms down by instance and map instances to nodes:
histogram_quantile(0.5, sum by (le) (rate(http_request_duration_seconds_bucket{job="<app>",service="<svc>",instance="<task-ip>:<port>"}[1h])))
histogram_quantile(0.95, sum by (le) (rate(http_request_duration_seconds_bucket{job="<app>",service="<svc>",instance="<task-ip>:<port>"}[1h])))
docker service ps <stack>_<svc> --filter desired-state=running --format '{{.Node}} {{.ID}}'
docker inspect <task-id> --format '{{range .NetworksAttachments}}{{.Network.Spec.Name}}={{.Addresses}} {{end}}'
ping -c 5 <other-node> # node-to-node RTT; every remote data call costs at least this
Count the sequential data calls per request (Mongo, shared Redis, synchronous publishes). calls × RTT is the floor a remote replica adds.
8. Adding a node
A new node runs every unconstrained global service (log rotation, pruning, agents, anything without a constraint) the moment it is active, so it joins drained and is labelled before it takes work:
- Measure first: RTT to every other node, disk (fio), network (iperf3). The numbers decide what the node may host.
- Base host: RAID 1 and an alert on a degraded array; the private network (e.g. Tailscale) up, and its DNS working (a resolver stub that SERVFAILs breaks every overlay lookup); Docker pinned to the fleet's version; the firewall and egress rules the other nodes have; public SSH closed once the private path works.
- Join drained over the private address:
docker swarm join --availability drain …. - Labels:
region,location, roles. Third-party-facing roles (catcher,whois…) only when the node is meant to send that traffic. - Per-node data, one service at a time: its Mongo member (non-voting in a
second region), ClickHouse replica, Kafka broker, Redis cache. Deploy only
the new services — a full
docker stack deployof a stateful stack can roll every member at once. - Proxy prerequisites: anything the load balancer needs on the node (default certificate, entrypoints) before it serves.
- Activate (
docker node update --availability active), then confirm monitoring scrapes it and the app tasks that landed there are healthy. - Record the host's configuration with the rest of your infrastructure.
Testing read preference
- Test on a replica set. A standalone server or
directConnection=truemakes the driver drop$readPreference, so a test there passes for the wrong reason. A single-member set is enough:docker run -d -p 27199:27199 mongo:7 --replSet rs0 --port 27199 mongosh --port 27199 --eval "rs.initiate({_id:'rs0',members:[{_id:0,host:'localhost:27199'}]})" # mongodb://localhost:27199/?replicaSet=rs0
The port must match inside and outside the container: a member must find itself in its own config. In CI, pick a free port first. - Assert on the wire: use a
CommandMonitor, and check$readPreferenceon the command each classified read sends. - Watch for TTL time bombs. Real-data fixtures with fixed dates fall out of a table's TTL (e.g. 7 days) and ClickHouse drops them on insert; the tests start failing on a date, on every commit. Create test tables without the TTL.
Testing zone sharding
A two-shard cluster in Docker is enough to prove a member query is targeted:
docker network create rfshard
docker run -d --name rf-cfg --network rfshard mongo:8.0 mongod --configsvr --replSet cfg --port 27019 --bind_ip_all
docker run -d --name rf-s1 --network rfshard mongo:8.0 mongod --shardsvr --replSet s1 --port 27018 --bind_ip_all
docker run -d --name rf-s2 --network rfshard mongo:8.0 mongod --shardsvr --replSet s2 --port 27018 --bind_ip_all
docker exec rf-cfg mongosh --port 27019 --eval 'rs.initiate({_id:"cfg",configsvr:true,members:[{_id:0,host:"rf-cfg:27019"}]})'
docker exec rf-s1 mongosh --port 27018 --eval 'rs.initiate({_id:"s1",members:[{_id:0,host:"rf-s1:27018"}]})'
docker exec rf-s2 mongosh --port 27018 --eval 'rs.initiate({_id:"s2",members:[{_id:0,host:"rf-s2:27018"}]})'
docker run -d --name rf-mongos --network rfshard -p 27100:27100 mongo:8.0 mongos --configdb cfg/rf-cfg:27019 --port 27100 --bind_ip_all
docker exec rf-mongos mongosh --port 27100 --eval 'sh.addShard("s1/rf-s1:27018"); sh.addShard("s2/rf-s2:27018")'
REDELAY_TEST_MONGO_SHARDED_URI='mongodb://localhost:27100' go test ./runtime/mongo/mongotest/
# teardown — -v removes the anonymous data volumes (leaked ones filled 136 GB on one node)
docker rm -f -v rf-mongos rf-s1 rf-s2 rf-cfg && docker network rm rfshard
In an app's own tests, run each member query through mongotest.AssertTargeted
against such a cluster: it explains the query through mongos and fails when it
would reach more than one shard — and when mongos answers with a plan layout
it cannot read, rather than passing. Only find is explained; an aggregate or
count with the same filter targets the same shards. The outbox's transactions need a replica set
(REDELAY_TEST_MONGO_RS_URI, one member is enough).
Checklist
- Node labels for role and location; services constrained by labels.
- Per-node services named
<svc>-<hostname>; app env uses{{.Node.Hostname}}. -
MONGO_URIlists every member withreplicaSet=; default read preference staysprimary. - go-framework ≥ v0.16.6 if any read uses
Nearest; raw collections cloned with the preference. - Every hot-path read classified (Nearest / primary / read-your-writes pattern), recorded with the code.
- Routing model chosen: A (app next to primary), B (regional services + geo-steering edge), or client-chosen region (regional hosts + client RTT choice).
- Sticky cookies only where a task holds per-request state.
- go-events on the latest tag (≥ v0.4.5 for broadcast consumers and no per-topic startup stall; never v0.6.4).
- Per-replica p50/p95 dashboards; RTT between nodes known.
- Writes local per region only where it pays: member data sharded by home region, two data nodes per region, apps on their node's
mongos,AssertTargetedin tests,MONGO_HOME_REGION_FILTERon after the backfill. - No broker publish on the request path across regions: transactional outbox (
runtime/outbox). - At-least-once handled:
EVENTS_DEDUPE=redis, every consumer named (eventstest.AssertConsumersNamed), go-events ≥ v0.6.9 (never v0.6.4). - Balancer and container healthchecks on
/health/live(go-framework ≥ v0.17.2), not the deep/health. -
region=eu|nalabels on every node; regional services onnode.labels.region+max_replicas_per_node: 1+order: stop-first(update and rollback) when tasks = eligible nodes — never pinned to one node, never start-first with a cap of 2 (both tasks drift onto one node). - Second-region Mongo members non-voting (
priority: 0, votes: 0); those servicesEVENTS_OUTBOX_RELAY=false. - Every node has its ClickHouse/Redis replica before app tasks can land on it.
- Rolling updates behind Traefik:
SHUTDOWN_PREDRAIN_SECONDS=30,SHUTDOWN_DRAIN_SECONDS=15,RUNNER_STOP_TIMEOUT_SECONDS=55,stop_grace_period: 100s(no startup warning on go-framework ≥ v0.22.0). - New nodes join drained, are labelled, then activated; third-party callers are opt-in labels.