How World War Heroes merged 100m+ player accounts and reshaped matchmaking
- Last Level Games migrated more than 100 million World War Heroes player accounts across iOS and Android into a shared server.
- The larger player pool improved matchmaking quality but initially reduced player satisfaction as players faced more real opponents instead of bots.
Mikhail Orlov is a developer at Last Level Games.
We migrated over 100 million World War Heroes player accounts from two separate game platforms - iOS and Android - into a single shared server. The databases had overlapping IDs in every table, and the social graph meant we couldn't move users one by one. We needed under two hours of planned downtime, the ability to roll back, and a way for QA to test on real production data before release.
This article covers how we solved it using Postgres logical replication with a custom middleware layer that transforms data on the wire. You'll see how we handled the ID offset scheme across regions, the business logic edge cases we didn't expect, and what went wrong on release night, and how the merge unexpectedly changed matchmaking quality.
The problem
Background:
Our game, WWH, runs on both iOS and Android. For historical reasons, these two platforms always had completely separate backend infrastructure - separate servers, separate databases, separate everything. At some point we decided to merge both platforms into a single server with one shared player pool.
Each platform had 11 databases per region, with game data on the main cluster and statistics on a separate one. Three regions: EU, NA and AS. Around 50 tables total per platform. Total data volume: 4.8 TB on the largest EU server alone, over 9 TB combined. Everything ran on Postgres 13.
QA needs to test the merged result on real production data before players see it.
Every entity in every table on both platforms had overlapping primary keys. User ID 1 on iOS is a different person than user ID 1 on Android, and the same goes for clan IDs, item IDs, weapon IDs, transaction IDs - everything. You can't just dump one platform's data into the other.
Beyond the raw ID conflicts, users could register via Facebook, and the same Facebook account might exist on both platforms. Players have social connections - friendships, clan memberships, in-game mail, chat history. You can't migrate users in isolation without breaking the social graph.
Hard constraints:
-
Maximum 1-2 hours of downtime
-
Rollback must remain possible if something breaks at release
-
QA needs to test the merged result on real production data before players see it
What we considered
Background migration at login. Shift data gradually as users authenticate. Minimal downtime in theory, but the implementation complexity is high. No clean rollback, no way to test on production data, and any data bug affects live users immediately.
Real-time migration at cutover. After a predefined cutoff time, migrate user's entire datasets on login. Same problems: no rollback, no pre-testing, and this approach dumps heavy migration work onto the system at exactly the moment when login traffic is highest.
What Postgres doesn't give you is data transformation in transit.
Script-based background migration. A process runs continuously, migrating users in the background. More controllable - rollback is possible by simply not switching traffic, and you can test the target database. But now you need custom infrastructure to track migration state across 11 databases, handle partial failures, retries, and crash recovery reliably - for a process that has to run for potentially weeks on live data.
Debezium. A solid CDC tool built on top of Postgres logical replication. It captures changes and streams them to Kafka. But for our use case, it would bring significant operational overhead: a JVM service and a Kafka cluster to run and monitor.
Transformation logic would have to be implemented separately from the replication setup. And ultimately Debezium is designed for general-purpose event streaming, not for a one-time migration with complex custom transformation rules defined per column in a known fixed schema.
None of these felt like the right fit.
The approach
The right foundation:
Logical replication works at the row level using a publish/subscribe model. You create a publication on the source listing which tables to expose, and a subscription on the target that connects to it. The subscriber receives the current data snapshot, then a continuous stream of changes.
What Postgres doesn't give you is data transformation in transit. User ID 1 arrives as user ID 1.
So we built a thin middleware layer that sits between publisher and subscriber and rewrites data on the wire. Postgres handles every hard part. The middleware handles only the transformation.
ID offset strategy
The core transformation is simple: add a fixed offset to every ID and every foreign key reference to that ID.
Every entity had to be modified - not just users and clans, but weapons, items, inventory entries, transactions, battle logs, notifications, mail - anything with a primary key and everything that referenced those keys. Across ~50 tables per platform, the config covered all of it.
Rather than picking arbitrary offsets, we designed them to be useful beyond this migration. We might eventually want to merge regional servers (EU, NA, AS) into a single global server. If each region's data lands in a non-overlapping numeric range, a future regional merge would require only standard logical replication - no middleware, no transformation. So the offsets were designed with room for each region.
There's no iOS row for AS: the region never had an iOS build, so there was nothing to merge there. We shifted the Android AS IDs anyway - partly to keep every region on the same scheme, and partly because players grow attached to their user IDs. Leaving one region on its original numbers while everyone else's ID changed is the kind of thing players notice and read as unfair.
Why not UUIDs? They would have removed the collisions entirely. We didn't go that way for two reasons, one practical and one technical.
Normally, the game doesn't allow two accounts with the same Facebook credential per region - the auth service enforces a unique constraint.
The practical one: user IDs and clan IDs in this game are player-facing. Players share user IDs in support tickets, type clan IDs to join, and reference them in community posts. A UUID isn't something players can realistically type. An offset doesn't change that - the IDs stay short and numeric.
The technical one: the codebase is large and spans multiple services. Changing a column type from int64 to uuid.UUID in Go isn't just a schema migration - it touches every struct, every query, every service boundary that handles those values. The offset approach required only infrastructure changes. Application code didn't change at all.
Business logic edge cases
Two things didn't fit neatly into the offset model.
Facebook authentication. Normally, the game doesn't allow two accounts with the same Facebook credential per region - the auth service enforces a unique constraint. But before the merge, the same Facebook account could exist on both iOS and Android. After merging, this would be a constraint violation.
Our solution: during replication, all iOS Facebook credentials are renamed from facebook to facebook-ios. The unique constraint holds. For players who had accounts on both platforms before the merge, we added an account selection screen at login - they pick which account to continue with. After the merge date, no new duplicate accounts are possible.
Clan names and tags. Clan names must be unique within a platform, but there was no cross-platform uniqueness requirement before. After merging, some would collide.
Each source goes through its own middleware instance with its own offset, and the merged database ends up with no overlap.
We considered force-renaming all iOS clans during migration. But when we actually looked at the data, there were very few conflicts - and most were the same person who had created a clan on both platforms with the same name. Force-renaming would have been disruptive for almost no benefit.
Instead: we kept all clan data intact and applied uniqueness checks on write. If a clan has a name or tag that collides with another clan in the merged database, the clan owner can't modify clan settings (name, tag, colour, beacon, etc.) until one of the conflicting clans resolves the collision. New clans can't take conflicting names at all.
The middleware
The subscriber thinks it's talking to a Postgres server. The publisher thinks it's talking to a Postgres client. The middleware sits in the middle, speaking both sides of the wire protocol simultaneously.
Both platforms number their entities from 1, so every ID collides. Each source goes through its own middleware instance with its own offset, and the merged database ends up with no overlap.
Each middleware instance is a TCP server built on top of jackc/pgx/v5/pgproto3. On the subscriber side, it acts as a Postgres backend - it receives the startup message, handles SSL negotiation, and proxies all authentication messages to the real publisher and back. The subscriber never knows it isn't talking to a real Postgres server.
On the publisher side, it acts as a Postgres frontend client. Two goroutines run bidirectionally: one forwarding subscriber→publisher, one forwarding publisher→subscriber.
Getting it live
Testing:
Before doing anything with the real production setup, we ran the complete migration against a full dump of the production database in a staging environment. This is where most missed foreign key references were found - we'd transform the data, try to start the application against it, and watch what broke.
We also wrote comparison scripts that ran against both source and target databases simultaneously - checking that ID offsets were applied consistently, JSON fields were modified correctly, Facebook credential renames happened, and that record counts matched. Running these against actual production data (not synthetic) caught edge cases that staged data wouldn't have surfaced.
QA ran a full test plan against the migrated production dump before the actual release.
Infrastructure and bonus migrations
New merged databases were created from scratch with sequences set as described earlier. This was also the opportunity to upgrade the Postgres version on the target databases - logical replication works across versions.
Green app instances were deployed pointing at the merged databases, visible only to QA.
The replication setup also let us reorganise where tables live. Some tables that had gradually ended up in the main cluster were replicated directly into the stats cluster instead. The middleware didn't need to change for this - you just point the publication and subscription at different source and target databases, and the data lands where you want it.
Replication was started weeks before the release date. The initial snapshot copy of the EU server alone took over 20 hours. We didn't care - we started early enough that it finished well before release week, and the system had been streaming changes with millisecond-level lag for several days prior to release.
What wasn't in scope
Two things needed separate work that the middleware didn't cover.
Client-side integer size. The backend Go code already used int64 everywhere for entity IDs, so no server-side changes were needed. Mobile clients used int32 for user IDs in their data models. Those had to be updated in a client release to handle the larger post-offset values.
External services with stored IDs. Several external services stored user IDs in their own databases. After the merge, their callbacks carried pre-offset IDs. We implemented ID converters in our webhook handlers that translated old IDs to new IDs on the fly, and kept them running until each external service updated its stored data.
Release day
Before release: Green app instances were deployed pointing at the merged databases, visible only to QA. Blue instances remained live for all players. Session versioning already in place prevented players from accidentally hitting Green - the version check rejected them. QA ran the full test plan against the real production data after migration.
Cutover:
-
Stop Blue app instances, wait for graceful shutdown
-
Update configs to point at the new databases
-
Verify replication lag is zero
-
Open Green to all players
Actual downtime: under 15 minutes.
Afterwards
What the merge did to matchmaking:
Within a few weeks, matchmaking quality shifted in unexpected ways. With a larger combined player pool, the algorithm started filling rooms with real players rather than bots far more often than before. Match quality went up, K/D ratios dropped - and player satisfaction dropped too. People were used to winning more often.
The matchmaking parameters had been tuned for a smaller pool. We had to revisit the balancing logic. A good problem to have after a migration like this, but it was a reminder that merging the infrastructure had real gameplay consequences that needed their own follow-up work.
The incident:
On release night, a Patroni failover occurred in the datacenter. A replica was promoted to primary. The replication slots didn't survive the transition.
it was a really interesting challenge - one that taught us a lot along the way and gave us experience worth sharing.
The slots were gone. We had to restart main data replication from scratch, under pressure, in the middle of the night. Stats replication didn't finish within the planned window and completed after players were already on the new servers.
How to fix: configure permanent replication slots in Patroni, so they survive primary transitions. This requires explicit configuration - Patroni doesn't do it automatically.
There's a good write-up on how to set it up here: How Patroni Addresses the Problem of the Logical Replication Slot Failover in a PostgreSQL Cluster. Set it up before release day. We learned that the hard way.
Looking back
That was more than a year ago, and the merged databases have been in production ever since. Nothing from the migration has surfaced in that time.
The logical replication approach worked well here. The built-in Postgres machinery - LSN tracking, crash recovery, consistent snapshots, conflict detection - handled functionality that would otherwise have taken weeks of careful custom development. The middleware only had to solve the transformation part.
The config-driven design meant that when we found a missed column reference in testing, the fix was a config change and not a deployment. The declarative format also made it easy to review the complete set of transformations before release.
The tool stayed narrow on purpose: protocol edge cases we knew wouldn't come up were never handled, and it isn't open source. In-house code for one migration and a library other people can depend on are different bars.
Overall, it was a really interesting challenge - one that taught us a lot along the way and gave us experience worth sharing.