valheim

Hosting VRising on AWS

Quick Intro - “V Rising is a open-world survival game developed and published by Stunlock Studios that was released on May 17, 2022. Awaken as a vampire. Hunt for blood in nearby settlements to regain your strength and evade the scorching sun to survive. Raise your castle and thrive in an ever-changing open world full of mystery.” (vrising.fandom.com)

Hosting a dedicated server for this game is similar to how we set one up with Valheim (Hosting Valheim on AWS). We used the same server tier as Valheim, below are the details.

VRising Server does not officially available for Linux OS, luckily we found this guide for setting it up on Centos. Hence we used a centos AMI on “community AMIs”.

- AMI: ap-southeast-2 image for x86_64 CentOS_7
- instance-type: t3.medium   
- vpc: we're using default vpc created by aws on our account.
- storage: 8gb.
- security group with the folowing rules:
    - Custom UDP Rule: UDP 9876 open to our pc ips
    - Custom UDP Rule: UDP 9877 open to our pc ips
    - ssh: TCP 22 open to our pc ips

We are using the same cloudwatch alarm as Valheim to turn off the server when there’s no activity.

This time we also added a new feature, using discord bot chat to turn the aws server on/off.

This discord bot is hosted on one of our raspberry pi. Here is the bot repo and below is the flow chart of the whole setup.

Improvements:

  • Maybe cloudwatch alarm can be set with a lambda function. Which would send a notification to our discord channel letting us know that the server got turn off by cloudwatch.

  • We considered using Elastic IP so the server can retain its ip after it got turn off. But we decided not to, as we wanted to save some cost.

It has been awhile since we got together and work on something this fun. Hopefully, we’ll find more ideas and interesting projects to work together. Thanks for reading, so long until next time.

Hosting Valheim on AWS

Quick introduction for Valheim, it’s an indi game developed by IronGate which is a viking survival game where player can build/craft like minecraft, fight like darksoul and explore a beautiful world like zelda. The game is a huge success with 5 milion players, more information can be found here at Valheim official site.

Below are the steps I took to setup a dedicated server on aws to host valheim:

  1. Spin up an ec2 instance: The game ran pretty smooth with a tiny bit of latency. Below is the instance details:

    • AMI: Ubuntu Server 20.04 LTS (HVM)
    • instance-type: t3a.medium. This is the cheapest we can get. Unfortunately valheim does not support 64bit(Arm) so we can’t use t4 instance type.
    • vpc: we’re using default vpc created by aws on our account.
    • storage: 8gb, the game only require less than 2gb.
    • security group with the folowing rules:
      • Custom TCP Rule: TCP 2456 - 2458 open to our pc ips
      • Custom UDP Rule: UDP 2456 - 2458 open to our pc ips
      • ssh: TCP 22 open to our pc ips
  2. Install Valheim server follow this git repo created by Nimdy: Dedicated_Valheim_Server_Script

  3. Setup cloudwatch to monitor “Network packet out(count)” to stop the instance when it’s not in use after 25 minutes. Valheim server save the world every 20 minutes, this ensure we have the game save whenever we log off:

    • Threshold type: statics
    • Whenever NetworkPacketsOut is: Lower/Equal <= threshold
    • than: 250
    • period: 5 minutes
    • Datapoint to alarm: 5 out of 5
    • treat missing data as missing
  4. Optional: Migrate exisiting world on local computer to valheim server. Coppy the following to files from the below source to valheim server world location: .fwl, .fwl.old, .db. I’m using FileZilla to transfer the file to the ec2 instance.

    • source: C:\Users\YOURNAME\AppData\LocalLow\IronGate\Valheim\worlds
    • valheim server world location: /home/steam/.config/unity3d/IronGate/Valheim/worlds
  5. Run the below script to start the instance and game. (aws powershell module is requrired on the local computer)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    Import-Module AWS.Tools.EC2

    $steam_exe = <steam_exe_location>
    $instance_id = <ec2_valheim_instance_id>
    Set-DefaultAWSRegion -Region <ec2_valheim_instance_region>


    $instance_status = Get-EC2InstanceStatus -InstanceId $instance_id
    if ($instance_status -eq $null){
    Start-EC2Instance -InstanceId $instance_id
    do {
    $instance = (Get-EC2Instance -InstanceId $instance_id).Instances
    Start-Sleep -Seconds 10
    } while ($instance.PublicIpAddress -eq $null)
    } else {
    $instance = (Get-EC2Instance -InstanceId $instance_id).Instances
    }

    $server_ip = $instance.PublicIpAddress

    while ($instance_status.Status.status -ne "ok"){
    Start-Sleep -Seconds 10
    $instance_status = Get-EC2InstanceStatus -InstanceId $instance_id
    $instance_status.Status.status
    }
    if ($instance_status.Status.status -eq "ok"){
    & $steam_exe -applaunch 892970 +connect ${server_ip}:2456
    }

We got this setup running fine for the last 2-3 weeks, and it’s costing us around $1.8 usd. Pretty happy with it, next improvement I guess maybe put together a Terraform for this or if possible, have cloudwatch monitor valheim’s log instead of network packet out count.