building games with aws mobile services - aws-de-media.s3...
TRANSCRIPT
AWS GAMINGAWS GAMING
BuildingGameswithAWSMobileServices
Ozkan Can – Solutions Architect, AWS
@_ozkancan
AWS GAMINGAWS GAMING
HowDoYouBuildaMobileGameToday?
AWS GAMINGAWS GAMING
COMPUTESERVICE
EVENTDRIVEN
Runcodewithoutthinkingabout
servers
Codeonlyrunswhenitneedstorun
AWS LAMBDA
AWS GAMINGAWS GAMING
AWS LAMBDA: BENFITS
EVENT-DRIVENSCALESERVERLESS SUBSECONDBILLING
$
AWS GAMINGAWS GAMING
BRINGYOUROWNCODE COMPUTE“POWERLEVELS”
FLEXIBLEINVOCATIONPATHS GRANULARPERMISSIONSCONTROL
AWS LAMBDA: HOW IT WORKS
AWS GAMINGAWS GAMING
AWSCloudFormationcustomresources
…andthelistwillcontinuetogrow!
AmazonEchoskills AmazonSWFtasks CustomizednotificationswithAmazonSNS
AmazonCognitotriggersAmazonS3triggers
AmazonDynamoDBtriggers
AmazonKinesisprocessors
MicroserviceswithAPIGateway
MULTIPLE WAYS TO PUT LAMBDA TO WORK
AWS GAMINGAWS GAMING
Whatitdoes
Useradministration
Contentstorage
Pushnotifications
Analyzeuserbehavior
Customapplogic
Howitbehaves
Costfollowsusage
Minimalundifferentiatedheavylifting
Iterativedevelopment
Reducedtimetomarket
Instantscale
Reliableandsecure
BACK-END WISHLIST
AWS GAMINGAWS GAMING
AuthenticateusersManageusersandidentityproviders
AuthorizeaccessSecurelyaccesscloudresources
SynchronizedataSyncuserpreferencesacrossdevices
StoreandDelivermediaStoreDLCandDeliverContentQuickly
AWS GAMINGAWS GAMING
SendRealTimeEventsCreateLiveDashboardstotrackusereventsinrealtime
AnalyzeUserBehaviorTrackactiveusers,engagementandstats
StoreshareddataStoreandqueryfastNoSQLdataacrossusersanddevices
SendPushNotificationsBringusersbacktoyourappbysendingmessagesreliably
AWS GAMING
Createprofile,uploadcontent,andtrackusage
Trackplayerprogressandfriends
Matchandnotifyusers
App-centric“You”
Activity-centric“Whatyoudo”
Userbase-centric“Them&me”
1
2
3
BACK-END LAYERS
AWS GAMING
Createaprofile,uploadcontent,andtrackusage
1
AWS GAMING
Cognito
PinpointCampaigns
SNSMobilePush
KinesisRecorder DynamoDBMapper S3TransferManager
SQSClient
AWSglobalinfrastructure(regions,AvailabilityZones,edgelocations)
Corebuildingblockservices
Mobile-optimizedconnectors
Your mobile game
AWSMobileSDK(iOS,Android,Unity,Xamarin)
Compute Storage Networking Analytics Databases
IntegratedSDK
Lambda
AWS GAMING
Mobileclient
IAM PermissionsAWSSecurityTokenService
1.Requesttoken
2.Receivetemporarycredentials
3.SignAPIrequestwithtemporarytoken AWSServiceAPIs
4.MakeAPIrequestagainstAWSserviceAPI
SECURITY MODEL FOR API CALLS
AWS GAMING
• Generatetemporarycredentialsandenforcerotationtolimitcredentiallifetime
• Authenticateuserthroughthird-partyauthenticationprovider
• Uniqueusersacrossmultiple devicesandidentityproviders
• Allowsanonymous useraccess• EnablessecuritybestpracticesthroughIAM
roles
AUTHENTICATE YOUR PLAYER: AMAZON COGNITO
AWS GAMING
//Create and configure Cognito credentials provider
AWSCognitoCredentialsProvider *credentialsP = [AWSCognitoCredentialsProvidercredentialsWithRegionType:AWSRegionUSEast1 accountId:@"0123456789” identityPoolId:@”us-east-1:beeeeeef-beef-beef-beef-beef” unauthRoleArn:@"arn:aws:iam::0123456789:role/Unauth” authRoleArn:@"arn:aws:iam::0123456789:role/Auth"];
//Set Cognito as default credentials provider for all AWS service calls
AWSServiceConfiguration *configuration = [AWSServiceConfigurationconfigurationWithRegion:AWSRegionUSEast1 credentialsProvider:credentialsP];
[AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration;
USE COGNITO FOR AUTHENTICATION ON IOS
AWS GAMING
• Createyourappprofileandsaveitlocally intheCognitodatastore
• Cognitowillsynchronize thedatasetsacrossallyouruser’sdevices
• Cognitodatasetsarekey/valuepairs
AWSCognito *syncClient = [AWSCognito defaultCognito];
AWSCognitoDataset *subs = [syncClientopenOrCreateDataset:@”UserProfile"];
[dataset setString:”Ozzy" forKey:@”name"];[dataset setString:”11235813" forKey:@”hscore"];
[dataset synchronize];
CREATE YOUR PLAYER PROFILE: COGNITO SYNC
AWS GAMING
• AmazonS3tostoreandshareUGCdirectlyfromthemobiledevice
• S3TransferUtilityprovides:• Abilitytocontinuetransferringdatainthe
background whenyourappisnotrunning• Abilitytouploadbinarydatainsteadofhaving
tofirstsaveitasafileonthedevice
AmazonS3
UPLOAD USER GENERATED CONTENT (UGC): AMAZON S3
AWS GAMING
NSData *dataToUpload = // The data to upload
AWSS3TransferUtility *transferUtility = [AWSS3TransferUtility defaultS3TransferUtility];
[[transferUtility uploadData:dataToUpload
bucket:@"YourBucketName"
key:@"YourObjectKeyName"
contentType:@"text/plain"
expression:expression
completionHander:completionHandler] continueWithBlock:^id(AWSTask *task) {
if (task.result) {
AWSS3TransferUtilityUploadTask *uploadTask = task.result;
// Do something with uploadTask
}
}
S3 TRANSFER UTILITY: IOS CODE
AWS GAMING
• Allowsyoutocollect,visualize,andunderstandyourmobileappusage
• Scalesseamlesslytobillions ofeventsperday• Youretainfullcontrolandownership ofthedata• Definesegmentationcriteriabasedonusage,
device andcustomattributeslikegameprogress• Targetyouraudiencewithcustompush
notifications foryourcampaigns
AMAZON PINPOINT: TRACK APP USAGE & ENGAGE PLAYERS
AmazonPinpoint
AWS GAMING
AWS GAMING
Createprofile,uploadcontent,andtrackusage
Trackplayerprogressandfriends
Matchandnotifyusers
App-centric“You”
Activity-centric“Whatyoudo”
Userbase-centric“Them&me”
1
2
3
BACK-END LAYERS
AWS GAMING
Trackplayerprogressandfriends
2
AWS GAMING
Back-endlogic DatabaseMobile
HOW TO COLLECT PROGRESS AND FRIENDS?
AWS GAMING
AmazonLambda
AmazonAPIGateway
AmazonDynamoDB
• /progress• /friends
• reportProgress()• getProgress()• addFriend()• listFriends()
Microservice
• progress-table• friends-table
“PROGRESS TRACKER” AND “INTEREST” MICROSERVICE
AWS GAMING
• FullymanagedandscalableRESTful APIgatewayservice
• Poweredthroughourcontentdeliverynetworkviaourover70globaledgelocations
• Provides DDoS protectionandthrottling capabilities• MultipleAPIstageswhichyoudefine(e.g.dev,test,
prod)
AWSLambda
AmazonAPIGateway
AmazonEC2
AWSAPI
On-premserver
AMAZON API GATEWAY
AWS GAMING
• AmazonAPIGatewayaddsanadditionallayerbetweenyourmobileusersandyourlogicanddatastoresinorderto:
• Allowback-endlogictobeinterchanged withoutmobileappcodemodifications
• Abilitytothrottle individualusersorrequests• ProtectagainstDDoS attacksincludingcounterfeit
requests(Layer7)andSYNfloods(Layer3)• Provideacachinglayerforyourcalls
WHEN TO CHOOSE API GATEWAY VS. DIRECT SDK?
AWS GAMING
Createprofile,uploadcontent,andtrackusage
Trackplayerprogressandinterests
Matchandnotifyusers
App-centric“You”
Activity-centric“Whatyoudo”
Userbase-centric“Them&me”
1
2
3
BACK-END LAYERS
AWS GAMING
Matchandnotifyplayers
3
AWS GAMING
DynamoDBstreams
CognitoSynctrigger
S3eventnotification
AWS LAMBDA: EVENT-DRIVEN COMPUTE
AWS GAMING
/progress
RESTAPIProfile(friendssetting)
friends-table
AWSSDKcall
reportProgress()
Invoke
findMatch()
DynamoDB Streams
progress-table
AWSSDKcall
friends-tableaddFriend()
/friends
FIND A FRIEND MATCH BASED ON PROGRESS
AWS GAMING
exports.handler = function(event, context) {
// Process all the records in the stream
event.Records.forEach(function(record) {
var newProgress = record.dynamodb.NewImage.progress.S;
if (findFriendMatch(newProgress)) {
// Found match!
}
});
context.succeed();
};
DYNAMODB STREAMS PROCESSOR: findMatch()
AWS GAMING
Wefoundamatch.Nowwhat?
AWS GAMING
• AmazonSNSisafullymanaged,cross-platformmobilepushintermediaryservice
• Fullyscalabletomillions ofdevices
• Allowsyoutocreatetopics(e.g.perprogress,interest,usagepattern,etc.)
AppleAPNS
GoogleGCM
AmazonADM
WindowsWNSandMPNS
BaiduCP
Androidphonesandtablets
AppleiPhonesandiPads
KindleFiredevices
AndroidphonesandtabletsinChina
iOS
Windowsphonedevices
AmazonSNS
AMAZON SNS FOR MOBILE PUSH NOTIFICATIONS
AWS GAMING
AWSSDKcall
findMatch()
DynamoDB Streams
progress-table
interest-table
AmazonSNS
FOUND A MATCH: NOTIFY USER!
AWS GAMING
Createprofile,uploadcontent,andtrackusage
Trackplayerprogressandinterests
Matchandnotifyusers
App-centric“You”
Activity-centric“Whatyoudo”
Userbase-centric“Them&me”
1
2
3
BACK-END LAYERS
AWS GAMING
MobileAppMobileSDK
AmazonAPIGateway
AWSLambda
AmazonS3
AmazonDynamoDB
AmazonCognito
AmazonPinpoint
AmazonSNS
FINAL ARCHITECTURE
AWS GAMINGAWS GAMING
Serverless =Fast&Secure
AWS GAMING
AWS GAMING
BEGIN YOUR JOURNEY WITH AWS!