[{"data":1,"prerenderedAt":577},["ShallowReactive",2],{"\u002Fblog\u002Fscaling-minecraft-kubernetes":3},{"id":4,"title":5,"body":6,"date":560,"description":561,"draft":562,"extension":563,"image":564,"meta":565,"navigation":566,"path":567,"seo":568,"stem":569,"tags":570,"__hash__":576},"blog\u002Fblog\u002Fscaling-minecraft-kubernetes.md","Scaling a Minecraft server with Kubernetes",{"type":7,"value":8,"toc":553},"minimark",[9,31,34,37,42,50,68,84,91,95,98,108,121,127,136,156,159,162,180,319,337,344,404,419,423,426,457,506,519,522,526,540,549],[10,11,12,19,20,25,26,30],"p",{},[13,14,18],"a",{"href":15,"rel":16},"https:\u002F\u002Fminebox.co",[17],"nofollow","Minebox"," is a persistent Minecraft RPG. It runs as a fleet of single-threaded Minecraft servers on ",[13,21,24],{"href":22,"rel":23},"https:\u002F\u002Fkubernetes.io",[17],"Kubernetes",", behind proxies that move players between them. Why we split it into a network in the first place is in ",[13,27,29],{"href":28},"\u002Fblog\u002Ffrom-one-server-to-a-network","From one Minecraft server to a network",".",[10,32,33],{},"Kubernetes restarts crashed pods, rolls out new images and keeps replica counts. It doesn't know when a Minecraft server has finished loading its world, whether it has room for another player, or how to move a player to another server without disconnecting them. This post covers how we handle that: the control plane, the in-pod helper, rolling updates, and running the control plane as two replicas.",[10,35,36],{},"A mistake anywhere in this lifecycle can lose player data, for example a pod killed mid-save. This post is about orchestration, not data safety.",[38,39,41],"h2",{"id":40},"why-not-agones","Why not Agones",[10,43,44,49],{},[13,45,48],{"href":46,"rel":47},"https:\u002F\u002Fagones.dev",[17],"Agones"," is the standard answer for game servers on Kubernetes. It allocates a server per match and gives the player an address. For session-based games it's a good default.",[10,51,52,53,57,58,57,61,57,64,67],{},"Minebox works differently. Players connect to a proxy, and the proxy moves them between running servers: spawn, islands, PvP, raids. We run a standing fleet of typed servers (",[54,55,56],"code",{},"SPAWN",", ",[54,59,60],{},"ISLAND_BAMBOO",[54,62,63],{},"PVP",[54,65,66],{},"RAID",", …) instead of allocating one per session. We needed a registry and a scheduler with Minecraft-specific rules:",[69,70,71,75,78,81],"ul",{},[72,73,74],"li",{},"readiness based on game state, not on an open port",[72,76,77],{},"typed servers",[72,79,80],{},"drains that wait for player saves",[72,82,83],{},"health based on TPS",[10,85,86,87,90],{},"Fitting that into Agones would have meant working against its model. So we wrote ",[54,88,89],{},"server_manager",", a Go service that handles discovery, health checks and scaling for our fleet.",[38,92,94],{"id":93},"server-lifecycle","Server lifecycle",[10,96,97],{},"A server boots, registers, sends heartbeats, drains and unregisters. Everything runs over gRPC inside the cluster.",[99,100,105],"pre",{"className":101,"code":103,"language":104},[102],"language-text","        game server pod                         proxies\n  ┌─────────────────────────────┐        ┌────────────────────┐\n  │ boot → load world → RUNNING │        │ routes players     │\n  └──────┬───────────────▲──────┘        │ to READY servers   │\n         │               │               └─────────▲──────────┘\n         │ 1. Register   │ 2. reverse channel      │\n         │ 4. Heartbeat  │    (query, drain,       │ 3. pushes every\n         │    (state,    │     transfer)           │    state change\n         │    players,   │                         │\n         │    TPS)       │                         │\n  ┌──────▼───────────────┴─────────────────────────┴──────────┐\n  │            server_manager · 2 replicas · Redis            │\n  │   registry: SPAWN ×3 · ISLAND ×2 · PVP ×1 …               │\n  │   reserves slots · tracks last-seen · alerts on silence   │\n  └───────────────────────────────────────────────────────────┘\n","text",[54,106,103],{"__ignoreMap":107},"",[10,109,110,114,115,117,118,120],{},[111,112,113],"strong",{},"Registration."," After loading its world, a server registers with ",[54,116,89],{}," with its type, address and state. ",[54,119,89],{}," adds it to the registry and opens a reverse gRPC channel into the server. It uses that channel to query the server, drain it and transfer its players. State changes are pushed to every proxy, so proxies never poll.",[10,122,123,126],{},[111,124,125],{},"Heartbeats."," Each server checks in every few seconds with its state, player count and TPS. When the scheduler sends a player to a server, it reserves the slot immediately instead of waiting for the next heartbeat. Without that, 40 players joining at once would all be sent to the same server. The next heartbeat replaces the reservation with the real count.",[10,128,129,132,133,135],{},[111,130,131],{},"Health."," ",[54,134,89],{}," checks the registry every 3 seconds:",[69,137,138,141,144,150],{},[72,139,140],{},"silent for about 30 seconds: warning and alert",[72,142,143],{},"silent for 60 seconds: removed from routing",[72,145,146,149],{},[54,147,148],{},"STARTING"," servers get a minute before they can be declared dead, because worlds take time to load",[72,151,152,155],{},[54,153,154],{},"DRAINING"," servers don't trigger the warning, because they're expected to go quiet",[10,157,158],{},"Removing a server on the first missed heartbeat would take healthy servers out during a GC pause.",[38,160,161],{"id":161},"convoy",[10,163,164,165,170,171,176,177,179],{},"Kubernetes ",[13,166,169],{"href":167,"rel":168},"https:\u002F\u002Fkubernetes.io\u002Fdocs\u002Fconcepts\u002Fconfiguration\u002Fliveness-readiness-startup-probes\u002F",[17],"probes"," and ",[13,172,175],{"href":173,"rel":174},"https:\u002F\u002Fkubernetes.io\u002Fdocs\u002Fconcepts\u002Fcontainers\u002Fcontainer-lifecycle-hooks\u002F",[17],"lifecycle hooks"," know nothing about worlds, players or saves. Each game server pod includes ",[54,178,161],{},", a small binary that the probes and hooks call:",[99,181,185],{"className":182,"code":183,"language":184,"meta":107,"style":107},"language-yaml shiki shiki-themes min-dark min-dark","readinessProbe:\n  exec: { command: [\"\u002Fopt\u002Fserver\u002Fconvoy\", \"--state=RUNNING\"] }\n  initialDelaySeconds: 60\n  periodSeconds: 5\nlivenessProbe:\n  exec: { command: [\"\u002Fopt\u002Fserver\u002Fconvoy\", \"--check\"] }\n  initialDelaySeconds: 90\n  periodSeconds: 30\n  failureThreshold: 5\n","yaml",[54,186,187,200,235,246,257,265,289,299,309],{"__ignoreMap":107},[188,189,192,196],"span",{"class":190,"line":191},"line",1,[188,193,195],{"class":194},"sCQh8","readinessProbe",[188,197,199],{"class":198},"sOPea",":\n",[188,201,203,206,209,213,216,218,221,225,229,232],{"class":190,"line":202},2,[188,204,205],{"class":194},"  exec",[188,207,208],{"class":198},":",[188,210,212],{"class":211},"sFR8T"," { ",[188,214,215],{"class":194},"command",[188,217,208],{"class":198},[188,219,220],{"class":211}," [",[188,222,224],{"class":223},"s-3mD","\"\u002Fopt\u002Fserver\u002Fconvoy\"",[188,226,228],{"class":227},"sQKTl",",",[188,230,231],{"class":223}," \"--state=RUNNING\"",[188,233,234],{"class":211},"] }\n",[188,236,238,241,243],{"class":190,"line":237},3,[188,239,240],{"class":194},"  initialDelaySeconds",[188,242,208],{"class":198},[188,244,245],{"class":194}," 60\n",[188,247,249,252,254],{"class":190,"line":248},4,[188,250,251],{"class":194},"  periodSeconds",[188,253,208],{"class":198},[188,255,256],{"class":194}," 5\n",[188,258,260,263],{"class":190,"line":259},5,[188,261,262],{"class":194},"livenessProbe",[188,264,199],{"class":198},[188,266,268,270,272,274,276,278,280,282,284,287],{"class":190,"line":267},6,[188,269,205],{"class":194},[188,271,208],{"class":198},[188,273,212],{"class":211},[188,275,215],{"class":194},[188,277,208],{"class":198},[188,279,220],{"class":211},[188,281,224],{"class":223},[188,283,228],{"class":227},[188,285,286],{"class":223}," \"--check\"",[188,288,234],{"class":211},[188,290,292,294,296],{"class":190,"line":291},7,[188,293,240],{"class":194},[188,295,208],{"class":198},[188,297,298],{"class":194}," 90\n",[188,300,302,304,306],{"class":190,"line":301},8,[188,303,251],{"class":194},[188,305,208],{"class":198},[188,307,308],{"class":194}," 30\n",[188,310,312,315,317],{"class":190,"line":311},9,[188,313,314],{"class":194},"  failureThreshold",[188,316,208],{"class":198},[188,318,256],{"class":194},[10,320,321,324,325,328,329,332,333,336],{},[54,322,323],{},"convoy --state=RUNNING"," asks the local game server for its state and exits ",[54,326,327],{},"0"," only when it's ",[54,330,331],{},"RUNNING",": the world is loaded and the server can take players. The pod only receives traffic after that. The usual Minecraft health check, pinging port ",[54,334,335],{},"25565",", only tells you the port is open.",[10,338,339,340,343],{},"The drain runs as the ",[54,341,342],{},"preStop"," hook:",[99,345,347],{"className":182,"code":346,"language":184,"meta":107,"style":107},"lifecycle:\n  preStop:\n    exec:\n      command: [\"\u002Fopt\u002Fserver\u002Fconvoy\", \"--terminate\", \"--copy-crashes\"]\nterminationGracePeriodSeconds: 300\n",[54,348,349,356,363,370,394],{"__ignoreMap":107},[188,350,351,354],{"class":190,"line":191},[188,352,353],{"class":194},"lifecycle",[188,355,199],{"class":198},[188,357,358,361],{"class":190,"line":202},[188,359,360],{"class":194},"  preStop",[188,362,199],{"class":198},[188,364,365,368],{"class":190,"line":237},[188,366,367],{"class":194},"    exec",[188,369,199],{"class":198},[188,371,372,375,377,379,381,383,386,388,391],{"class":190,"line":248},[188,373,374],{"class":194},"      command",[188,376,208],{"class":198},[188,378,220],{"class":211},[188,380,224],{"class":223},[188,382,228],{"class":227},[188,384,385],{"class":223}," \"--terminate\"",[188,387,228],{"class":227},[188,389,390],{"class":223}," \"--copy-crashes\"",[188,392,393],{"class":211},"]\n",[188,395,396,399,401],{"class":190,"line":259},[188,397,398],{"class":194},"terminationGracePeriodSeconds",[188,400,208],{"class":198},[188,402,403],{"class":194}," 300\n",[10,405,406,407,410,411,414,415,418],{},"Before Kubernetes stops the pod, ",[54,408,409],{},"convoy --terminate"," copies crash dumps to a ",[54,412,413],{},"crash-dumps"," PVC so they survive the pod, then calls ",[54,416,417],{},"Drain"," on the server. The 300-second grace period gives the drain time to move players and save.",[38,420,422],{"id":421},"rolling-updates","Rolling updates",[10,424,425],{},"We roll out new images, config, worlds and plugins without disconnecting players:",[427,428,429,432,444,449,454],"ol",{},[72,430,431],{},"Kubernetes starts a new pod. It loads its world, registers and becomes ready.",[72,433,434,435,437,438,440,441,443],{},"Kubernetes marks an old pod for termination. ",[54,436,409],{}," runs and the server switches to ",[54,439,154],{},". ",[54,442,89],{}," tells the proxies to stop sending new players to it, and the load balancer stops selecting it.",[72,445,446,448],{},[54,447,89],{}," transfers the old pod's players to the new pod. Players stay connected to the proxy the whole time; only the server behind it changes.",[72,450,451,453],{},[54,452,161],{}," waits for the old pod to reach 0 players, waits 15 seconds for saves, and exits. If players remain, it keeps waiting, up to the 300-second grace period.",[72,455,456],{},"The old pod terminates.",[99,458,460],{"className":182,"code":459,"language":184,"meta":107,"style":107},"strategy:\n  type: RollingUpdate\n  rollingUpdate:\n    maxSurge: 10%\n    maxUnavailable: 25%\n",[54,461,462,469,479,486,496],{"__ignoreMap":107},[188,463,464,467],{"class":190,"line":191},[188,465,466],{"class":194},"strategy",[188,468,199],{"class":198},[188,470,471,474,476],{"class":190,"line":202},[188,472,473],{"class":194},"  type",[188,475,208],{"class":198},[188,477,478],{"class":223}," RollingUpdate\n",[188,480,481,484],{"class":190,"line":237},[188,482,483],{"class":194},"  rollingUpdate",[188,485,199],{"class":198},[188,487,488,491,493],{"class":190,"line":248},[188,489,490],{"class":194},"    maxSurge",[188,492,208],{"class":198},[188,494,495],{"class":223}," 10%\n",[188,497,498,501,503],{"class":190,"line":259},[188,499,500],{"class":194},"    maxUnavailable",[188,502,208],{"class":198},[188,504,505],{"class":223}," 25%\n",[10,507,508,509,514,515,518],{},"As a ",[13,510,513],{"href":511,"rel":512},"https:\u002F\u002Fkubernetes.io\u002Fdocs\u002Fconcepts\u002Fworkloads\u002Fcontrollers\u002Fdeployment\u002F#rolling-update-deployment",[17],"Deployment rolling update",", new pods are created before old ones are removed, and a rollout never takes more than 25% of a server type offline. Each Deployment has a ",[54,516,517],{},"restart-group"," label, so we can roll a whole class of servers, such as all islands, as one wave without dropping below the capacity the fleet needs.",[10,520,521],{},"The drain is the slow part. A pod with 20 players takes as long as those 20 players take to move and save. We accept that, because rushing it risks player data.",[38,523,525],{"id":524},"two-replicas","Two replicas",[10,527,528,530,531,536,537,539],{},[54,529,89],{}," runs as two replicas. The registry lives in ",[13,532,535],{"href":533,"rel":534},"https:\u002F\u002Fredis.io",[17],"Redis",", and each replica keeps an in-memory copy for routing, synced through pub\u002Fsub. A replica loads the registry before it starts serving, so restarting or deploying ",[54,538,89],{}," doesn't affect players. One replica holds a leader lock in Redis and runs the fleet-wide jobs, like health checks, so each server is checked once.",[10,541,542,543,548],{},"Questions, or a different approach? I'm ",[13,544,547],{"href":545,"rel":546},"https:\u002F\u002Fx.com\u002Fimevlad",[17],"@imevlad"," on X.",[550,551,552],"style",{},"html pre.shiki code .sCQh8, html code.shiki .sCQh8{--shiki-default:#F8F8F8;--shiki-dark:#F8F8F8}html pre.shiki code .sOPea, html code.shiki .sOPea{--shiki-default:#F97583;--shiki-dark:#F97583}html pre.shiki code .sFR8T, html code.shiki .sFR8T{--shiki-default:#B392F0;--shiki-dark:#B392F0}html pre.shiki code .s-3mD, html code.shiki .s-3mD{--shiki-default:#FFAB70;--shiki-dark:#FFAB70}html pre.shiki code .sQKTl, html code.shiki .sQKTl{--shiki-default:#BBBBBB;--shiki-dark:#BBBBBB}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":107,"searchDepth":202,"depth":202,"links":554},[555,556,557,558,559],{"id":40,"depth":202,"text":41},{"id":93,"depth":202,"text":94},{"id":161,"depth":202,"text":161},{"id":421,"depth":202,"text":422},{"id":524,"depth":202,"text":525},"2026-10-31","How Minebox runs Minecraft servers on Kubernetes: a replicated control plane, an in-pod helper for probes and drains, and rolling updates without disconnects.",false,"md","\u002Fimages\u002Fog\u002Fscaling-minecraft-kubernetes.png",{},true,"\u002Fblog\u002Fscaling-minecraft-kubernetes",{"title":5,"description":561},"blog\u002Fscaling-minecraft-kubernetes",[571,572,573,574,575],"minecraft","kubernetes","golang","devops","continuous-deployment","9T_PXTJZiMdiepqV8AiZIVDN4Hw_3UXfgwjAVxN-T4c",1793424336535]