500 Hours of Free, 4K 60 FPS Cloud Gaming

A guide to Google Cloud Platform and Moonlight

John Ragone
13 min readOct 28, 2020
BioShock Infinite streamed to a 2013 MacBook Pro

In the past decade, the cloud gaming market has been flooded by a wave of varied services and software, enabling players to stream once platform-restricted games to almost any device. These services range from Stadia to GeForce Now to Amazon’s newly-announced Luna and connect players to high-powered machines that stream high-quality games, for a price. On the other hand, the software — Parsec, Moonlight, Rainway, etc. — is free. The player, though, must provide the machine. For those that don’t own a personal PC, gaming through provisioned cloud servers can be a viable and economical solution to building their own machine. One such cloud provider, Google, can be paired with the open-source software Moonlight to deliver possibly one of the highest quality streaming experiences available today. This article seeks to guide prospective cloud gamers through detailed instructions for provisioning a Google Cloud Platform (GCP) machine and streaming games over the internet by means of Moonlight.

Parsec vs. Moonlight on GCP

It’s important to note that Parsec does exist as an alternative software whose implementation on GCP has been well-documented. In fact, this article will set up the GCP machine for Parsec in the process of setting it up for Moonlight. The motivation for using Moonlight over Parsec is founded on a number of factors. The first few of which are the fact that it is open-source and offers a greater degree of customization over Parsec. Additionally, the fidelity of the Moonlight stream seems to be a leap beyond Parsec; where graphically dynamic games would produce noticeable visual artifacts in the Parsec stream at a bitrate of 50 Mbps, Moonlight produces no such artifacts and provides a lower input latency. As a result of this, Parsec seems perfectly suitable for games whose scene views are primarily static such as strategy and board games. But for most other games where the scene view changes rapidly with user input, Moonlight appears to be the superior streaming software.

Credits

As with most guides, this would not exist without the prior contributions of the community. Below are several guides and public resources that made this possible.

Cost

All told, this machine will cost approximately 60¢/hour when in use. Relative to Paperspace’s cloud gaming machine, this tutorial provisions a less powerful CPU but provides an experience with higher visual fidelity and costs reduced 18¢/hour. Some quick division will see that GCP’s $300 starting credit can run this tutorial’s cloud gaming machine for approximately 500 hours. Spread across the $300 credit’s 90 days of eligibility, that’s about five and a half hours of gaming every day. Contingent on the Windows Server licensing fee and disk space provisioned, there will also be associated costs when the machine is off. Following the values in this tutorial, those costs will be about 11¢/hour. Beyond the free credit, this approach to cloud gaming can be fiscally more responsible than Shadow, arguably the highest-quality cloud gaming service today, when limiting gaming to 20 hours per month. As with most cloud gaming solutions today, this may not be everyone’s solution, but it may very well be someone’s.

Video Tutorial

Although a written tutorial follows this, some — including myself — may find a video tutorial more digestible and easier to follow. For that reason, I’ve created a video tutorial that follows each step of this guide.

Provision the GCP Machine

Create and upgrade your GCP account

  1. Sign up for a free GCP account here. Once you’re signed up, you’ll have $300 of free credit to spend over the course of 90 days.
  2. The first thing you’ll want to do with your new account is increase some quotas. The machine we will provision requires an NVIDIA T4 GPU. But to increase your quota for GPUs, you’ll have to upgrade your trial account. You can do this by navigating to Billing, scrolling to the Free trial credit tile, and selecting the Upgrade button.
Navigate to Billing
Select Upgrade under Free trial credit

Increase quotas

Now that your account has been upgraded, you can increase the necessary quotas.

  1. The first quota to increase is the global GPU limit. Navigate to the All Quotas page and filter the quotas by Compute Engine API and GPU.
  2. Select All Quotas on the GPUs (all regions) row.
  3. Select the Global location and Edit Quotas button, and request a limit of 1 GPU. Note here that if this is a brand new GCP account, you’ll almost certainly run into some trouble getting approval for your request. In my case, I had to accrue some billing history to be approved for a GPU. This can be done by making a payment of ten to twenty dollars through your billing account or running several VM instances. If that doesn’t work, contacting GCP support may be your best bet. Undoubtedly, this can be the most finicky step, as Google does not provide any clear way to ensure that your quota request will be approved.
  4. Once your global GPU request is approved, you can increase the next quota: the NVIDIA T4 GPU. Return to the All Quotas page and filter by NVIDIA T4 GPUs.
  5. Select All Quotas on the NVIDIA T4 GPUs row.
  6. You will want to request a limit increase in your optimal location. Region and zone information can be found here. Once you know which location is best, select the location and Edit Quotas button, and request a limit of 1 GPU.
Visit the All Quotas page
Filter the Compute Engine API service and GPU term
Click All Quotas for GPUs (all regions)
Request a limit increase
Filter the Committed NVIDIA T4 GPUs limit name and click All Quotas
Request a limit increase for your optimal location

