Full backend rewrite, in Go, of a large-scale MMORPG. Three-service microservices, custom binary protocol, real-time world and combat simulation.
Context
Large-scale MMORPG backend, fully rewritten from scratch in Go. The project was born out of two drivers: pushing concurrency and distributed-system design to their limits, and replacing a legacy Java stack with something simpler, faster, and more maintainable.
Architecture
The system is split into three services (game, auth, chat) communicating over gRPC on a shared MySQL data layer with GORM. Each service has its own lifecycle, its own session state machine, and its own packet router. Most of the game logic lives in game, but auth and chat can scale horizontally on their own.
The client-facing network protocol is binary with custom encryption, and packet routing depends on the session’s current state (handshake, login, in-world, etc.). Every incoming packet is routed to a handler and ends up as an action queued on the player’s actor.
Concurrency
The key piece is the actor model: each player is an actor with an action queue. Client inputs, world events, and effects from other players are processed in order, one at a time, with no need for global mutexes. Game logic stays sane in single-thread and the system scales with number of players rather than with locking complexity.
Simulation
The world is divided into regions with KnownList-based visibility, NPC AI with walking / chase / leash patterns, a combat system with physical and magical damage calculations, 3D geometry with raycasting for line-of-sight, and everything needed around it (inventory, skills, party, alliance, trade, mail, quests, teleports, etc.).
Tooling
The project ships with its own Bash + gum CLI for build, run, debug (Delve), migrations, and cross-compile packaging. Dev hot-reload via air, docker-compose orchestration for dev/prod, and data-loading scripts for the game’s static XML files.