← All posts

MiniMMO: a game server aiming for 10,000 players, kept simple

Load, optimization, server-side logic, concurrency and security: the constraints of my small C# MMO, the solutions I use and what is left to fix.

  • C#
  • .NET
  • WebSockets
  • Redis
  • Postgres
  • Games

MiniMMO is a multiplayer survival game: you walk, fish, mine, chop wood, cook, fight, sail and trade with other players. The client is written in TypeScript with Phaser, the server in C#. I started it in September 2026 and it is still in development.

The design goal: about 10,000 players connected at once. I haven't load tested it yet, so that number is still a target. It shapes every decision anyway.

The game in pictures

These screenshots come from a local instance, with staged characters.

Creating a character

Pick hair, eyes and skin. The server validates the appearance it receives.

The character creation screen

Non-player characters

Every town hall has a merchant, a money changer, a banker and a postmaster. A single list defines them for all towns.

Four non-player characters inside a town hall

Chat

Messages are only sent to nearby players.

Three players talking with speech bubbles

The store

Prices come from the server's catalog, and you have to stand near the merchant.

The general store buy and sell window

The money changer

Rates follow supply and demand, with a 5% cut. They survive restarts.

The money changer window with its rates

The bank

The same vault is available in every town.

The bank window: bag and vault

Player trading

Both players must stand next to each other and confirm the same offer.

A trade in progress between two players

Inventory

Equipment, stats and carried weight in one place.

The inventory with equipment and carried weight

Fishing

You need a rod and water right next to you. Catches come over time and train the skill.

A fish jumps out of the water at the end of the line

Woodcutting

Fell the tree, pick up the logs, and the forest eventually grows back.

A character hitting a tree with an axe

Gathering

Berries grow back after a delay.

A character picking berries from a bush

Mining

Underground, you need your own light to see the rocks and the rats.

A character striking a rock with a pickaxe in a dark cave

Crafting

The server checks the ingredients. For now there is a single recipe: a campfire, from three logs.

The crafting panel with the campfire recipe

Cooking

Next to a fire, raw food can be cooked. Food eventually spoils.

The menu to cook a fish next to a campfire

Combat

Hits land or miss, and monsters fight back. Crouching lets you sneak up.

A fight against a crow, with damage numbers

Sailing

Buy a sailboat from the shipwright; its speed depends on the wind.

A sailboat near a pier, with the wind indicator

The world map

The 20 towns are named after places in Gaspésie, with their harbours.

The world map with town names

The architecture

One ASP.NET Core server, one WebSocket per player, and two databases.

  • In memory: all the live game state.
  • Redis: characters and world state.
  • Postgres: accounts.

No microservices, no message queue. Until measurements show that one process isn't enough, one process is simpler to understand, debug and test.

The server decides everything

The basic rule: the client sends intentions, never results. “I want to go there”, “I'm buying this item from this merchant”. The server checks distance, price, money and bag space, then acts.

Movement shows why this matters:

  • the received direction is normalized and invalid values are rejected: sending a bigger vector doesn't make you faster;
  • speed is computed by the server;
  • a held direction expires after 700 ms without a refresh;
  • a lagging server never simulates more than 100 ms at once, so nobody gets teleported;
  • for a click on the map, the server plans the path itself (A*), with a cap on explored tiles so an unreachable goal can't stall it.

A concrete difficulty: two steps sent at a regular interval can arrive bunched together because of the network. A strict check dropped them and the character stuttered. The fix is a small 40 ms grace period: enough to absorb jitter, too little to cheat in any useful way.

Load: only talk to neighbours

If every action is sent to everyone, cost explodes with the number of players. So the map is split into chunks of 8 × 8 tiles. A player only hears about what happens within two chunks, a 40 × 40 tile window.

The same split is used for ground items, trees, rocks and campfires. Cost depends on local density, not on the total number of players.

Same idea for compute time: the movement loop, which runs every 40 ms, only visits players who are moving.

Sending less: dead reckoning

At first, each walking player generated about 25 position packets per second for each neighbour.

But someone walking goes in a straight line most of the time. The server now sends a position and a velocity only when the velocity changes (start, turn, wall, stop), with a resync every 400 ms. A packet also goes out on each tile change, about 6 per second.

Between messages, the client walks the character itself:

  • a small error is eased out over about 120 ms;
  • a gap of more than 2 tiles is treated as a teleport;
  • after 1 second without news, the character stops.

The server still simulates everything. Only the way it reports it changed.

Sleeping when nobody is watching

The world holds hundreds of monsters. A resting monster with no player nearby only costs a few dictionary lookups.

The trap was elsewhere. To know whether a tile was occupied, the server had to search the monsters of the surrounding chunks, and since they roam away from their spawn point, that area got large, repeated for every tile of a path. A plain “who is on which tile” index solved it.

A world of 9.7 million tiles

The main map is 4400 × 2200 tiles: two continents, an ocean and 20 towns. The image at the top of this post comes from it.

It is generated from a seed and run-length encoded into a file of about 2.25 MB. The server and the client read the same file, so they can't disagree about where a wall is. The client only draws the chunks near the camera.

Two problems along the way: the browser kept old maps cached during development (fixed by forcing revalidation), and saves from the old small map must not apply to the new one (fixed with a version in the Redis key).

Concurrency: two players, one item

This is where the most expensive bugs hide, such as item duplication.

  • Picking up: the item is locked, so two players can't get the same stack.
  • Trading: both must confirm, any change withdraws the confirmations, and everything is checked again at the moment of the swap. Locks are taken in a fixed order to avoid deadlocks.
  • Joining: an account has a single character in game, reserved atomically. The slot is released even if the disconnect cleanup fails, so an account never gets stuck.
  • Character names: adding to a Redis set is atomic, so a name can't be taken twice.

Persistence

Writing to the database on every step would be needlessly expensive. State lives in memory and is saved every 15 seconds, on disconnect and on server shutdown. On a deliberate logout, the save happens before the client gets its confirmation.

The world is only rewritten if it changed: an idle world generates no Redis traffic.

Security

  • Passwords hashed with BCrypt, with the same response time whether or not the account exists.
  • Signed tokens with an 8-hour lifetime and a pinned algorithm.
  • Before opening the game connection, the server checks that the character belongs to the account.
  • Parameterized SQL queries.
  • Admin commands are checked server-side on every call.
  • Chat is sanitized, limited to 120 characters and one message per 700 ms.

Tests

Every change comes with tests. The project has over a hundred test files that run against a separate instance with its own throwaway world. That is essential, not least because I build it with coding agents: the tests are the guardrail.

What's left before 10,000 players

  • Slow clients. The game loop waits for sends to finish, so one player on a slow connection can delay others. Next step: a bounded send queue per connection.
  • Serialization. The same message is turned into JSON once per recipient. Once would be enough.
  • Saves. Characters are written one by one; they will need batching.
  • Tile changes. Their packets can still be reduced.
  • A load test with simulated players, to replace assumptions with measurements.
  • Before opening to the public: encrypt connections and tighten rate limits and access.

The order matters: measure first, optimize second.