Game Deployment and Development in Cloud

Rohan Singh
CodinGurukul
Published in
15 min readSep 10, 2018
Credit: Google

Whether you are running applications that share photos to millions of mobile users or you’re supporting the critical operations of your business, a cloud services platform provides rapid access to flexible and low-cost IT resources. With cloud computing, you don’t need to make large upfront investments in hardware and spend a lot of time on the heavy lifting of managing that hardware. You can access as many resources as you need, almost instantly, and only pay for what you use.

You are probably using cloud computing right now, even if you don’t realize it. If you use an online service to send email, edit documents, watch movies or TV, listen to music, play games or store pictures and other files, it is likely that cloud computing is making it all possible behind the scenes.

What is Game Development?

Game Development, in very basic language, is the process of creating the game, no matter whether is the game is as simple as Pacman or as advanced as Battlefield V or GTA V. All the effort is done by the Game Development team who work 24*7 to create a great game and give an experience to their user like innovation, creativity, hosting, matchmaking, syncing of data, correct information.

Game Deployment and Development in AWS Cloud.

When we play games on our Mobile, Tablet, PC, Xbox, PlayStation there are lots of things that work in backend like correct level to be selected, correct syncing of data with player profile, choose equal opponent when playing multiplayer games, no latency in the games especially in arcade and action games, purchasing from online market and then sync with it, login up or signup etc.

Earlier all this happen on non-cloud premises which lead to sometimes loss of data and heavy lifting manually, require a team 24*7 to work upon data because every time thousands of players around playing your game if your game is too popular like Angry Birds, Clash of Clans, Subway Surfer, Temple Run, NFS, FIFA and all every time. These are the game in which there is no chance of latency and choosing of the wrong opponent leads us to somewhere else.

So developers now shifted on the cloud for the development of games whether it is single player or multiplayer. And nowadays games are serverless and there is very low latency as compared to other which doesn’t affect your games and all the heavy lifting is done by cloud so developers can only focus on designing games and give user a great experience without any worry of heavy lifting of games, or syncing of data, database, authentication, analytics, hosting, notifications, analyzing, delivering of media and content, playing correct game without any latency or crashing.

I am going to talk about Game Deployment and Development in Amazon Web Services (AWS) as I work on AWS for Game Deployment in my college summer term.

This blog is about what services you actually need if you are developing and deploying Multiplayer Game in AWS with a brief introduction of services. You can use other AWS Services too.

Let’s check some feature which user sees and how a developer or solution architect see:

So there is the different view of the developer than the user in the game entity and for this AWS provides lots of tools and backend services so that developer can do all these things without any lifting.

Backend Services used in features

Amazon Cognito: Play Button, Login/Signup

Amazon S3 Transfer Utilities: Store

Amazon Cognito Sync: Settings

Dynamo DB: Scores

SNS Mobile Push: Push Notifications

Amazon Mobile Analytics: Stats

Kinesis Recorder: Game Over

In this article, I am going to tell you about the services which you require to which handling game on AWS Cloud.

Amazon Cognito

Amazon Cognito helps developers to create user sign-up, sign-in, and access control to your web and mobile apps quickly and easily. As the cloud service, it is scalable and fully managed which scale up to millions of users.

Its User Pools provide a secure user directory that scales to hundreds of millions of users and it is very easy to set up because it's fully managed service.

It provides two types of security architecture:

  1. Authentication with social identity providers such as Google, Facebook, Microsoft, Amazon etc.
Authentication with social identity

2. Developer Authenticated Identities in which developer can create its own security management instead of a social identity provider

How these identifiers work, I will tell you in my next blog in detail.

Amazon Cognito User Pools is a standards-based Identity Provider and supports identity and access management standards, such as Oauth 2.0, SAML 2.0, and OpenID Connect.

It also supports multi-factor authentication and encryption of data-at-rest and in-transit.

It provides solutions to control access to backend resources from your app. By defining roles and mapping it to a particular user restrict the unauthorized to access your resources.

You can easily integrate sign-in, sign-up, and access control to your app in minutes because of a built-in UI and easy configuration for federating identity providers. You can customize the UI to put your company branding front and centre for all user interactions.

Amazon Cognito Concepts:

1. Identity Pool- it is the store of user identity data securities to your according, so it is the top level you know construct that you would use with incognito and when identity pools you have different identities Amazon.

2. Identities- Authenticated and Unauthenticated- it is for those users who give credentials before playing and unauthenticated who don’t give credentials

3. IAM Roles, trust and permissions- define guest permissions for your users depending on what kind of role they have and what resources they can access. Trust specifies who can assume a role and permission define can be accessed.

Amazon Cognito Sync

  • Store app data, preferences, and state
  • Cross-device cross-OS sync
  • Work Offline

Dataset

Each dataset is the collection of key-value pairs. Each dataset can hold up to 1MB of data and each user with Cognito can have up to 20 data dataset so you can have a separate dataset for app preferences, the separate dataset for purchases.

Import Cognito to your app snippet

DynamoDB

Amazon DynamoDB is a nonrelational database that delivers reliable performance at any scale. It’s a fully managed, multi-region, multi-master database that provides consistent single-digit millisecond latency, and offers built-in security, backup and restore, and in-memory caching.

Create a new table for your application and let DynamoDB handle the rest.

  • Performance at scale
  • Fully Managed
  • Enterprise-ready

None database is open to any IP, the database is always connected with instance behind it so whenever need the user id and password, only instances can talk to the database and ask for user credentials.

AWS provides an object mapper that allows you to basically map your classes to the actual tables itself.

When we create a DynamoDB which has a list of users in there and it authenticates against a DynamoDB table and on the success it returns success and when it’s a success is returns, it returns an open ID token that developer then uses to connect to the different backend services and failure it returns failure and user have to enter their details again.

Mapper Example
Mapper Snippet
Mapper Snippet

There are two main concepts of NoSQL Database:

  1. Replication: In replication, database replicates itself and store its data in more than one site. It copies data from one database to another so the user keeps work without any latency and inconsistency.
Replication
  1. Sharding: When you keep the binary asset, key-value pairs, game state that you want to persist and as the peak load goes up, the no of users increase then you are going to see the database become a bottleneck and then come to a concept of Sharding. Sharding means add more database environment. We have master DB replicated into the secondary copy for durability reasons we might store all the users in there and when we want to increase the capacity we add another environment of DB and split our user base into all these separate DB, as you can see in the figure below, database divided into 3 database one which contains data from alphabet A to H, other from I to P and last one from Q to Z. So this reduces the load on the server so if any new user come and his/her is from P it will directly go into the 3rd database. All the data is stored in the Master Database denoted as M and its copy will be created in the Slave database denoted S in the same region.
Sharding

Amazon Simple Storage Service (S3)

Amazon S3 has a single web services interface that you can use to store and retrieve any amount of data, at any time from anywhere on the web. It gives access to highly scalable, reliable, fast, inexpensive data storage infrastructure that Amazon uses to run its websites globally.

Components of S3

1. Buckets- Folder referred to Buckets and subfolders are referred to folders

2. Objects- Files stored in the buckets

3. Regions- Any data you upload to the S3 bucket will be physically located in a data centre in that region.

Select the region that is physically closest to you customer to reduce transfer latency.

Transfer Utility:

  • Multipart upload i.e. files get broke into chunks and upload it. All done in the backend.
  • Fault-tolerant download.
  • No backend required.
  • Automatic retries.
  • Pause, resume and cancel functions.

How to track transfer progress?

With the transfer utility call, the download and upload methods return a transfer object this object gives you access to the state of the download as an enum. Total bytes transferred, left and a unique ID for tracking. This is called TransferObserver.

To get progress we set a transfer listener on your transfer observer and then can implement these functions called state change progress or an error.

TransferObserver Snippet

Amazon SNS Push

Amazon SNS Mobile Notifications makes it simple and cost effective to send push notifications to iOS, Android, Fire OS, Windows and Baidu-based devices. You can also use SNS to send push notifications to MacOS desktops and Voice over IP (VoIP) apps on iOS devices, emails, and SMS messages to 200+ countries. With SNS, it’s easy to send updates, promos, or news to individual users, a subset of users, or all of your users, using a single message.

