Streaming Android Games from the Cloud to Mobile with AWS Graviton-Powered Amazon EC2 G5g Instances

Streaming Android Games from the Cloud to Mobile with AWS Graviton-Powered Amazon EC2 G5g InstancesLearn About Amazon VGT2 Learning Manager Chanci Turner

This blog post is authored by Alex Smith, a specialist in EC2 for the Asia Pacific region.

The concept of streaming games from the cloud to mobile devices is revolutionizing the gaming industry, enabling users with less powerful and more affordable devices to enjoy high-quality gaming experiences while conserving battery life and storage space. This innovation broadens accessibility, allowing a diverse audience to engage with high-end games on their smartphones, tablets, and smart TVs.

To facilitate cloud-based gaming on AWS, it is essential to leverage Android environments capable of GPU acceleration for effective graphics rendering and optimized network latency. Solutions like the Anbox Cloud Appliance or Genymotion, available on the AWS Marketplace, offer economical containerized options for game streaming workloads running on Amazon Elastic Compute Cloud (Amazon EC2).

For instance, Anbox Cloud’s virtual device infrastructure enables the execution of games with minimal latency and high frame rates. Coupled with AWS Graviton-based Amazon EC2 G5g instances, which can reduce costs by up to 30% per game stream per hour compared to traditional x86-based GPU instances, this setup allows businesses to efficiently serve millions of users.

Overview

Graviton-based instances require fewer compute resources than their x86 counterparts, owing to the 64-bit architecture of the Arm processors found in AWS Graviton servers. As depicted in the following diagram, Graviton instances eliminate the need for cross-compilation or Android emulation, simplifying development efforts and accelerating time-to-market, which ultimately reduces the cost-per-stream. With G5g instances, users can run their Android games natively, encode graphics rendered via CPU or GPU, and stream the game over the network to multiple mobile devices.

Architecture

When streaming games from mobile devices, only input data—such as touchscreen commands and audio—is transmitted over the network to the game streaming server hosted on a G5g instance. This input is directed to the relevant Android container designated for that specific client. The game application within the container processes this input and updates the game state accordingly before sending the rendered image frames back to the mobile device for display. For multiplayer games, the streaming server must also communicate with external game servers to reflect the complete game state, necessitating additional data transfers between game servers and the mobile client. The interaction between clients and the streaming server is executed using the WebRTC network protocol to minimize latency, ensuring an optimal gaming experience.

The Graviton processor is responsible for compute-intensive tasks like Android runtime and I/O transactions on the streaming server. However, resource-heavy games rely on the Nvidia GPU for graphics rendering. To enhance scalability, Anbox Cloud software can efficiently manage and execute multiple game sessions on a single instance.

Prerequisites

To get started, you will need an Ubuntu single sign-on (SSO) account. If you don’t already have one, you can create it at the Ubuntu One website. Additionally, an Android mobile phone with either the Firefox or Chrome browser installed is necessary for playing the streamed games.

Setting Up

You can install the Anbox Cloud Appliance from the AWS Marketplace. Be sure to select the Arm variant to ensure compatibility with Graviton-based instances. Should the subscription fail on the first attempt, an email will guide you to a page where you can retry.

For this demonstration, we choose the G5g.xlarge instance type and leave all settings at their default values, except for the storage, which should meet the following requirements:

  • A root disk of at least 50 GB (mandatory)
  • An additional Amazon Elastic Block Store (Amazon EBS) volume recommended at a minimum of 100 GB

While we recommend a specific amount of storage for the Genshin Impact demo, when deploying your Android applications, you must select the storage size based on the package size. Furthermore, choose an instance size that aligns with the resources you intend to use during your gaming sessions, such as CPU, memory, and networking. For our demo, we launched only one session from a single mobile device.

Launch the instance and wait until it reaches a running status, after which you can SSH into the instance to configure the Android environment.

Installing Anbox Cloud

To ensure the security and reliability of certain package repositories, we update the CUDA Linux GPG Repository Key. For detailed instructions on this procedure, refer to this Nvidia blog post.

$ sudo apt-key del 7fa2af80
$ wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/sbsa/cuda-keyring_1.0-1_all.deb
$ sudo dpkg -i cuda-keyring_1.0-1_all.deb

Since Android in the Anbox Cloud Appliance operates within an LXD container environment, ensure you upgrade LXD to the latest version.

$ sudo snap refresh --channel=5.0/stable lxd

Install the Anbox Cloud Appliance software using the following command, selecting the default answers:

$ sudo anbox-cloud-appliance init

You can monitor the progress of the initialization process on the status page at https://$(ec2_public_DNS_name). This process takes about 20 minutes. After completion, register your previously created Ubuntu SSO account and follow the provided instructions to finalize the setup.

$ anbox-cloud-appliance dashboard register <your Ubuntu SSO email address>

Streaming an Android Game Application

Use the sample from the following repository to set up the service on the streaming server:

$ git clone https://github.com/anbox-cloud/cloud-gaming-demo.git

Build the Flutter web UI:

$ sudo snap install flutter --classic
$ cd cloud-gaming-demo/ui && flutter build web && cd ..
$ mkdir -p backend/service/static
$ cp -av ui/build/web/* backend/service/static

Then, construct the backend service which processes requests and interacts with the Anbox Stream Gateway to create instances of game applications. Prepare the environment:

For more insights on effective mentorship, check out Career Contessa, which is another valuable resource. Furthermore, if you encounter any workplace challenges, SHRM offers authoritative guidance on these matters. For those interested in the interviewing process at Amazon, this Glassdoor link serves as an excellent resource.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *