A Don't Starve Together server on a VPS: two worlds, a Klei token and mods
When you host Don't Starve Together from your own computer, the world only exists while you are in the game, and the caves slow the host down noticeably. A dedicated server on a VPS fixes both problems. It is built in an unusual way, though: it isn't one program but two. The overworld and the caves run as separate processes, called shards in the game, and they talk to each other over the network. That affects both the choice of plan and the setup.
Which plan you need
Each shard simulates its world in a single thread. So a server with caves needs at least 2 cores: one for the surface and one for the caves. With a single core both worlds share it, and as soon as someone goes down into the caves, everyone left on the surface starts lagging.
- A group of up to 6 people with caves. 2 cores and 2 GB of memory. On a vanilla world that lasts for many seasons.
- A server for 10–20 people or a large mod pack. 2–4 cores and 4 GB. Mods load into both shards, so memory use grows twice as fast as you might expect.
- Several servers on one machine. Count two shards per world and plan for one core per shard.
A Don't Starve Together world gets heavier in the late game. A huge base with hundreds of structures, beefalo pens and piles of items on the ground are all processed constantly. When the server runs out of power, hits on a boss land late, your character snaps back, and items take a moment to appear in your hands. What helps is clearing loose items off the map and a faster core, not extra memory.
The Klei token and the cluster layout
The server is installed through SteamCMD as app 343050 with an anonymous login and runs on Linux and Windows. Linux is simpler on a VPS, and there is a separate 64-bit server build for 64-bit systems.
Without a cluster token the server won't appear online. You get one for free in your Klei account: open the games section, then Game Servers, and add a new server. Save the string you receive into a file called cluster_token.txt. The token is tied to your account, so don't publish it along with the rest of the server files.
All settings live in the cluster folder. It holds a shared cluster.ini with the server name, password, game mode, PvP and the player limit max_players (up to 64). Inside are two folders, Master for the surface and Caves for the caves, each with its own server.ini. The easiest way to get a ready-made layout is to create a world in the game with the settings you want and then copy the cluster folder to the server.
Ports and starting both worlds
Each shard needs its own game port, server_port, over UDP. The surface uses 10999 by default; give the caves a different one, for example 11000. The Steam ports master_server_port and authentication_port must also differ between shards. The master_port in cluster.ini is only used for the worlds to talk to each other. If both shards run on the same machine, keep it closed to the outside. Open the game ports of both worlds in the firewall, otherwise players will get onto the surface and then be kicked when they go down into the caves.
The server is started with two commands that point at the same cluster, with different parameters, -shard Master and -shard Caves. It is convenient to do this through systemd or screen so both processes restart together.
Mods, backups and rollbacks
Mods from the Steam Workshop are installed in two steps. In the dedicated_server_mods_setup.lua file in the server's mods folder, list the mod IDs as ServerModSetup("id") lines, and the server downloads them on startup. Then enable each mod in modoverrides.lua, and that file has to be identical in both folders, Master and Caves. If a mod is enabled only on the surface, the cave world won't match it, and travel between the worlds starts breaking.
All progress sits in the cluster folder, ~/.klei/DoNotStarveTogether by default. Copy it whole, both shards at once, every day and before updating mods. The server keeps its own last few save points, and if something goes wrong an admin can roll the world back a day or two with c_rollback() in the console. You need a full copy for the cases a rollback can't fix, for example after a mod has damaged the save.
Where to put the server and whether you need protection
Don't Starve Together is more forgiving of ping than a shooter, but in a boss fight the difference between 20 and 100 ms is noticeable. For a group in Europe, Germany or the Netherlands works well; in North America, pick the coast where most of you live. If some friends play from Russia or the CIS, Finland keeps their ping short without penalising Western Europe much. You can compare locations on the VPS in Europe and VPS in the USA pages. Password-protected servers for friends are rarely attacked. If the server is open to everyone, take a plan with DDoS protection. A survival game in a similar spirit with an easier setup is Terraria; compare on the VPS for Terraria page.