Why Honor of Kings Avoids Microservices: Real-Time Game Architecture Explained
This article analyzes why real-time multiplayer games like Honor of Kings reject microservices, citing latency sensitivity, stateful game sessions, sticky routing needs, and the mismatch between microservice patterns (stateless, request/response) and game server requirements (streaming, in-memory state, single-threaded Netty models).
Background
The author interviewed at a listed game company and asked about microservice adoption plans. The interviewer had never heard of microservices; after a brief explanation covering easier testing, maintenance, upgrades, loose coupling, polyglot development, and auto-scaling, the interviewer responded that game servers don't need microservices because they require real-time performance and modular development within a single process is sufficient.
Answer from hongjic93 (Zhihu)
Core Insight: MOBA Games Are About High-Speed Small-Group Communication
Honor of Kings is a MOBA (Multiplayer Online Battle Arena). Peripheral systems — account, rune, hero, skin, friend, messaging — could use microservices if traffic demanded. The core is 10 players exchanging game events at high speed via streaming, broadcast, multicast, and pub/sub patterns. An extra 10 ms of latency makes players complain.
Three Technical Reasons Microservices Fail for Game Cores
Network Overhead : Microservices split in-process modules into separate services, adding significant network latency. Service mesh, gateways, proxies, and sidecars only make latency worse.
Request/Response vs Streaming : Microservices are built around request/response. Game cores need continuous streaming with state. Microservices assume statelessness for horizontal scaling; streaming inherently introduces state.
Sticky Routing vs Stateless Scaling : A single match's 10 players are best served by one server so data exchanges stay in local memory, maximizing performance. This requires sticky routing (client reconnects to the same server). Microservices' stateless, horizontal-scaling model is fundamentally anti-sticky because sticky routing is state.
Long-Lived In-Memory State
A match lasts 20+ minutes with persistent state: towers destroyed, kill counts, super-god status, time elapsed. This state lives in memory until the match ends. Moving it to Redis would add a remote request per event, increasing latency. Example: every attack on a crystal is an event streamed to the server's sandbox; a stream processor instantly recalculates crystal health. Storing crystal HP remotely is impossible for the required speed.
Optimization Focus
Such games optimize network, memory, and CPU. During a match, almost no RPC calls occur; any remote data is prefetched at match start. Microservices are not a silver bullet — they mainly help decompose simple CRUD apps, not high-interaction, stateful distributed systems. The perception that microservices transformed the internet exists because 90% of internet apps are simple CRUD.
Answer from brice (Card Game Experience)
Business Complexity : Microservices address complex business logic and organizational interfaces. Game logic is simpler; lobbies handle basic account functions, while the game itself runs its own logic.
Stateful Game Servers : Game servers (e.g., Dou Dizhu) are stateful for latency sensitivity. State stays in memory; Redis/MySQL are only used for async periodic persistence. Synchronous DB access is unacceptable.
Push Model & Protocols : Game servers need active push. First-gen microservice gateways don't support TCP; Spring Cloud Gateway's WebSocket might work but TCP is preferred for anti-attack in PC games.
RPC & Message Ordering : HTTP-based RPC (Ribbon, Feign) risks message reordering (e.g., two card plays arriving out of order). Game clusters use persistent TCP connections; Dubbo (long-lived connections) is a candidate.
Thread Model : Spring MVC's multi-threaded model performs poorly and adds complexity for game loops. Game servers use single-process/thread driving fixed room counts (Netty), which is why they are stateful and cannot directly read/write MySQL.
Auto-Scaling = Opening Servers : Games have fixed procedures, tools, and rate-limiting for launching new servers ("opening servers"), not dynamic cloud auto-scaling.
No Graceful Degradation : Game operations cannot degrade; failures must return errors directly to users.
Lobby Services : Login/registration could use microservices, but fixed launch schedules and operational controls make service discovery unnecessary. Shutdowns are strictly controlled.
Traffic Scale : 10k concurrent users in a card game is very profitable; 100k is a hit. Traffic is far below typical web scale.
Payment Services : Recharge systems might need microservices, but that's a "good problem to have".
brice notes Spring Cloud could be adapted for game clusters (registration, discovery, orchestration) but lacks game-specific design: full WebFlux support, single-threaded long-connection protobuf RPC with service discovery, TCP gateway exposing Netty encoders/decoders, etc.
Code example
1.
我的私密学习小圈子,从0到1手撸企业实战项目~
2.
LatchUtils:简化 Java 异步任务同步的利器
3.
网易二面:CPU狂飙900%,该怎么处理?
4.
比 VMware 更快,更轻的虚拟机,横空出世!Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
