Sharding a Minecraft world: the architecture
How Mosaic splits one Minecraft world across several servers: a coordinator, shards and a proxy, ownership by chunk claims, and leases with fencing epochs so that every chunk has exactly one writer.
Three moving parts
- The coordinator decides who owns what. It grants ownership leases, watches load, and moves chunks between shards when the load gets uneven.
- Shards are servers running a Folia fork. Each one ticks only the chunks it owns, split into Folia regions that each run their own tick loop on their own thread. It keeps a read-only mirror of its neighbours' chunks along every border.
- The proxy (Velocity) holds every player's connection. When a player moves to another shard, the proxy swaps their backend without the client noticing.
Ownership by chunk claims
By default the world is handed out in sections of 16×16 chunks, because a section is a cheap unit to lease and to move. Sections aren't a hard limit, though. A shard can claim individual chunks or carve a piece out of a section, so it can own exactly the chunks its regions tick. The coordinator places each region whole on one shard and keeps borders in idle ground, where nobody is ticking and a border costs nothing. Only a crowd too big for one shard gets cut.
Inside a shard nothing changes from Folia: only chunks near players tick, and separate groups of ticking chunks form separate regions with their own tick loops. A shard's tick time is set by its busiest region, not by the sum of everything it owns.
Leases, fencing epochs and the journal
Moving ownership is where split-brain bugs live. Two servers that both think they own a chunk will both write to it, and the world forks. Mosaic grants ownership as a lease, and every lease comes with a fencing epoch: a number that only ever goes up. Every write carries the epoch it was made under, and storage rejects any write with an older epoch than it has already seen. A shard that froze for a few seconds and woke up still believing it owns a chunk can try to write, but it can't succeed.
The journal records each grant and each saved hand-over. When a shard dies, its lease runs out, and the shards next to it take its chunks over from what was last committed to storage, under new epochs.
Moving chunks while people stand on them
When the load is uneven, the coordinator re-carves the claims and moves the chunks that changed hands. Every move runs in four steps: the current owner freezes the chunks, saves them, hands them over under a new epoch, and the new owner resumes ticking. The freeze covers only the chunks being moved, never the whole shard.
Some crowds are too dense to split by area. If a thousand players stand in one spot, no border fixes it. For that case a chunk becomes a replicated zone: players are spread across several shards, one shard ticks the blocks and mobs, and the others hold full replicas and forward player actions to it. A per-client visibility cap means each client only gets its nearest players, so a dense crowd doesn't flood everyone's connection.