Launch an NVIDIA Gaming PC instance

  1. Visit the NVIDIA Gaming PC’s marketplace page and click the Launch button to configure your instance of the machine.
  2. On the configuration page, the first thing to do is select the zone. This should match the zone that has the quota for an NVIDIA T4 GPU.
  3. Next, under machine type, select the 4 vCPUs 15GB memory, n1-standard-4 option. The default of 8 vCPUs and 30GB of memory is a bit overkill, so this is a cost-effective alternative. It’s important that whatever memory option you pick is an N1 machine type, as this is currently the only machine type that supports a GPU on GCP.
  4. Lastly, configure the size of the boot disk. The boot disk type and size you choose won’t have any critical effect on your ability to stream games, but giving yourself a modern disk type with ample space is a good idea. After launching, you can always append more disks. I’ve set my boot disk to be 250 GB SSD Persistent Disk, but you can set it much higher if you anticipate needing the space. Keep in mind though that the default SSD quota is 250 GB, so you may need to request a limit increase.

Once you complete those configuration steps, you’re ready to deploy! Press the Deploy button and GCP will provision your machine.

Configure your new NVIDIA Gaming PC

Set firewall rules

By default, GCP enables firewalls on ports necessary for Moonlight to function. To fix this, we’ll add a network rule to the newly-provisioned machine.

  1. Go to the Firewall section of the VPC network page.
  2. On this page, select Create Firewall Rule.
  3. Give your rule a name and a target tag. In my case, I chose moonlight for both.
  4. In the Source IP ranges field, enter 0.0.0.0/0. Under the Protocols and ports section, select tcp and udp. In the TCP row, enter 47984, 47989, 48010. And in the UDP row, enter 5353, 47998, 47999, 48000, 48002, 48010.
  5. Click Create to create the new firewall rule.
  6. Visit your NVIDIA Gaming PC at the VM instances section of the Compute Engine page, and click on the instance’s name.
  7. Click Edit, and in the Network tags field, enter the tag you chose for your firewall rule. In my case, that would be moonlight.
  8. Save the new settings.
Navigate to the Firewall section of the VPC network page
Click Create Firewall Rule
Configure and create the firewall rule
Edit the VM instance configuration
Add your network tag

Configure the Machine for Moonlight

Connect to your machine

Now that you have your NVIDIA Gaming PC configured on GCP, it’s time to connect to the machine and continue the configurations.

  1. Set a password for your machine by clicking on the dropdown under the Connect column of your VM instance and selecting Set Windows password. Be sure to save this password.
  2. Download the RDP file for your VM instance and connect to it using Microsoft’s Remote Desktop application and the password you just created.
Set and retrieve the Windows password and RDP file
Connect to the VM instance through Remote Desktop

Update Server Manager settings

When you first connect to your machine, Server Manager will open. Here, you’ll want to update a few settings and install some new software.

  1. Click Manage in the top right of Server Manager, and select Server Manager Properties. Check the box that reads Do not start Server Manager automatically at logon. Once we update the Server Manager settings, we won’t need to open Server Manager again and certainly won’t need it opening at every logon.
  2. On the dashboard, click Add roles and features. Moonlight relies on NVIDIA GeForce Experience’s GameStream to stream games, and that requires the Wireless LAN Service feature to be installed. Click Next until you reach the Features tab, and on this tab, select Wireless LAN Service. On the Confirmation tab, check the Restart the destination server automatically if required box.
  3. Your machine will restart during the installation, likely kicking you off the Remote Desktop connection. Once you reconnect, Server Manager will be successfully updated.
Select Manage > Server Manager Properties in Server Manager
Update the Server Manager properties
Select Add roles and features
Select Wireless LAN Service under the Features tab
Select and accept automatic restarts

Run the Parsec script

At this point there is a slew of necessary configurations that have been compacted into a simple script thanks to the Parsec team. Their script will ensure you are set up with proper audio and video drivers to stream games.

  1. Visit the Parsec script repo and copy the multi-line block of code in the instructions.
  2. Open an instance of Windows PowerShell and paste the code into there.
  3. Follow the prompts from the script, saying yes to the auto logon feature for ease-of-use in the future.
  4. When the script finishes, Parsec and the necessary drivers will be installed on your machine. To test this, open and log in to Parsec on your local and remote machines. On the remote machine, choose to share the computer. On the local machine, connect to the shared computer.

At this point, we no longer need to use Remote Desktop, so you can close that connection. Parsec will prove to be a necessity for the next script, as it will disable the monitor to which Remote Desktop connects.

Copy the Parsec script instructions to Windows PowerShell
Log in to Parsec
Share your remote machine
Connect to your remote machine

Run acceleration3’s script

Moonlight streams games using NVIDIA GeForce Experience’s GameStream feature. However, GameStream is only available on GTX series graphics cards, and unfortunately, our NVIDIA T4 does not fit the bill. Luckily though, there’s a script for this. GitHub user acceleration3’s cloudgamestream PowerShell script will perform the necessary modifications to trick GeForce Experience into enabling GameStream.

