Skip to content

Map sync: every server on one clock

During a Kacky Reloaded event, every server plays the same maps in the same order. Every server switches to its next map at the same moment. So the whole fleet runs on one schedule. You can look at the clock and know which map is on which server, now and in an hour.

One rotation, shifted per server

Every server plays the full map list of the event, in the same order. Each server starts at a different place in that list. With 75 maps and 15 servers, each server is 5 maps ahead of the one before it.

Server Plays now Plays next
1 map 1 map 2
2 map 6 map 7
3 map 11 map 12
... ... ...
15 map 71 map 72

At any moment, no map runs on two servers. And every map comes around on some server about once an hour. If you missed a map, you do not wait for one server to get back to it. You go to the server that gets it next.

Slots: the shared schedule

An admin starts the sync with one command. The command fixes two things for every server: a start moment, and the length of one slot. From then on, time is cut into slots, all of the same length, all starting at the same moment on every server.

A slot is the map timer plus time for the podium and for the next map to load. A 10-minute map gets a slot of about 11 minutes. The map always gets its full 10 minutes. The extra minute covers the part between two maps, where nobody can drive.

gantt
    dateFormat mm:ss
    axisFormat %M:%S
    section Slot 1
    Driving, 10 minutes  :a1, 00:00, 10m
    Podium and loading   :a2, after a1, 1m
    section Slot 2
    Driving, 10 minutes  :b1, after a2, 10m
    Podium and loading   :b2, after b1, 1m

Each server works out by itself which slot it is in: the time since the start, divided by the slot length. So the servers do not need to ask each other. They only need to agree on the time.

One clock for every server

Every computer has its own clock, and clocks drift apart. A server whose clock is two seconds fast switches two seconds early. So the servers do not trust their own clocks. They take the time from Redis, the one place they all talk to (see How the game talks to the platform). Every server asks the same Redis, so every server gets the same time.

Staying in step

A map is never cut short. The game ends a map at the end of its timer, and the sync only sets that timer.

  • A server that loads fast is a few seconds early. It gives the map a few seconds more, so it ends with its slot.
  • A server that loads slowly is a few seconds late. The loading time in the slot takes up the difference, and the server is back in step on the next map.

Each server also writes to Redis the moment it expects to end its map. A server that is ahead of the others waits for them. So the fleet stays together, even with one slow server.

Restarts

A server can restart in the middle of a map: the controller, the game server, or both. The sync is kept in Redis, and each server also keeps a copy on its own disk. So a restarted server knows the sync is still on. It also remembers which slot it was in, and it carries on from there. It does not skip ahead.

A server on another map list pauses the sync. An admin does that, for example, to load a different playlist for a special round. When the server loads the event's list again, it rejoins at the map the clock says.

Not every server needs the full list

A server can run a shorter list and still follow the clock. A server with one map plays that map in every slot. The rest of the fleet goes on as before. That is how one server can run a single map for a day while the other servers keep the normal rotation.