build and deploy your mobile games
TRANSCRIPT
1
Build & Deploy Your Mobile Game with AWS
Dhruv ThukralSolutions Architect, Gaming
Tara WalkerTechnical Evangelist
AWS Gaming Solutions
Authenticate users
Authorize access
Synchronize data
Manage users and identity providers
Securely access cloud resources
Sync user preferences across devices
Store and Deliver media
Send Push Notifications
Store user-generated photos Media and share them
Bring users back to your app by sending messages reliably
Store shared dataStore and query fast NoSQL data across users and devices
Analyze User BehaviorTrack active users, engagement
AWS Gaming Solutions
Introducing AWS Mobile Services
Amazon Cognito Amazon Mobile Analytics Amazon SNS Mobile Push
Kinesis Recorder DynamoDB Mapper S3 Transfer Mgr SQS Client SES Client
Core Building Block
Services
Mobile Optimized
Connectors
Mobile Optimized
Services
Your Mobile Game
AWS Mobile SDK for iOS, Android & Unity, API Endpoints, Management Console
Compute Storage Networking Analytics Databases
Integrated SDK
AWS Lambda
Lambda
Functions
λ λλλ
AWS Gaming Solutions
Cross-platform, Optimized for Mobile
User identity &
data synchronization
service
Store any NoSQL
data and also map
mobile OS specific
objects to tables
Fast cross-platform
Analytics & reporting
Service
Powerful Cross-platform
Push notification service
Recorder that can
handle intermittent
network connection
Easily upload,
download to S3 and
also pause,
resume, and cancel
Send email
reliably from
device
Access
distributed
buffering and
queuing service
Amazon Cognito Amazon Mobile Analytics Amazon SNS Mobile Push
Kinesis Recorder DynamoDB Mapper S3 Transfer Mgr SQS Client SES ClientAWS Lambda
Lambda
Functions
λ λλλ
Not limited to Mobile.
Run stateless cloud
Functions without any
Backend servers to
Manage or scale
AWS Gaming Solutions
Amazon Cognito
Simplifies Identity and
Access Management
Securely access all
AWS services from
Mobile device
Cross-device and
Cross-platform SyncImplement security best
practices
“Your App data is secure, available offline, and kept in sync between devices”
Synchronize user’s data
across devices and
platforms
Manage users as
unique identities across
identity providers
Guest Your own
Auth
AWS Gaming Solutions
Getting Started with Cognito in 3 steps
Sign up for AWS Account and login to AWS Management Console
Download and integrate the Mobile SDK and store and
sync user data in a dataset
Create an identitypool for authenticated and
unauthenticated users in the AWS Console
AWS Gaming Solutions
Amazon Cognito Security
Set granular access permissions on AWS
resources
Safeguard AWS Credentials
Helps implement security best practices
EC2 S3 DynamoDB Kinesis
AWS Gaming Solutions
Amazon Cognito Security Architecture
End Users
App with
AWS Mobile
SDK
Access
to AWS
Services
Login OAUTH/OpenID
Access Token
Cognito ID,
Temp
Credentials
Access
Token
Pool ID
Role ARNs
Cognito ID
(Temp
Credentials)
DynamoDB
Developer
Cognito Identity
Broker
S3
Mobile Analytics
Cognito Sync
Store
AWS
Management
Console
AWS Gaming Solutions
Developer Authenticated Identities
Cognito ID
(Temp
Credentials)
DynamoDB
End Users
Developer
Access
to AWS
Services
Cognito Identity
Broker
Get OpenID Token
Username
password
Cognito ID,
Temp Credentials
S3
Mobile Analytics
Cognito Sync
Store
AWS
Management
Console
OIDC Token
Pool ID
Role ARNs
User Authentication
System
(Running on AWS or not)
OIDC Token
OIDC Token
AWS Gaming Solutions
Concrete Software builds cross platform mobile games
Concrete Software has been making hit mobile games
like Jellyflop and PBA Bowling Challenge since 2003.
With Amazon Cognito, We
can build games much faster
and provide great user
experience to our customers.
Keith A. Pichelman
CEO, Concrete Software
”
“• Provide a seamless user experience across devices
and platforms to our users.
• Store save games in the cloud and synchronize them
across all of a user’s devices without creating or
hosting a backend.
The Challenge
The solution
• Amazon Cognito helps us securely access our AWS
resources.
• Cognito Sync gives us flexibility to save data in the
cloud, and cache it on a user’s devices, without
managing any backend infrastructure.
AWS Gaming Solutions
Amazon Cognito Sync
User Data
Storage and
Sync
Any Platform
iOS/Android/FireOS
Store App Data, Preferences and StateSave app and device data to the cloud and merge
them after login
Cross-device Cross-OS Sync Sync user data and preferences across devices
with one line of code
Work OfflineData always stored in local SQLite DB first.
Works seamlessly when intermittent or no
connectivity
k/v data
Identity pool
AWS Gaming Solutions
Integrating Cognito Sync functionality is simple
Initialize the CredentialsProvider and CognitoClient
Call synchronize on the dataset
Create or open Dataset and Add Key Values
provider = new CognitoCachingCredentialsProvider (context, AWS_ACCOUNT_ID,
COGNITO_POOL_ID, COGNTIO_ROLE_UNAUTH, COGNITO_ROLE_AUTH, Regions.US_EAST_1);
cognito = new CognitoSyncManager (context, COGNITO_POOL_ID, Regions.US_EAST_1, provider);
dataset.synchronize(new SyncCallback(){..});
cognito.openOrCreateDataset(datasetName);
dataset.put(key, value);
AWS Gaming Solutions
Integrating Cognito Sync functionality is simple
Initialize the AWSCognitoSyncClient
Call synchronize on the dataset
Create or open Dataset and Add Key Values
DataSet *dataset = [syncClient openOrCreateDataSet:@"myDataSet"];
NSString *value = [dataset readStringForKey:@"myKey"];
[dataset putString:@"my value" forKey:@"myKey"];
AWSCognitoSyncClient *syncClient = [[AWSCognitoSyncClient alloc]
initWithConfiguration: configuration];
[dataset synchronize];
iOS
AWS Gaming Solutions
Amazon S3 Connector: Transfer Manager
S3 Connector
Multipart upload media (photos, videos, audio)
Fault tolerant download (e.g. assets)
No backend required
Automatic retries
Pause, resume, cancel functions
Optimized for native OS
AWS Gaming Solutions
// Creating the transfer manager
self.transferManager = [S3TransferManager new];
self.transferManager.s3 = s3client;
// Upload image
[self.transferManager uploadFile:fileName bucket:bucketName key:objectName];
// Download image
[self.transferManager downloadFile:fileName bucket:bucketName key:objectName];
// Pause, Resume, Cancel
[self.transferManager pauseAllTransfers];
[self.transferManager resumeAllTransfers];
[self.transferManager cancelAllTransfers];
Amazon S3 Connector: Transfer Manager
AWS Gaming Solutions
Outplay Entertainment – Amazon S3 Connector via Mobile SDK
Outplay Entertainment is mobile-focused game
developer on a mission to deliver fun, free and
innovative games for smartphones, tablets, and social
networks.
With Amazon S3 connector, we can
improve the users experience by
dynamically downloading game assets
in the background. No long up-front
delays for our users.
Douglas Hare
CEO, Outplay Entertainment
”
“ • Improved User Experience. Using the Mobile SDK,
they can download the game assets in background
while the user starts playing the game. No limits on
downloading extra assets.
• Dynamic updates. They can update the assets
dynamically and avoid AppStore release cycles.
• Unquestioned Scalability. Different assets for
multiple screen densities go up to 170 MB+. By
storing this data on S3 and directly downloading to
the mobile device, they can scale seamlessly.
• Excellent Performance. Highest resolution devices
end up downloading about 90MB of extra content.
AWS Gaming Solutions
Amazon Mobile Analytics
Scalable and Generous
Free Tier
Focus on metrics that matter. Usage
reports available within 60 minutes of
receiving data from an app
Fast
Scale to billions of
events per day from
millions of users.
Own Your Data
“Easily collect, visualize and understand your app usage data at scale”
Data collected are not
shared, aggregated, or
reused
AWS Gaming Solutions
Getting Started with Mobile Analytics
in 3 steps
Sign up for AWS Account and create or use existing Cognito ID in
the AWS Management Console
View engagement and session activity reports in the
AWS Management console within minutes
Download and integrate the Mobile SDK with one line of
code (Android/FireOS, iOS)
AWS Gaming Solutions
Key Business Metrics
(with one line of code)
1. Monthly Active Users
(MAU)
2. Daily Active Users
(DAU)
3. New Users,
4. Daily Sessions,
5. Sticky Factor,
6. 1-Day Retention,
7. Avg. Revenue per DAU,
8. Daily Paying Users,
9. Avg. Paying DAU
AWS Gaming Solutions
Get behavioral insights into app specific
actions that your users take
Reports provide a view of how often custom
events occur. You can add further context
with Attributes and Metrics, to each custom
event
Track the number of
Likes/Shares, per
article, in a news app
Understand player
abort rates per
level, in a game
Number of songs
played, per user
session, in a music
app
In-app item popularity
in a shopping app
Track Custom Events
AWS Gaming Solutions
Integrating Mobile Analytics is simple
Initialize the MobileAnalyticsManager. That’s it!
For Custom Events activity reports, add events.
Add OnResume() and OnPause()
private static MobileAnalyticsManager analytics;
analytics = MobileAnalyticsManager.getOrCreateInstance(
this.getApplicationContext(),"yourCompany.yourAppId",
Regions.YOUR_REGION, config, cognitoProvider );
EventClient eventClient = analytics.getEventClient();
MobileAnalyticsEvent visitEvent = eventClient.createEvent("speedSet");
eventClient.recordEvent(visitEvent);
analytics.getSessionClient().resumeSession();
analytics.getSessionClient().pauseSession();
Analytics.getEventClient().submitEvents();
AWS Gaming Solutions
Integrating Mobile Analytics is simple
Initialize the AWSMobileAnalytics object. That’s it!
Submit the event. If we don't call submitEvents, events
will automatically be submitted at periodic intervals.
Create add Custom Events
[eventClient submitEvents];
id<AWSMobileAnalyticsEventClient> eventClient =
analytics.eventClient;
id<AWSMobileAnalyticsEvent> level1Event = [eventClient
createEventWithEventType:@"level1Complete"];
AWSMobileAnalytics* analytics = [AWSMobileAnalytics
defaultAWSMobileAnalyticsWithIdentifier:@"someuniqueid"];
iOS
AWS Gaming Solutions
Each platform works differently, and push gets more
complex as you scale to support millions of devices.
Cloud App
Platform Services Mobile Apps
AWS Gaming Solutions
Amazon SNS
Cross-platform
Mobile Push
Internet
Apple APNS
Google GCM
Amazon ADM
Windows WNS and
MPNS
Baidu CP
New features:
Message Expiry TimeMessage Attributes
Delivery StatusBroadcast
iOS 8 support.
Amazon SNS Mobile Push
Android Phones and Tablets
Apple iPhones and iPads
Kindle Fire Devices
Android Phones and Tablets in China
iOS
Windows Desktop and Windows Phone
Devices
AWS Gaming Solutions
Joe Anna Bob
Highscores
Joe 1500
Anna 800
Bob 750
Amazon DynamoDB Connector: Object Mapper
Simplifies access to Amazon
DynamoDB in your app
Map client-side classes to Amazon
DynamoDB tables
Removes the need to transform
objects into tables and vice versa
AWS Gaming Solutions
Amazon DynamoDB: Example@DynamoDBTable(tableName = ”Highscores")
public static class HighScore{
private int id, highScore;
private String name;
@DynamoDBHashKey(attributeName = "id")
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@DynamoDBAttribute(attributeName=”name")
public String getName() {
return name;
}……
id name highscore
17 Joe 25
23 Anna 67
32 Bob 55
Table: Highscores
AWS Gaming Solutions
Amazon DynamoDB: Example// Build a highscore object
HighScore highScore = new HighScore();
highScore.setId(17);
highScore.setName(”Joe");
highScore.setHighScore(25);
// Save book object to dynmaoDB
mapper.save(highScore);
// Update item and save object again
highScore.setHighScore(118);
mapper.save(highScore);
// Load another book
HighScore anotherHighScore = mapper.load(HighScore.class,23);
AWS Gaming Solutions
Amazon DynamoDB Best Practices
• Keep item size small
• Store metadata in Amazon DynamoDB and
large blobs in Amazon S3
• Use a table with a hash key for extremely
high scale
• Use table per day, week, month etc. for
storing time series data
• Use conditional/OCC updates
• Avoid hot keys and hot partitions
AWS Gaming Solutions
Scale It Way Out
ELB
S3
• Auto Scaling Group
• Capacity on Demand
• Respond to Users
EC2EC2EC2
Region
AWS Gaming Solutions
Scale It Way, Way Out
ELB
S3
• Auto Scaling Group
• Capacity on Demand
• Respond to Users
• ElastiCache
• Memcached
• Redis EC2EC2EC2
Region
AWS Gaming Solutions
Scale It Way, Way, Way Out
CloudFront
CDN
ELB
S3
EC2EC2EC2
Region
• Auto Scaling Group
• Capacity on Demand
• Respond to Users
• ElastiCache
• Memcache
• Redis
• CloudFront CDN
• DLC, Assets
• Game Saves
• User-Generated
Content
AWS Gaming Solutions
Elastic Beanstalk
• Managed Container
• ELB, EC2, RDS
• Git Push or Zip Upload
• Web Dashboard
• Same Performance
AWS Gaming Solutions
AWS Lambda
Auto Scaling
(Never under or over
provision)
Focus on business logic,
not infrastructure. Upload
your code; AWS Lambda
handles everything else
Zero Administration
Lambda scales the
infrastructure as needed
to match the event rate
and pay as you go
Bring Your Own Code
“Run stateless functions in the cloud and scale without any servers to manage”
Starting with Javacript but
later bring your own code,
Create threads and
processes, run batch scripts
or other executables,
AWS Gaming Solutions
An Event Driven Asynchronous Code
Execution Platform.
1. Custom event
2. S3 Notifications
3. DynamoDB Changes
4. Kinesis
AWS Gaming Solutions
An Event Driven Asynchronous Code
Execution Platform.How do invoke a function?
Directly Invoke on Lambda Console
Use SDK or CLI and call invoke-async
Registering an Event (S3, DynamoDB, Kinesis)
X Cron-ish
X RPC
X REST
AWS Gaming Solutions
An Event Driven Asynchronous Code
Execution Platform.
• A call to a Lambda function is non-blocking.
• You do not wait for an answer.
• You just assume your function will be executed and your request
processed.
AWS Gaming Solutions
An Event Driven Asynchronous Code
Execution Platform.
• Underlying Infrastructure is Entirely Managed for You!
• Supports Node.js only but more languages coming soon.
• Runs on Amazon Linux.
• Offers 500MB of /tmp storage.
AWS Gaming Solutions
Messages and Queues
ELB
S3
• Simple Notification Service
• HTTP
• SMS
• Mobile Push
EC2EC2EC2
Region
AWS Gaming Solutions
Messages and Queues
ELB
EC2EC2EC2
Region
EC2EC2
• Simple Notification Service
• HTTP
• SMS
• Mobile Push
• CloudWatch
• Monitoring
• Alerts
• SQS
• Background Tasks
• Avatar Resizing
• Score Processing
AWS Gaming Solutions
Messages and Queues
ELB
EC2EC2EC2
Region
EC2EC2
• Simple Notification Service
• HTTP
• SMS
• Mobile Push
• CloudWatch
• Monitoring
• Alerts
• SQS
• Background Tasks
• Avatar Resizing
• Score Processing
AWS Gaming Solutions
AWS Mobile SDKs for Gaming
1. AWS Mobile SDK for Android
2. AWS Mobile SDK for iOS
3. AWS Mobile SDK for Unity (Developer Preview)
AWS Gaming Solutions
SDK Installation and Setup
• Download AWS Unity SDK and unzip– http://aws.amazon.com/mobile/sdk/
• Import the desired package(s) into Unity as a Custom Package– CognitoSync Package
– DynamoDB Package
– S3 Package
– MobileAnalytics Package
• Add the AWSPrefab to Scene in Unity
AWS Gaming Solutions
Grumpy Flappy Game
• Demo will showcase– Cognito Identity
– Cognito Sync
– Mobile Analytics
• Demo will be open-sourced …and polished– Showing more of the AWS services
• Other Unity Samples Available on GitHub
AWS Gaming Solutions
Grumpy Flappy : Services Setup
• Set up Cognito Identity Pool– Create Grumpy Flappy Identity Pool
– Retrieve Identity Pool ID
• Set up Mobile Analytics App– Add Grumpy Flappy App
– Retrieve App ID
AWS Gaming Solutions
Adding DynamoDB
• Create DynamoDB Table– Using DynamoDB Console
– Using code with createTable method
– Using Visual Studio with AWS Toolkit for Visual Studio: http://aws.amazon.com/net/
– Example:
• Table Name: GrumpyHighScores
• Primary Key Type: Hash
• Hash Attribute Name: ScoreID,
• Hash Type: Number
• Create DynamoDB ClientAmazonDynamoDBClient client = new
AmazonDynamoDBClient(RegionEndpoint.USEast1)
AWS Gaming Solutions
Using DynamoDB
• Add a High Score Record
– Create High Score Object[DynamoDBTable("GrumpyHighScores")]
class HigScore
{ [DynamoDBHashKey] // hash key
public int ScoreID { get; set; }
[DynamoDBProperty]
public string Score { get; set; }
public string UserID {get; set; }
}
– Save High Score Record to DynamoDB_context.SaveAsync<Book>(myBook,
(AmazonDynamoResult<VoidResponse> result) =>
{ if (result.Exception != null) { this.displayMessage += "Save
failed ; “ +result.Exception.Message; }
AWS Gaming Solutions
Adding Simple Storage Service (S3)
• Create S3 Bucket (set permissions)
– Using S3 Console
– Using code with PutBucket and PutBucketRequest
– Using Visual Studio with AWS Toolkit for Visual Studio: http://aws.amazon.com/net/
– Example:
• Bucket Name: grumpyflappy_bucket
• Create an S3 Transfer ManagerAmazonS3Client S3Client =
new AmazonS3Client (credentials ,RegionEndpoint.USEast1);
AWS Gaming Solutions
Using Simple Storage Service (S3)
• Download an Object
– Get Badge Picture (bragging rights)var request = new GetObjectRequest ()
{ BucketName = bucketName,
Key = downloadKey,
};
S3Client.GetObjectAsync (request, GetObjectCallback,null);
• Upload an ObjectStream stream = null;
stream = new FileStream(uploadSrcFilePath, FileMode.Open, FileAccess.Read,
FileShare.Read);
var postRequest = new PostObjectRequest
{ Key = uploadKey, Bucket = bucketName, InputStream = stream };
S3Client.PostObjectAsync (postRequest, PostObjectCallback,null);
AWS Gaming Solutions
AWS Resources
• AWS Mobile Blog– http://mobile.awsblog.com
• AWS Mobile Services– http://aws.amazon.com/mobile/
• AWS Mobile SDK– http://aws.amazon.com/mobile/sdk/
• AWS Mobile Developer Guides– Unity: http://docs.aws.amazon.com/mobile/sdkforunity/developerguide
– iOS: http://docs.aws.amazon.com/mobile/sdkforios/developerguide
– Android: http://docs.aws.amazon.com/mobile/sdkforandroid/developerguide/Welcome.html