Auto-Scaling Linux Game Servers
Sorry I haven't blogged in a while, but I've been consumed learning about Linux. Long story short, I LOVE it and World of Pursuits got cheaper. The pricing difference between Linux and Windows was to great to ignore while looking at Azure virtual machines. I went down a Linux rabbit hole, and went on a frustrating, but greatly beneficial adventure.
First, here's the motive... I've chosen to test WOP servers on Azure's F1 size Virtual machines (1 core, 2GB RAM). The price of the F1 server running windows is $76.65/month
The EXACT same F1 server running Linux is $39.93/month.
$76.65 - $39.93 = $36.72 savings per month per server. You can almost run 2 Linux servers for the price of 1 Windows server. 39.93 to 76.65 is a 91.9609316% gain lol. So that's the motive... We can keep the game A LOT cheaper running on Linux.
The second part of this adventure was the need to learn Linux, which led to even more motive to run WOP on Linux servers. I'm no pro in Linux, but what I've learned thus far impresses me. I decided I needed a GUI being a newbie in Linux. I chose the LXDE GUI based on a blog I found about CPU and RAM usage. Gnome-Core also seemed like a good choice. I had to learn the Linux terminal, permissions, what .sh files were, the home folder, the root user, remotely running shell scripts, WinSCP, SSH protocol, remoting to a Linux machine from windows, etc.. Error after error led me to learning WAY more about Linux than I wanted too lol.
So after getting the ability to remote to a Linux F1 Server I wanted to check its stats. I was shocked. No joke, the CPU and RAM usage of a F1 virtual machine running Ubuntu and LXDE would bounce between 0% and 2%.
Windows Server 2019 on the EXACT same virtual machine size ran at a low 3%, but would spike to 100% on annoying background task occasionally (probably a fat lag spike while racing in WOP). Windows loves to add its extra apps and services, all leading to more RAM usage than Linux too.
So not only is Linux cheaper, its better performance.
The third part of this adventure got brutal. My ODBC plugin for unreal engine did not work on Linux. I started researching on tons of forums learning a lot about Linux, but I got stuck bad for a few weeks. I reached out to old co-workers, and my homie Harry had solved a lot of these puzzles already. I went deep into learning about cross-compiling, FreeTDS, unixodbc-dev, the odbcinst.ini and odbc.ini files, etc... I learned everything I could find online, but I was still stuck. I went back into my plugin and add better logging. I had to learn about SqlGetDiag to get better error messages. After better error messages, help from Harry, and rolling my forehead on the keyboard for weeks, I finally broke free. I won ;)
After breaking the Linux compatibility puzzles, I put an empty WOP server instance on the virtual machine. The CPU bounced between 5% to 10% running a world of pursuits server. Looking good :)
After learning a lot about Linux, and the Azure C# SDK. I built game server auto-scaling logic. Our matchmaking server can now create and destroy virtual machines as they're needed. This silent boring video is our matchmaking server auto-scaling Linux game servers in Azure.