Before following the steps below, be sure that you are connected to your remote machine over Parsec and not Remote Desktop. The script will not work otherwise.

  1. Download the script files and extract them into your Downloads directory.
  2. Open the script titled 1_Install_Requirements.ps1 under the folder Steps in a file editor.
  3. Delete the final condition in the file. It begins with if($installVideo) {
  4. Run Windows PowerShell as administrator and navigate to the directory cloudgamestream-master containing Setup.ps1. Run the following command: Set-ExecutionPolicy Unrestricted; ./Setup.ps1, and agree to the initial execution policy prompt. Be sure to use Windows PowerShell and not PowerShell 7, as the two will produce different results.
  5. Reply n to the prompts regarding VBCable and updating your GPU driver. The audio and video drivers were already handled by the Parsec script.
  6. Continue through the rest of the prompts, replying y.
  7. The final prompt of the script will restart your remote machine, and you will be disconnected from your Parsec session. Wait a few moments for the machine to restart, and reconnect through Parsec.
Download the script files
Open the file 1_Install_Requirements.ps1
Delete everything from the line highlighted above through the end of the file
Run Windows PowerShell as administrator
Navigate to the root script directory and execute Setup.ps1
Choose to restart the machine

Enable GameStream and Download Moonlight

This is the home stretch. Now you have everything set up as if you were trying to stream from a personal PC. The final steps follow the Moonlight setup.

  1. Open GeForce Experience, log in to or create your NVIDIA account, and click the gear in the upper right to reach the settings page.
  2. Open the Shield tab and flip the switch to enable GameStream.
  3. Click the the Add button on the Games & Apps tile, and add the file C:\windows\system32\mstsc.exe. This will enable you to stream the desktop once Moonlight is set up.
  4. Download the latest release of Moonlight’s internet hosting tool and run the executable. This will install the application Moonlight Internet Streaming Tester.
  5. Open Moonlight Internet Streaming Tester and allow the process to run. Once finished, it should display a success message with an IP address that you will use to connect from your local machine. Be certain to write this IP address down.
  6. On your local machine, download the Moonlight client from the Moonlight website.
  7. After opening the Moonlight client, add your remote machine using the IP address displayed previously.
  8. Click on your added PC, and enter the displayed GameStream code on your remote machine. Then, disconnect from Parsec.
  9. In the Moonlight client, click on your PC and run mstsc.exe

Congratulations! You’re streaming video from a remote machine using Moonlight! But this isn’t gaming, so let’s get some games on there.

Open GeForce Experience
Enable GameStream and click Add
Add mstsc.exe
Download and install the Moonlight Internet Hosting Tool
Run Moonlight Internet Streaming Tester
Copy down your PC address for Moonlight
Download the Moonlight client
Add your PC to the Moonlight client
Click on your added PC
Enter the code from the Moonlight client
Disconnect from Parsec
Run mstsc.exe

Get some games on there

You’ll remember from the configuration of the NVIDIA Gaming PC that I opted for more than the default 50 GB of storage. Before downloading games, it’s a good idea to expand the boot disk partition to include the extra space.

  1. Open Disk Management, and right-click the C: volume. Select Extend Volume and provision the unallocated space to C:

With that set, you can start downloading and playing any games of your choosing. My first download was BioShock Infinite on Steam. You’ll notice that when you download games, GeForce Experience will pick up on the game files. Moonlight will then allow you to launch those games directly from your client machine, should you prefer that over the virtual desktop experience.

Please also be sure to read the next section, Critical Notes, as it contains some essential information.

Open Disk Management
Extend C:’s volume
Star Wars Battlefront (2015) streamed to a 2013 MacBook Pro

Critical Notes

Below are a few notes critical to ensuring a good cloud gaming experience.

  • Shut off the remote machine when not in use — GCP will charge 60¢/hour when this machine is running, whether or not you’re playing games on it. It’s crucial that you shut off the machine when you’re not playing, so you can make the most out of your dollar.
  • If you’re playing on Mac, be sure to turn off location services. The Mac OS routinely does demanding work with location services that can cause hiccups in streams. This can be disabled by navigating to System Preferences > Security & Privacy > Privacy and unchecking Enable Location Services.

Next Steps

Gaming through the cloud is a terrific thing. But beyond gaming, the infrastructure of cloud gaming has many potential applications. It’s ability to stream a live scene in response to user input is, at a high level, how we interact with all machines. Although internet latency and bandwidth still have room to develop, this is an exciting time in the field of cloud computing for those interested in pushing distributed systems to a new limit.

As for the next steps of this guide, I’d be interested in benchmarking Moonlight vs. Parsec on GCP, testing this approach with more than one GPU on the machine, and creating a script that encapsulates most of the steps outlined in this guide. That work will continue to be documented at my research site, Project Paladin.

Please be sure to comment any issues you face, and I’ll do my best to help out.

--

--