It manages the complexity of integrating with the different push notification provider and then managing the push tokens for each individual user and then also the logic itself for managing push notification.

SNS

Amazon Mobile Analytics

Easily collect, visualize and understand your app usage at scale.

It is fast, scalable and generous and you own your data.

  • Focus on metrics that matter, usage reports available within 60 minutes of receiving data from an app.
  • Scale to billions of events per day from millions of users.
  • Data collected are not shared, aggregated or reused.
Initialize the MobileAnalyticsManager

Custom Event tracking using Mobile Analytics

Custom event tracking using Mobile Analytics like how many users completed different levels in this, we can create an analytics event called level complete event and call it and then we pass in attributes which is the level name and the difficulty and we pass a metric which is the quantifiable thing that you can measure.

Can store 100 million events in free tier.

You can track the no of likes and shares per article, no of time a level played by a particular player and even which item is most popular in online game store.

Amazon Kinesis

Amazon Kinesis makes it easy to collect, process, and analyze real-time, streaming data so you can get timely insights and react quickly to new information. Amazon Kinesis offers key capabilities to cost-effectively process streaming data at any scale, along with the flexibility to choose the tools that best suit the requirements of your application. With Amazon Kinesis, you can ingest real-time data such as video, audio, application logs, website clickstreams, and IoT telemetry data for machine learning, analytics, and other applications. Amazon Kinesis enables you to process and analyze data as it arrives and responds instantly instead of having to wait until all your data is collected before the processing can begin.

  • Real-Time
  • Fully Managed
  • Scalable

Now let’s talk about “Common Game Backend Concepts”

  • APIs: allows you to separate frontend and backend which simplifies things like versioning and development of 2 different parts
  • HTTP+JSON: the way to structure the data b/w the client and the server.
  • Get friends, leaderboard, submit scores
  • Binary Asset Data: content you need to download to the client based on what board they are playing in any game or whatever your game needs.
  • Multiplayer servers: need the real-time interaction b/w players and you need a backend to support them maintaining things like game stats and maybe exchanging messages b/w the different connected players and of course you want the environment to be high availability and scalable as well.
  • Scalability.

Here are “Core Game Backend” that you must follow from the very initial stage of development of Game

  • Choose a region: pick region which gives the best user experience.
  • >=2 Availability Zones: within regions, there are more than 2 availability zones isolated from each other by networking, power, cooling.
  • Higher-level tools like AWS opsworks or elastic beanstalk helps to deploy your game servers
  • Amazon EC2 for an app: launch it on the virtual machine that AWS EC2, launch multiple instances and place them in different availability zones for higher availability of the game.
  • Load Balancing: distribute the incoming traffic over the instance of better running using health check to make sure you don’t send to an instance which broken or not working.
  • Amazon RDS database: use because we don’t want to store game state in those virtual servers where you deployed your application if something happens to that instance the state you stored will be gone. So we use the database like MongoDB, DynamoDB, Aurora DB which is highly available and flip the switch to make sure that DB is in multiple availability zones which synchronously replicate data into a second available zone.
  • Scaling: the ability of application or services that are hosted on the cloud to increase as the demand or load increases. This can be achieved by Auto Scaling Groups.

Amazon EC2 Auto Scaling helps you ensure that you have the correct number of Amazon EC2 instances available to handle the load for your application. You create collections of EC2 instances, called Auto Scaling groups.

1. Capacity on demand: adjust the no of instances running based on load we are seeing i.e. increase or decrease the game servers according to the load or demand

2. Respond to users: no matter how much the capacity, it will respond to the user by increasing itself.

3. Automatic healing: game servers get crashed or working slowly it will start a new game server and transfer all the incoming traffic to that new server to avoid problems and start the healing of those servers.

  • Amazon S3 for game data

1. Assets: binary asset

2. UGC: user-generated content

3. Analytics: analyze user behaviour and gameplay

