NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

I Hosted My Valheim Dedicated Server With Docker On A Rock Pi X

Valheim is the new rage, surpassing Dota 2 by 500K peak players, on February 21st 2019, and surpassing Dota 2 by crossing its 6,000,000 sales mark just a few short days ago. While I like to be a nonconformist, it's embarrassing to admit that I too succumbed Valheim's mysterious lure.



I picked up this game just over 3 weeks ago and the first thing I did, given my obsession with self-hosting, was to find the most cost-efficient way to host a dedicated server for it.



What is Valheim?



Valheim is the current hottest survival sandbox on the market. It's a game created by Iron Gate Studios, a Swedish developer. The team consists of only 5 people. Valheim's Steam peak player statistics were second only to Counter Strike: Global Offensive, which is impressive considering it's only been out for a little over a year.



Why host a dedicated server?



Valheim bears a striking similarity with Minecraft and other similar sandbox games and because of that, shares the same reasons behind why a dedicated server is a crucial addition to the gaming experience.



Before creating a character, the player must first create a world. When a world is loaded by the player's computer (host), and made available to other players, it becomes functionally equivalent to a server. Multiplayer is achieved when other players are invited to join the game. Players may join directly by IP address or via Steam's friends list.



This model makes perfect sense for a sandbox game as the very definition of a sandbox implies isolation from outside influences, with each player generating their own world and/or joining other worlds. Without isolation Valheim is not much different from your typical MMORPG.



The only problem is that if the host quits the server, all other players will be immediately disconnected. This means that they won't be able to join the same world again unless the host is also online and in-game. This makes for a less than fun experience, especially given that it is getting increasingly difficult to find a common time slot among friends to play together with the unpredictability of work schedules during these uncertain times brought about by none other than our best friend, COVID-19.



What a dedicated server can do



Asynchronous collective progress



With a dedicated server, players can decouple their gaming schedules from each other, and play whenever they want and still contribute to the collective progress of a shared world. For example, I can just enter the game and dedicate an hour just to chop down an entire forest of trees for the sole purpose of relieving stress and yet in doing so, I can use the wood obtained to replenish the stockpile at base which was used earlier for building walls.



This element of asynchronous collective success is, in my opinion, what makes Valheim so much fun and is probably the main reason for Valheim's meteoric rise. It takes the stress away from coordinating schedules among your friends and allows you to still play as a group, even if you can't agree upon a time.



Performance decoupling



Another benefit is that the dedicated server decouples the performance of the server from the performance of your computer. Hosting a Valheim match may be difficult if your computer is not up to standard.



With a dedicated server, your computer is now freed of the burden of computing world changes for other players just needs to focus on your game experience. You won't affect the enjoyment of other players if you experience performance problems.



Though that is still not a valid excuse for not getting a better-specced computer, but at the very least whenever there seems to be some lag with the dedicated server, you can now share the pain with the other players and pin the blame on the server.



Disaster-recovery



Regardless of whether you are a solo-player or prefer multiplayer with friends, disaster-recovery is an important aspect of every service that's at least semi-critical. Imagine a server of six players spending 2 hours per day to build a base, dock, and castle. All this work over several weeks only to have all your progress lost when the host's computers die. This is a loss of 180 man-hours!



With a dedicated server, depending on the implementation that you choose to deploy, one can schedule backups of the game world, and at any time, restore the state of the world to a specific backup. I schedule backups every fifteen minutes so that the maximum loss is limited to 15 seconds. I also keep the backups for as long as 24 hours just in case.



The Setup



Let's move on to the actual setup!



Hardware



Specs for the Rock Pi X



The Rock Pi X has a soldered on eMMC module. This is a departure from the Rock Pi 4's modular eMMC, but it is a tradeoff. The BIOS doesn’t like storage being swapped.



Here's the final cost for the entire setup:



And this is what the final setup looks like, with the old cluster rack case.



Why Rock Pi X?



I chose the Rock Pi X as it is the cheapest amd64/x86 Single-board computer (SBC) on the market with storage and memory included. The ODROIDH2+ was also on my mind, but it is constantly out of stock and much more expensive with all components. In fact, the Odroid H2+ setup costs enough to purchase 2 Rock Pi X setups.



Here's the cost breakdown for Odroid H2+ if you're still skeptical.



* SGD/USD exchange rate is 0.746268 as of the time of writing 1 This shipping costs WAY too much in my opinion



Another reason I chose to use the Rock Pi X was its small size. The Rock Pi X, unlike many x86 SBCs, adopts the Raspberry Pi form factor, which saves a ton of space. As an added bonus, the form factor means that it fits in my old GeauxRobot Raspberry Pi cluster case, recycled from my old retired cluster, the Octopi.



Why not cloud VMs instead?



Although I had considered running Valheim on a virtual machine in the cloud, it proved to be quite expensive.



Based on the experiences of Redditors in r/valheim, it appears that the dedicated server requires at least 2 vCPU and 3GB RAM. I searched across 3 major cloud service provider for the best price and the table below displays what I found.



* As of the time we are writing, the SGD/USD Exchange Rate is 0.746268



