Operations
How the network runs: heartbeats, the matchmaker, the path of a match, returning players and what you can tune.
Heartbeats
Every backend and the proxy publish a heartbeat every 2 seconds. It carries the role, the players, the free arenas per kit, the ready copies per arena, whether the server holds the matchmaker lock, the queue sizes of a lobby and the running matches of a server.
A heartbeat also says whether the server is draining (/md drain). Other servers then stop choosing it. See Restarts and the game server gate.
A server whose last heartbeat is older than 10 seconds is ignored when a server or lobby is chosen, and its messages are refused until its next heartbeat arrives.
The matchmaker
One lobby is the matchmaker at a time. It holds a lock in Redis that expires after 5 seconds and is renewed every 2 seconds. The other lobbies check the lock in the same cycle.
- When the matchmaker stops, another lobby takes the lock. Every lobby then sends its queued players to the new matchmaker, a batch at a time.
- A lobby that was silent for a while, for example during a long pause, sends its queue again when it is heard from.
/mdproxyshows[matchmaker]next to the lobby that holds the lock.
The matchmaker pairs players with the rules of matchmaking.yml (queue.tick-interval and the ranked range). It only uses a duel server that has a free arena for the kit.
The path of a match
- A player joins a queue on a lobby. The lobby forwards the join to the matchmaker. The player can be in several queues at once, up to
queue.multi-queue.max. Pre-made party teams cannot use the global queue. - The matchmaker pairs players and assigns the match to the duel server with the most free arenas for the kit. The paired players leave all of their queues.
- The duel server reserves an arena copy for the match and loads the chunks around the spawns.
- The lobbies tell the players, save their data and ask the proxy to move them.
- Each player arrives on the duel server and waits on their own block of the waiting platform (
cross-server.hold). The action bar says that the server waits for everyone to load. - When every player is online, has their profile and has reported the world as loaded (or
hold.wait-max-secondshas passed), the match is created and everyone is moved into the arena at the same time. - The arrival box and the start mode preparations (such as the elevator walls and platform) are sent, the server waits for the chunks to be sent, then the countdown starts.
- The match runs. After it, players stay for
post-match.stay-secondswith the post-match items (whenpost-match.game-serversistrue). - Players go back to a lobby: the one they came from when it is up and not full, otherwise the least full lobby.
If the players do not all arrive within assign-timeout-seconds, the match is cancelled, the arena is released and the players who did arrive are sent back.
Waiting before the countdown
| Setting | File | Effect |
|---|---|---|
cross-server.hold.* | database.yml | The waiting platform. See Backend config. |
match.arrival-settle-seconds | config.yml | Minimum wait after everyone is in the arena. |
match.arrival-wait-max-seconds | config.yml | Longest wait for the clients to receive their chunks. The check must be true on two seconds in a row. |
arrival-box.* | match-start.yml | The box around each player in freeze mode. |
elevator.preload | match-start.yml | Sends the elevator walls and platform before the countdown, and again once the chunks are there. |
After a match
| Item | Behaviour on a duel server |
|---|---|
| Stay | Every player stays for post-match.stay-seconds, including a player who forfeited. |
Leave item or /leave | The player is sent to a lobby at once. |
| Play again, requeue all | The player is sent to a lobby and queued there when they arrive. Only for queue matches, and not for party members. |
| Duel rematch | Not offered on a duel server. |
| End of the stay | Everyone is sent to a lobby. Players are never sent away before it ends. |
If the move to a lobby did not happen within cross-server.return-wait-seconds, the player is teleported out of the arena and the transfer is repeated.
Arenas of a duel
A duel server lists in its heartbeat every arena it can host with the number of ready copies. A lobby uses this to show only playable arenas in /duel and /gduel, and the matchmaker prefers a server with a ready copy of the chosen arena. The arena travels in the duel request, the acceptance and the assignment. Servers of an older version do not report arenas; a lobby then shows all arenas of the kit and the game server picks.
If the chosen arena has no ready copy, the assignment waits for it until half of assign-timeout-seconds is over and then uses another arena of the kit.
Counts shown to players
The queue menus, queue signs, dialogs, scoreboards and placeholders show network-wide numbers.
- In queue is the number of players waiting in that queue on every lobby.
- In fight is the number of running matches of that kit on every server.
The numbers of the other servers come from their heartbeats and are up to about 2 seconds old. The numbers of the server itself are live.
Duels, spectating, chat and parties
| Feature | Behaviour |
|---|---|
/gduel <player> [kit] [rounds] | Challenges a player on any server. The target answers with /gduel accept <player> or /gduel deny <player>. /duel on a lobby falls back to it for a player who is not on that server. |
/spectate <player> | Looks the player up on the network. When they are in a match, the spectator is sent to that duel server and returns to a lobby when they stop. |
/servers | Opens the server selector. Permission mineduels.servers. |
/lobby, /hub | Sends the player to the least full lobby. |
| Parties | A party belongs to the server where it was created. It keeps its members while they are away on a duel server. A member who stays away longer than party-away-minutes leaves the party. A player on another server, or in another region, cannot join or be invited, and gets a message that says so. See Parties. |
| Global chat | Shown on every server with global-chat: true. |
Startup checks
Cross-server refuses to start, and the console says why, when:
| Message | Fix |
|---|---|
cross-server.enabled needs storage.type: mysql | Switch the backend to MySQL or MariaDB. |
cross-server.redis.password is empty | Set a password on Redis and in the config. |
cross-server.secret: ... shorter than 32 bytes | Use a longer random secret, the same on every server. |
cross-server.server-name ... must be the server's name | Use letters, digits and _ . : - only, and the name from velocity.toml. |
cross-server.role must be lobby or game | Set the role to lobby or game. |
Proxy log: proxy-name ... may use letters, digits | Use letters, digits and _ . : -, up to 64 characters, in config.properties of the proxy plugin. |
Proxy log: public-address ... is not a host or host:port | Write the address players use to reach the proxy, for example play.example.com:25565. |
A message that is refused at runtime is counted and logged in short, repeating lines, for example Refused N Redis message(s): BAD_SIGNATURE. A signature error means a different secret, an out of window timestamp error means the clocks differ, and a version error means a server runs another MineDuels version.
Checks when something is wrong
| Symptom | Check |
|---|---|
A server is missing in /mdproxy | Its server-name, the Redis settings and the secret. |
| Players are not moved to the duel server | The server-name of the duel server must equal its velocity.toml entry. |
The arena menu of /duel is empty or lacks an arena | No fresh duel server reports that arena. Check the arena exists on the duel server and its pool has started. |
| A duel server is never chosen | It needs a ready arena pool and arenas for the kit, and a fresh heartbeat. |
| Menus show 0 in queue or in fight | The lobbies and duel servers need the same Redis and secret, and cross-server.enabled: true. |
A player disconnects
The proxy tells every backend when a player leaves the network. Moving between servers does not count.
- Party: a member who disconnects leaves their party at once, wherever they were. The lead passes on, or the party disbands, as set by
disband-on-leader-quitinsocial.yml. - Found match: if a player disconnects after a match was found and before it starts, the other players wait on the duel server for up to
disconnect-grace-seconds(default 10). If the player reconnects in that time the proxy sends them straight to the duel server and the match starts. Otherwise the match is cancelled, the players who are there are told, and they are queued again in the queues they were in. - On proxy shutdown the proxy tells the backends about every player it still has before it closes. A player who is replaced by a new login of the same account is not reported as gone.
- Without the proxy plugin: these steps need MineDuels-Velocity from the same version. With an older proxy plugin the party member stays for
party-away-minutesand the waiting players forassign-timeout-seconds.
Testing a network
The bot suite can play through the proxy and read the lobby, duel server and proxy logs together. See Testing with bots.
A server stops or crashes during a match
A duel server writes every match it runs to md_running in the shared database. A graceful stop ends the matches as draws and removes the rows. After a crash or kill the rows stay, and when that server starts again it pastes the arena copies in full, publishes a cancelled result for every match a lobby asked for (so tournament bouts and party games fail at once), and sends the players to a lobby when they join. Players who were connected to the proxy are moved by the proxy as soon as the server goes away. See match.recovery in Configuration.
Moving players, tickets and limits
- A backend may only ask the proxy to move players to a lobby, or to the least full lobby with an empty target. A duel server can send players only to lobbies. A target that is not heard from in the last 10 seconds is replaced by the least full lobby.
- A player moved to another proxy gets a signed route ticket in Redis first; the move waits for it to be stored. The receiving proxy reads the ticket without removing it, and removes it only when it uses it, so a player who joins through a proxy that cannot place them keeps the ticket until it expires.
- Messages that make a server choose, such as duel requests, acceptances and party duels, are accepted from lobbies only. A drain request (from the web API) is accepted from a lobby or a duel server, applies only to the server it names, and is applied once. A heartbeat that announces a transfer address is accepted from a proxy only.
- A lobby asks for a match on a duel server and watches that server. If the duel server stops sending heartbeats while the match runs, the lobby counts the match as cancelled. A tournament bout is then played again.
- A server not heard from for an hour is forgotten by the directory.
- Redis settings: tickets and heartbeats share one connection pool with a short timeout. A critical message is not dropped when the proxy shuts down: the proxy waits up to 1.5 seconds for the queue to empty.
- The shared secret is the trust anchor: every server signs with the same key. The checks above narrow what a compromised backend can do, but a backend that has the secret can still send everything its role allows.