4. CloudFront: to decrease latency you can use CDN such as CloudFront service can be used in front of s3 to make sure static resources are cached more locally to the users and by doing this you decrease the load on the game servers because our server did this previously which means you can run smaller instance that means you are saving money.

Amazon ElastiCache offers fully managed Redis and Memcached. It's a web service that helps improve the performance of web app by allowing you to retrieve information from fast, managed, in-memory caches, instead of relying on slower disk-based databases.

1. Memcached: Memcached is an easy-to-use, high-performance, in-memory data store. It offers a mature, scalable, open-source solution for delivering sub-millisecond response times making it useful as a cache or session store. Memcached is a popular choice for powering real-time applications in Web, Mobile Apps, Gaming, Ad-Tech, and E-Commerce.

2. Redis: Redis is a fast, open-source, the in-memory key-value data store for use as a database, cache, message broker, and queue. It delivers sub-millisecond response times enabling millions of requests per second for real-time applications in Gaming, Ad-Tech, Financial Services, Healthcare, and IoT. Redis is a popular choice for caching, session management, real-time analytics, geospatial, chat/messaging, media streaming, and gaming leaderboards.

But caching a game is only in theory but writing is very painful because lots of things are going in the game that you want to collect like user action, purchase, stats and other data that you want to analyze it to understand so that you can improve the game and, in that scenario, adding a cache is not good because of limited use.

Let talk about the things you keep in mind when creating a multiplayer game — “Multiplayer Game Servers”

  • Login Via API: when a user wants to play the game, they connect to the API service, log in or do whatever which is required to start a game.
  • Request Matchmaking: user wants to start a new game by request matchmaking (finding opponent of the same category).
  • Get game server IP: we want to return like the IP address and potentially a port number of the game server to connect, use tools as a registry for tracking what’s running in our environment.

We can do this by EC2 APIs to track what game servers are running, a load on servers, initialize to make a sure scene is in the right state before connection.

  • Connect to the server: and once we are done we take the IP and port number of that game server and return to the client for connection to an instance.
  • Pull down assets: players might download asset according to his/her game requirements.
Multi-region Game server presentation

Let’s go to a comprehensive suite of products and services that provide solutions to the everyday problems of game development provided by Amazon Web Services.

AWS provides great products specific for Game Development that can handle any game on any platform with great ease.

Note: Earlier Mention services can be used in other products too apart from a game but these are only for Game Development & Deployment

Amazon Game Lift

Save thousands of engineering hours and reduce cost with Amazon GameLift, the dedicated game server hosting and matchmaking solution built on AWS. Use Amazon GameLift to deploy, scale, and manage your dedicated game servers in the cloud, delivering low-latency, fun and reliable gaming experiences to your players around the world. Focus on creating a great multiplayer game for your players, not building scalable server infrastructure.

AWS Lumberyard

Lumberyard is architected for performance, modularity, and productivity. Reduce time to quality and maximize ambition, across PC, console, and mobile.

Engage and grow your community inside and outside of your game and build games as fun to watch as they are to play, with Lumberyard’s Twitch integration.

Lumberyard is free and includes full source. There are no seat fees, subscription fees, or requirements to share revenue. Only pay for the AWS services you choose to use.

Cloud Canvas

Deeply integrated with AWS, Cloud Canvas is a suite of tools and solutions (cloud gems, resource groups, script canvas nodes) designed to achieve two main goals:

  1. Make it easy for you to build cloud-connected features, so you can focus on innovation rather than on undifferentiated backend infrastructure.
  2. Make it possible for you to create fantastic new experiences made possible by the availability of the on-demand, global storage and compute provided by AWS.

With Cloud Canvas, you can add a cloud-connected feature to your game in as little as 30 minutes. A single engineer can do this, freeing up the rest of your team to think about innovation and player experience.

So these are the services, core concepts, and the suite of tools that you need when developing and deploying a game on a cloud.

--

--

Rohan Singh
CodinGurukul

Infrastructure @ SADA | Google Cloud Champion Innovator | Motorcyclist | rohans.dev