The disk snapshot cost is not included in the above prices. These snapshots can be used to recover data if there is data corruption or loss. This increases your risk of losing all the progress that you and your friends have made in the world.



In an attempt to further reduce the cost of the VMs, I've even lowered the virtual machine's instance class to Spot/Low Priority/Preemptible, depending on the cloud provider, but they all mean the same thing:



In exchange for a discount, this means that you have to pay in terms of uncertainty regarding the availability of your servers. It's fine for dedicated game servers. However, it's quite concerning as Valheim saves at 20 minute intervals. This means that if your VM fails to connect while you are playing, you could lose up to 20 minutes. This may sound small but can be frustrating if it happens repeatedly.



From the table above, we can see that AWS offers the cheapest VMs for the required specs. If we choose to leave the Spot instance class and opt for On-Demand instead, which is the standard class with no termination risk, the monthly price jumps up to US$34.79 (S$46.79). That means that you can purchase a Rock Pi X in 3 months.



Assuming that the instance class is not an issue for you, then the breakeven point is pushed to around 8 months of cloud bills. I can see myself playing this game over 8 months. I also love the idea of self-hosting online so I chose the Rock Pi X at its end.



OS and Docker



Debian Buster is installed via a bootable USB. The default configuration is zram logging, zram swap and zram swap. This allows me to extend the life expectancy of the eMMC by reducing/redirecting write from logging.



For Docker, I followed these instructions to set up Docker’s apt repository and install via apt-install.



Docker image configuration



As for image choice, I chose mbround18/valheim-docker for its simplicity in configuration but there are other alternatives worth considering such as lloesche/valheim-server-docker which is more feature-packed. I suggest you look at both and choose the one that suits you best.



Last but not least, here's the docker run command for mbround18/valheim-docker along with my environment variable configuration:



The README.md file contains details about each environment variable setting.



Some of the notable configuration settings I have made:



PUID/PGID = 1000. This is the default UID/GID for the first user that you create during Debian installation. This is so you don’t run into permission problems with volume mounts.

AUTO_UPDATE/AUTO_UPDATE_SCHEDULE: I've enabled auto updates and set the server to update at 8:05AM which is a time when all players are guaranteed to be not offline (when everyone's either working or sleeping). The time specified by the cron expression here depends on the correct setting of the timezone in TZ


AUTO_BACKUP/AUTO_BACKUP_PAUSE_WITH_NO_PLAYERS: I set the server to perform an auto-backup at a default frequency of every 15 minutes and to pause auto-backups when there are no players. This reduces disk writings from backups by up 75%. The server will only have active players within a given day. If there aren't any players, the world will remain frozen in the same state as before.


WEBHOOK_URL: I set this to my Discord channel's Webhook URL which allows for server status notifications in the channel, giving my friends some visibility into whether the server is running.


Port-forwarding

I configured port-forwarding on my router for source ports 2456, 2457 and 2458 to the Rock Pi X's internal IP address, for the same destination ports. Each router has a unique interface, so you will need to search the internet for help if you are not familiar with it.



Connecting to the server



There are 2 ways to connect to the server, via Steam server browser or in-game server browser, but there's an even faster way that's not very well documented, which is specifying the server via the launch options.
https://evina.si/


1. Navigate to Valheim in Steam and click on Settings (indicated with the Gear icon).


2. Under Launch Options, enter the following, replacing the IP address with your dedicated server's: +connect server.static.public.ip:2457


3. Once you launch the game, all you need to do is enter the password into the prompt.


So far, you have been there



I have been running the server for more then 3 weeks and it has now achieved 99% uptime as tracked by BattleMetrics. The downtime was mostly due to my own itch, tinkering and accidentally bringing down the server.



Performance



I must say I'm pretty impressed by what the 3.35in by 2.13in machine can do. I have not experienced unexplainable performance issues so far. The only issues I have experienced are known issues in the game, which were thankfully fixed in the 0.148.6 update on 23 March 2020.



Known issues (Fixed)



1. Multiplayer network desync [Reddit]


2. Poor terraforming performance [Reddit]


Resource utilization



I've taken measurements using htop to determine the game's resource use and calculated the averages.



- CPU (Idle: 0.6


- CPU (Load: 1.5


- RAM: ~2.2GB


The game still has plenty of headroom thanks to the 4 cores, 4GB RAM, and 4GB of storage.



Current state



I've since joined the Rock Pi X into my arm64 cluster, Leviathan (post on it to come) and migrated the dedicated server into my K3s Kubernetes cluster so that it leverages the existing distributed block storage.



Kubernetes is great for self-hosting multiple apps. However, it is not recommended if you are just planning to run a Valheim server.



Would you recommend this?



Yes, but only if your hobby is tinkering. There are small hiccups that can occur along the way, which are very common in self-hosted setups. However, it has become a reflex to address them. It may prove discouraging for those who are not interested solving small problems and want a working solution that takes the least amount of time and effort.



If you intend to dive head first into the rabbit hole of self-hosting, then absolutely yes. This project is great for your first project. It's easy to do and the roadblocks will help you debug other apps. The motivation behind this project and the sense of satisfaction you'll get when it all works out will help drive you forward in this endeavor.


Website: https://evina.si/
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.