Devlog | M13d

Out of sight

Server tick time and memory against the number of players, before and after

Yesterday I filled the town with 300 simulated players to see what the server could take. It held, but its memory grew faster and faster with every player, and the numbers said this server would run out somewhere around 350.

So I went looking for where that memory went. The networking library keeps a short history of everything it sends to each player, so it only has to send what changed. That's sensible, until you notice what was in it: every player's whole backpack. Twenty inventory slots, their gear and their skills, copied into the history of every other player on the server. Nobody else ever needed to see your backpack, so now it isn't in there. Your own inventory comes to you on its own, only when something in it changes.

The other half is distance. In a town the size of Zierikzee, you don't need to know about someone on the other side of the harbour. Now the server only sends you the players, enemies and loot within 150 metres, and lets things go once they're well out of sight, so nothing pops in and out at the edge.

Together, 200 players standing in one spot went from 2.2 GB of memory to 0.7. Spread over the town, the way people actually play, each player now costs about 6 KB a second. Last time, with everyone bunched near the spawn, it was 45.

The simulated players got smarter too. They used to wander around the spawn point. Now they pick a far corner of town and walk there along the real streets, so people keep walking into and out of each other's view, and a real game client walked the same routes the whole time. It never dropped below its frame rate cap.