A Beginner’s Guide to Cloud Gaming

A screenshot of Battlefield V.

In this article, I’ll go through the fundamentals of cloud gaming and show you how to deploy your own cloud gaming server on Azure. If you don’t like reading, feel free to skip to The Simple Guide for Gaming on Azure.

Have you ever watched a video on Netflix or YouTube?

Gaming on the cloud is not so different from watching a video online. Instead of a console or PC, a powerful server will run the game and send you gameplay video through the internet. Your local device receives the video and plays it back for you, while sending your inputs back to the server.


Why Should I Try Cloud Gaming?

A console or PC gamer needs to upgrade their hardware every few years to experience the latest games. With cloud gaming, you can stream games to a MacBook Air or even a phone, making high-fidelity gaming experience cheap and mobile.

How Does Cloud Gaming Work?

To stream a game between a server on the cloud and your client (local device), the following is required:

  • A codec for compressing gameplay video and audio on the server end and decompressing on the client end.
  • A channel for the server to receive player inputs from the client.
  • A beefy internet connection, preferably at least 30 Mbit/s.

The hardest part to get right is stream latency. All of the steps —like running the game, encoding and decoding the gameplay video, and realizing the player’s inputs — happen in real time. The Turing test for cloud gaming is that it should be indistinguishable from gaming on a powerful console or PC.

Thanks to advances in video codec, cloud computing, and the internet, cloud gaming has grown from a cool idea to a practical alternative to gaming on local devices. Today, you can play the latest AAA titles on the cloud at 1080P at high frame rates with low input and display latency.

What Does Azure Offer?

Azure offers servers with an Nvidia M60 GPU, a powerful workstation GPU that works well for games, 6 virtual CPUs, and 56 GBs of memory. This is a beefy setup that can play the latest and most demanding games.

Playing Battlefield V Beta and Fortnite on Azure cloud, with terrible aim.

In Battlefield V Beta, an early version of the game that is not optimized, the game averaged 50 FPS at 1080P. This performance easily beats the current generation consoles and most PCs out there. In Fortnite, the frame rates consistently stayed about 60 FPS at 1080P. Both are multiplayer first-person shooter games that require low input and display latency. Azure is able to deliver an astounding 3 ms of input latency and around 23 ms of display latency.

Although the display latency is not ideal (a top-of-the-line gaming monitor has around 1ms latency), a lot of factors go into the perceived “smoothness” of a multiplayer game. A very important one is the network latency between the device running the game and the game server. For cloud gaming, both are located in data centers with phenomenal networking speed. Most likely, the network latency between the 2 is much better than normal. It may even be the fact that both are located in the same data center, resulting in near 0 network latency.


What’s the Cloud Gaming Setup Experience?

You need to do the following to setup cloud gaming on Azure:

  1. Deploy an Azure server.
  2. Convert the server meant for productivity workloads to running games.

Doing these manually is frustrating and time-consuming. That is why I’ve written automation for both steps so that minimal input is required for setup.

The below section demonstrates how to manually deploy a server on Azure, but I strongly recommend to instead use the automated approach. This section describes how it works and this is the simple guide for it.

A Taste Of Manual Labor

  • In Azure Portal, select “Create a resource” and then Windows Server 2016 VM:
  • Fill in the basic form. Be sure to select Standard HDD and select a region that offers the NV series (servers with GPU). You can check for region availability of NV series in this chart:
NV is available in region West US 2
  • Select NV6 to deploy:
  • Select all for public inbound ports and turn off boot diagnostics:
  • Deploy and wait for your server to be ready.

Whew, that’s a lot of forms to fill! We haven’t event gotten to step 2, which is much more tedious. If your are curious, checkout out this excellent guide for a walk-through of a full manual setup.

How can we automate all this? The answer is Azure Resource Manager template and PowerShell scripts.

The Beauty of Automation

Azure Resource Manager Template

The Azure Resource Manager (ARM) template defines what and how a server should be deploy on Azure using JSON. Essentially, it saves you from filling all the forms I showed above.

I’ve written an ARM template for automated deployment for an NV server with the Nvidia M60 GPU. The following describes the server type (NV) and the Operating System (Windows Server):

In addition to the ARM template, I’ve also written PowerShell scripts to automate the process of giving the server the ability to play games. The following uses the Azure Custom Script Extension to run my setup scripts when the VM is deployed:

PowerShell Setup Scripts

The setup scripts automate the tedious process of converting an Azure server, which is meant for productivity workloads, to a gaming machine. First, it tweaks Windows Server to be more like a PC and install the necessary software:

After a restart, it sets up the video and audio necessary for gaming:

The setup scripts need to run in a machine with no “real user”. A simple command, such as executing the above script after restart, becomes difficult in PowerShell. Here is a snippet of how it’s done with NSSM, a service scheduler:

The setup scripts are standalone and will work if you deploy your Azure server manually. If you choose to not use the ARM template, you’ll need to manually execute the script and append the following parameter:

-manual_install

The Simple Guide for Gaming on Azure

Below is an easy setup guide for gaming on Azure with Steam In-Home streaming and a virtual network. Steam does the heavy-lifting for streaming video and coordinating player interaction. Since the cloud is not in your home, you’ll need to connect to a (free) virtual network to simulate a home network. Alternatively, you could use either Parsec or Rainway, in which case you can skip the parts about network setup.

Here’s the simple guide for gaming on Azure:

  • Create a free account and setup a network on ZeroTier. Make sure the network is set to public. Write down the network ID for later use.
Under Networks tab, note down the Network ID and make sure the network is public.
  • Download and install ZeroTier client on your local machine. Join your network using the network ID.
  • Deploy cloud gaming on Azure:
Click to deploy your cloud gaming server on Azure

You will need to fill in the following:

  1. Subscription: your Azure subscription. You need a paid subscription as a free account does not grant you access to Azure servers with GPU.
  2. Resource group: create a new one and name it anything you like
  3. Location: pick the location closest to you. Again, you can check for region availability of NV series (server with GPU) in this chart.
  4. Admin username and password: the login credentials for the local user. You will use this to remote desktop into your server.
  5. Auto Shutdown: whether to automatically shutdown your server daily. You can also specify the daily time to shutdown.
  6. Script location: the location of the setup script. Use the default value.
  7. Windows Update: whether to update windows, which takes around an hour. Recommended to leave as false.
  8. Network ID: the network ID of your ZeroTier network.

Click on “Purchase” to deploy your server. Azure charges about $2.72 an hour for the server and data bandwidth. You can check the deployment progress on Azure Portal in the Resource Groups tab. My resource group is called “cgtest”:

The deployment will take 10 to 15 minutes. After the deployment is finished on Azure Portal, wait an additional 10 minutes for some final setup to complete.

Wait an additional 10 minutes after CloudGaming/SetupWithoutWindowsUpdate is done.

There you have it. Your server on Azure is deployed and ready to play games! You can access your server using Remote Desktop by downloading an rdp file in Azure Portal under the Virtual Machine tab:

Open the rdp file and login to your server on Azure with the username and password you specified earlier. You can then login to Steam and install your favorite games, or add a non-Steam game (like Fortnite) to use Steam In-Home Streaming.

When you are ready, close the remote desktop connection using the shortcut C:\disconnect.lnk and enjoy gaming on the cloud!

Remember to stop your virtual machine when you are done gaming to avoid paying for an idle server. Checkout my GitHub repository for a more detailed guide, including how to setup a lower-cost cloud gaming experience on Azure: