Engines & Tools6 min read

World War Heroes merges 100m accounts in under 15 minutes of downtime

Last Level Games merged over 100m World War Heroes accounts from iOS and Android into one server in under 15 minutes of downtime, using Postgres logical replication plus custom middleware that rewrites IDs on the wire.

World War Heroes merges 100m accounts in under 15 minutes of downtime
chienba / pixabay

Key points

  • More than 100 million player accounts were merged across iOS and Android in under 15 minutes of downtime.

  • The migration covered 9 TB-plus of data across roughly 50 tables per platform on Postgres 13; the EU snapshot copy alone took over 20 hours.

  • A Patroni failover on release night destroyed replication slots, forcing a from-scratch restart of main data replication.

  • Post-merge matchmaking quality improved but player satisfaction fell as real players replaced bots and K/D ratios dropped.

Last Level Games migrated more than 100 million World War Heroes player accounts from separate iOS and Android backends into a single shared server, completing the cutover in under 15 minutes of planned downtime. Mikhail Orlov, a developer at Last Level Games, laid out the full engineering account, including a release-night replication failure and an unexpected fallout in matchmaking quality.

The scale was substantial. Each platform ran 11 databases per region across three regions — EU, NA and AS — with roughly 50 tables per platform and more than 9 TB of combined data on Postgres 13. The largest single server, EU, held 4.8 TB. The initial snapshot copy of that EU server alone took over 20 hours, which is why replication started weeks before release and ran with millisecond-level lag for days prior to cutover.

Why a plain data merge was impossible

Every entity in every table on both platforms carried overlapping primary keys. User ID 1 on iOS is a different person than user ID 1 on Android, and the same applied to clan IDs, item IDs, weapon IDs and transaction IDs. Facebook registrations complicated matters further: the same Facebook account could exist on both platforms, and the social graph — friendships, clan memberships, in-game mail, chat history — ruled out migrating users in isolation.

Orlov described the hard constraints: a maximum of one to two hours of downtime, guaranteed rollback capability, and QA testing on real production data before players ever saw the merged result.

What did the team consider first?

The team evaluated four approaches before settling on its final design:

  • Background migration at login. Shifting data gradually as users authenticate. Rejected: no clean rollback, no pre-testing on production data, and bugs hit live users immediately.
  • Real-time migration at cutover. Migrating each user's full dataset on login after a cutoff. Rejected for the same reasons, plus it dumps heavy work onto the system at peak login traffic.
  • Script-based background migration. More controllable, but it required custom infrastructure to track state across 11 databases, handle retries and crash recovery over potentially weeks on live data.
  • Debezium. A CDC (change data capture) tool built on Postgres logical replication, streaming changes to Kafka. Rejected for operational overhead — a JVM service and a Kafka cluster — and because it targets general-purpose event streaming, not a one-time migration with per-column transformation rules over a fixed schema.

How the middleware works

The chosen foundation was Postgres logical replication, which operates at row level with a publish/subscribe model: a publication on the source lists exposed tables, a subscription on the target receives a snapshot then a continuous change stream. What Postgres does not provide is data transformation in transit — user ID 1 arrives as user ID 1.

So the team built a thin middleware layer that speaks both sides of the Postgres wire protocol. The subscriber believes it is talking to a Postgres server; the publisher believes it is talking to a client. Each middleware instance is a TCP server built on jackc/pgx/v5/pgproto3, with two goroutines forwarding traffic bidirectionally. Each source platform passes through its own middleware instance with its own ID offset, leaving the merged database with no overlap.

The core transformation is simple: add a fixed offset to every ID and every foreign key reference. Offsets were designed so each region lands in a non-overlapping numeric range, meaning a future regional merge (EU, NA, AS into one global server) would require only standard logical replication with no middleware. The Android AS region had no iOS counterpart to merge, but the team shifted its IDs anyway — partly for a uniform scheme, and partly because players notice their user IDs and read uneven treatment as unfair.

The team considered UUIDs but rejected them for two reasons. User IDs and clan IDs are player-facing: players type clan IDs to join and share user IDs in support tickets, and a UUID is not realistically typeable. Technically, changing column types from int64 to uuid.UUID in Go would touch every struct, query and service boundary. The offset approach required infrastructure changes only; application code did not change at all.

Which edge cases broke the model?

Two business logic cases required special handling. Facebook credentials were renamed from "facebook" to "facebook-ios" during replication so the per-region unique constraint held; players with accounts on both platforms received an account selection screen at login, and no new duplicates are possible after the merge date. Clan name and tag collisions turned out to be rare and mostly the same person founding identically named clans on both platforms — instead of force-renaming, the team kept all clan data intact and blocked clan setting modifications for conflicting owners until a resolution, with new clans barred from taking conflicting names.

The release sequence: stop Blue app instances and wait for graceful shutdown, update configs to point at the new databases, verify zero replication lag, then open Green instances to all players. Actual downtime came in under 15 minutes, well inside the two-hour budget.

What happened after release?

The gameplay consequences surprised the team. With a larger combined pool, matchmaking filled rooms with real players instead of bots far more often. Match quality rose, K/D ratios dropped — and player satisfaction dropped with them, because players were accustomed to winning more often. The matchmaking parameters had been tuned for a smaller pool, forcing the team to revisit balancing logic.

Release night also brought an incident: a Patroni failover promoted a replica to primary, and the replication slots did not survive the transition. The team had to restart main data replication from scratch, mid-night and under pressure; stats replication finished only after players were already on the new servers. The fix — permanent replication slots configured explicitly in Patroni — is something Orlov recommends setting up before release day, learned the hard way.

More than a year on, the merged databases remain in production and nothing from the migration has resurfaced. Orlov credits Postgres's built-in machinery — LSN tracking, crash recovery, consistent snapshots, conflict detection — with handling functionality that would otherwise have taken weeks of custom development, while the config-driven design meant missed column references found in testing were fixed by config change rather than deployment. The middleware itself remains closed, deliberately narrow and not open sourced: in-house code for one migration and a dependable library are different bars.

Watch the matchmaking balancing work as the signal worth tracking — shared player pools across formerly platform-split live service games remain rare, and the behavioral data from this one is still being digested.

via postgresql.org (Original)

More from James Calloway

James Calloway

Show full bio

Senior reporter covering money, funding and market shifts around video game industry at Game Dev Wire.

288 articles