All work

Platform and reliability

On-demand game servers on Kubernetes at Stratus Network

At Stratus I led part-time developers, planned an infrastructure rewrite, and built a worker that starts private game servers on Kubernetes on request.

Stratus Network, LLC · Senior Software Development Engineer · Aug 2018 – Aug 2019

The problem

Stratus ran on a big legacy codebase with little to no documentation, maintained by part-time developers spread across time zones. Players also wanted private servers they could request for their own matches, and there was no way to give them one without staff starting it by hand.

What I did

  1. Playerasks for a server
  2. Workerfinds or claims a spare
  3. KubernetesService and Pod created
  4. Replyproxy name and status
  5. Every minuterestart idle, keep a spare

How a request is handled

A sketch of the idea, not the production code.

on UseServerRequest(user, name):
    server = Server.find_by(name)
        ?? (Server.free_for_requests.first ?? create_server()).claim(user, name)
    if not pod_running_or_pending(server):
        k8s.create(headless_service(server))
        k8s.create(pod(server, image = "minecraft:bukkit-master",
                       readiness = "run.rb ready?", liveness = "run.rb alive?"))
    reply(UseServerResponse(server.bungee_name, now = server.online?))

every 1 minute:
    for s in owned_servers:
        if s.online? and s.empty_for > 10 minutes: queue_restart(s)
    if Server.free_for_requests.empty?: create_server()

on ModelUpdate(server) where server.owned? and not server.online?:
    k8s.delete(pod(server)); k8s.delete(service(server))

Stack

Links