Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Build and Deploy Your Mobile Games

5,643 views

Published on

Developing a successful mobile game today is about more than just the game: Users expect backend services like user authentication, downloadable content, and social features. Using our AWS Mobile SDK for iOS and Android, it’s easier than ever to build a game with these services. This session will provide a step-by-step approach to add features to your game such as user identity management, dynamic content updates, cross-platform data sync, and more. We’ll demonstrate how to use the AWS Mobile SDK to securely interact with services such as Cognito, DynamoDB, S3, and EC2. Finally, we’ll provide a few common architecture patterns and scalability tips for AWS game backends.

Published in: Technology
  • Want to preview some of our plans? You can get 50 Woodworking Plans and a 440-Page "The Art of Woodworking" Book... Absolutely FREE ➤➤ http://tinyurl.com/yy9yh8fu
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Build and Deploy Your Mobile Games

  1. 1. 1 Build & Deploy Your Mobile Game with AWS Dhruv Thukral Solutions Architect, Gaming dhruv@amazon.com Tara Walker Technical Evangelist tarawalk@amazon.com
  2. 2. AWS Gaming Solutions
  3. 3. AWS Gaming Solutions Table stakes for your mobile game!
  4. 4. 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 data Store and query fast NoSQL data across users and devices Analyze User Behavior Track active users, engagement
  5. 5. 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 λ λ λ λ
  6. 6. 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
  7. 7. AWS Gaming Solutions Authenticate users: Amazon Cognito
  8. 8. AWS Gaming Solutions Amazon Cognito Simplifies Identity and Access Management Securely access all AWS services from Mobile device Cross-device and Cross-platform Sync Implement 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
  9. 9. 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
  10. 10. 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
  11. 11. 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
  12. 12. 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
  13. 13. 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.
  14. 14. AWS Gaming Solutions Synchronize data across devices : Amazon Cognito (Sync)
  15. 15. AWS Gaming Solutions Amazon Cognito Sync User Data Storage and Sync Any Platform iOS/Android/FireOS Store App Data, Preferences and State Save 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 Offline Data always stored in local SQLite DB first. Works seamlessly when intermittent or no connectivity k/v data Identity pool
  16. 16. 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);
  17. 17. 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
  18. 18. AWS Gaming Solutions Store and deliver media assets: Amazon S3 and CloudFront
  19. 19. 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
  20. 20. 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
  21. 21. 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.
  22. 22. AWS Gaming Solutions Analyze User Behavior: Amazon Mobile Analytics
  23. 23. 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
  24. 24. 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)
  25. 25. 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
  26. 26. 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
  27. 27. 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();
  28. 28. 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
  29. 29. AWS Gaming Solutions Send Push Notifications: Amazon SNS Mobile Push
  30. 30. 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
  31. 31. 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 Time Message Attributes Delivery Status Broadcast 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
  32. 32. AWS Gaming Solutions Store Shared Data: Amazon DynamoDB
  33. 33. 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
  34. 34. 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
  35. 35. 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);
  36. 36. 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
  37. 37. AWS Gaming Solutions Adding a Server Backend
  38. 38. AWS Gaming Solutions 3 Ways To Do This! Do It Yourself. Serverless Fully Managed
  39. 39. AWS Gaming Solutions Basic Core Game Stack ELB S3 Region
  40. 40. AWS Gaming Solutions Scale It Way Out ELB S3 • Auto Scaling Group • Capacity on Demand • Respond to Users EC2EC2EC2 Region
  41. 41. AWS Gaming Solutions Scale It Way, Way Out ELB S3 • Auto Scaling Group • Capacity on Demand • Respond to Users • ElastiCache • Memcached • Redis EC2EC2EC2 Region
  42. 42. 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
  43. 43. AWS Gaming Solutions 3 Ways To Do This! Do It Yourself. Serverless Fully Managed
  44. 44. AWS Gaming Solutions Elastic Beanstalk • Managed Container • ELB, EC2, RDS • Git Push or Zip Upload • Web Dashboard • Same Performance
  45. 45. AWS Gaming Solutions 3 Ways To Do This! Do It Yourself. Serverless Fully Managed
  46. 46. 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,
  47. 47. AWS Gaming Solutions An Event Driven Asynchronous Code Execution Platform.
  48. 48. AWS Gaming Solutions An Event Driven Asynchronous Code Execution Platform. 1. Custom event 2. S3 Notifications 3. DynamoDB Changes 4. Kinesis
  49. 49. 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
  50. 50. 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.
  51. 51. 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.
  52. 52. AWS Gaming Solutions Add some de-coupling
  53. 53. AWS Gaming Solutions Messages and Queues ELB S3 • Simple Notification Service • HTTP • SMS • Mobile Push EC2EC2EC2 Region
  54. 54. 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
  55. 55. 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
  56. 56. AWS Gaming Solutions Now over to Tara!!
  57. 57. 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)
  58. 58. AWS Gaming Solutions Introducing the AWS SDK for Unity
  59. 59. 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
  60. 60. 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
  61. 61. AWS Gaming Solutions Grumpy Flappy AWS Mobile SDK: Services Setup
  62. 62. 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
  63. 63. AWS Gaming Solutions Grumpy Flappy Demo Amazon Cognito: Unity3D Code
  64. 64. 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 Client AmazonDynamoDBClient client = new AmazonDynamoDBClient(RegionEndpoint.USEast1)
  65. 65. 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; }
  66. 66. 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 Manager AmazonS3Client S3Client = new AmazonS3Client (credentials ,RegionEndpoint.USEast1);
  67. 67. 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 Object Stream 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);
  68. 68. 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/Welcom e.html
  69. 69. 69 Fill out feedback survey and win: http://bit.ly/amazongdc4

×