SlideShare a Scribd company logo
© 2015, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
John Chang 張書源
Technology Evangelist, AWS
November 2016
在雲端開發架構支援大規模流量的
行動/網頁應用程式
What do we expect from modern applications?
Modern Applications Expectations
• What do we expect from applications?
• Highly Availability
• Scalability
• Predictable Responsiveness
• Fault Tolerance
• How can we achieve this?
• Multiple datacenter facilities
• Auto-Scalable databases
• Auto-Scalable server infrastructure
• Load-Balancing
• etc.
在雲端開發架構支援大規模流量的行動/網頁應用程式
AWS Global Infrastructure
14 AWS Regions
• North America (5)
• Europe (2)
• Asia Pacific (6)
• South America (1)
Each Region has at least 2 Availability Zones
• 38 Availability Zones (AZs)
63 AWS Edge Locations
• North America (24)
• Europe (18)
• Asia Pacific (18)
• South America (3)
Availability
Zone A
Availability
Zone B
Availability
Zone C
Web Services
Core	Services Compute Storage Database Networking
Infrastructure RegionsAvailability	Zones Edge	Locations
Platform	
Services
Analytics App Deployment Mobile
Virtual	
Desktops
Collaboration	
&	Sharing
App	Delivery E-Mail
Access	
Control
Auditing Monitoring EncryptionSecurity
Applications
A
P
I
&
S
D
K
s
Web Services
Core	Services Compute Storage Database Networking
Infrastructure RegionsAvailability	Zones Edge	Locations
Platform	
Services
Analytics App Deployment Mobile
Virtual	
Desktops
Collaboration	
&	Sharing
App	Delivery E-Mail
Access	
Control
Auditing Monitoring EncryptionSecurity
Applications
A
P
I
&
S
D
K
s
SDKs
Java Python (boto) PHP .NET Ruby Node.js
iOS Android AWS Toolkit for
Visual Studio
AWS Toolkit
for Eclipse
AWS Tools for
Windows
PowerShell
AWS CLI
JavaScript
Let’s start with a Web App!
Components of a Web App
• Three tier architecture:
• Web Server
• App Server
• Database
• Components
• Application Compute
• Database Engine
• Storage & Delivery
Components of a Web App
• Three tier architecture:
• Web Server
• App Server
• Database
• Components
• Application Compute
• Database Engine
• Storage & Delivery
AWS Elastic Beanstalk
• Easily deploy, monitor, and scale web
applications
• Infrastructure provisioned and managed
by EB – you maintain complete control.
• Preconfigured application containers
that are easily customizable.
AWS Elastic Beanstalk Environment
• Two types:
• Single instance
• Load balanced, auto scalable
• Two tiers
• Web Server
• Worker
• Configures Amazon Route 53
and provides a domain name
https://yourapp.elasticbeanstalk.com
AWS Elastic Beanstalk Instance Configuration
Your code
HTTP server
Application server
Language interpreter
Operating system
Host
• Each EC2 instance
comes with the
necessary components
to run applications
• No more worrying about
logging into instances to
install and configure your
app stack
Focus on building your app
Application Versioning
Saved Configurations
Allow for easy duplication for
A/B testing or non-disruptive
deployments
Application Versions
All versions are stored
durably in Amazon S3.
Code can also be pushed
from a Git repository!
Deployment Options
1. Via the AWS Management Console
2. Via Git / EB CLI
3. Via the AWS Toolkit for Eclipse and
the Visual Studio IDE
$ git aws.push
~11.6s
Mean time between
deployments
(weekday)
~1,079
Max number of
deployments in a
single hour
~10,000
Mean number of
hosts
simultaneously
receiving a
deployment
~30,000
Max number of
hosts
simultaneously
receiving a
deployment
DEPLOYMENTS AT
AMAZON.COM
Components of a Web App
• Three tier architecture:
• Web Server
• App Server
• Database
• Components
• Application Compute
• Database Engine
• Storage & Delivery
Amazon RDS
Amazon RDS
• Fully managed relational database
• Automated full daily backups and 5 min
incremental point in time recovery
• Highly available through Multi-AZ with
automatic failover to standby database
• Easily create cross-region read replicas
• Managed underlying storage layer with
configurable IOPS performance
Aurora
Components of a Web App
• Three tier architecture:
• Web Server
• App Server
• Database
• Components
• Application Compute
• Database Engine
• Storage & Delivery
Amazon S3 (Simple Storage Service)
• Scalable & fully managed object storage
• Virtually unlimited storage capacity
• Pay only for what you use
• Trillions of unique customer objects
• Millions of transactions per second
• Designed for 99.999999999% durability Amazon S3
Amazon S3 – Buckets and Objects
• Stored in Buckets
• Allows Versioning
• Access control lists and bucket policies
• AES-256 bit encryption at rest
• Addressable via HTTP(S) endpoint
• Ideal for static assets like images,
videos, application data, backups and
more
Amazon S3 – Static Content Website
• S3 becomes your static webserver
• Amazon S3 is fully managed and
scales to millions of requests
• Offload static content to S3 and
run dynamic content on EC2
Case Study - Sony DADC New Media Solutions
“ We have 20 petabytes of content on AWS, the equivalent
of more than 800,000 hours of video, available on our
platform. We can only move all that content around the
world with the scalability we’re getting on the AWS Cloud. “
-- Andy Shenkler, Chief Solutions and Technology Officer
Amazon CloudFront
• CDN powered by 53 edge locations
across the world
• Caches content on edge locations for
low latency
• Allows Geo Targeting and Device
Detection
• Can route to different origins based
on path patterns (e.g. *.jpg à S3)
Amazon CloudFront
Amazon S3Amazon
CloudFront
Browser
Static Website Hosting on S3 & CloudFront
OK, how about a Mobile App?
Authenticate & Sync
Authorize access
Analyze User Behavior
Store Content
Test across Devices
Deliver Content
Store Data
Record Real-Time EventsRun Business Logic
Send Push Notifications
Manage users and identity providers
and sync prefs across devices
Securely access
cloud resources
Test across multiple devices
and operating systems
Track active users,
engagement
Run stateless custom
code without servers
Store user-generated content
and share it
Deliver content quickly globally
Bring users back to your app by sending
messages reliably
Store and query fast NoSQL data
across users and devices
Collect real-time event logs
and take actions quickly
Amazon Mobile
Analytics
Amazon Device Farm
AWS IAM
Amazon Cognito Amazon S3
Amazon CloudFront
Amazon DynamoDB
Amazon Lambda
Amazon SNS
Mobile Push
AWS Mobile SDK
Amazon Kinesis
Authenticate & Sync
Authorize access
Analyze User Behavior
Store Content
Test across Devices
Deliver Content
Store Data
Record Real-Time EventsRun Business Logic
Send Push Notifications
AWS Mobile SDK
• SDKs for iOS and Android
• Connectors to AWS Services
• SDK for Unity
• Cross Platform Game
Development environment
• SDK for Xamarin
• Cross-Platform App
Development Framework for C#
iOS Android
Amazon Mobile
Analytics
Amazon Device Farm
AWS IAM
Amazon Cognito Amazon S3
Amazon CloudFront
Amazon DynamoDB
Amazon Lambda
Amazon SNS
Mobile Push
AWS Mobile SDK
Amazon Kinesis
Authenticate & Sync
Authorize access
Analyze User Behavior
Store Content
Test across
Devices
Deliver Content
Store Data
Record Real-Time EventsRun Business Logic
Send Push Notifications
• Authenticates your users
• Facebook, Google,
Amazon,Twitter, OpenID
• Anonymous
• Manages the users and
synchronize data across
multiple devices
• Allows secure communication
with other AWS services
Amazon Cognito
Amazon
Cognito
Synchronize data across devices with Cognito
Sync Game State
Across OS/devices
State Transition
(link multiple accounts)
Sync User Profiles
across OS/devices/web
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
Architecture Amazon Cognito Authentication
Amazon Mobile
Analytics
Amazon Device Farm
AWS IAM
Amazon Cognito Amazon S3
Amazon CloudFront
Amazon DynamoDB
Amazon Lambda
Amazon SNS
Mobile Push
AWS Mobile SDK
Amazon Kinesis
Authenticate & Sync
Authorize access
Analyze User Behavior
Store Content
Test across
Devices
Deliver Content
Store Data
Record Real-Time EventsRun Business Logic
Send Push Notifications
Enables you to control access to your AWS resources
• Create users, groups or roles
• Fine grained control access control through IAM policies
• Control who can do what in your AWS environments
• Permit resource access with social identities or public
• Easily add multi factor authentication using hardware
tokens or smartphone apps
Identity and Access Management (IAM)
{
"Effect":"Allow",
"Action":["s3:*"],
"Resource":"*"
}
{
"Effect": "Allow",
"Action": ["cognito-sync:*"],
"Resource": "*"
}
{
"Effect": "Deny",
"Action": ["dynamodb:*"],
"Resource": "*"
}
Allow
Actions:
All S3
Sync store Operations
Resource:
All resources within
these services
Deny
Actions:
All DDB Operations
Resource:
All resources
Access Policy for IAM Role
Allow
Actions:
S3 Get/Put operations
Resource:
Only to a specific part
of bucket to that identity
{
"Effect": "Allow”,
"Action": ["s3:GetObject","s3:PutObject"],
"Resource": ["arn:aws:s3:::
myBucket/amazon/myapp/${cognito-identity.amazonaws.com:sub}"]
}
Allow
Actions:
DDB Get/Put operations
Resource:
Only to a specific cells in
the database
{
"Effect": "Allow”,
"Action": ["dynamodb:GetItem", "dynamodb:PutItem"],
"Resource" : [ "arn:aws:dynamodb:REGION:12345:table/TABLE_NAME”],
"Condition": {
"ForAllValues:StringEquals”:{
"dynamodb:LeadingKeys": ["${cognito-identity.amazonaws.com:sub}"],
"dynamodb:Attributes”: ["Wins","Losses”,"TopScore",”DateTime" ]
},
}
Access Policy Restriction (Policy Variables)
Amazon Mobile
Analytics
Amazon Device Farm
AWS IAM
Amazon Cognito Amazon S3
Amazon CloudFront
Amazon DynamoDB
Amazon Lambda
Amazon SNS
Mobile Push
AWS Mobile SDK
Amazon Kinesis
Authenticate & Sync
Authorize access
Analyze User Behavior
Store Content
Test across Devices
Deliver Content
Store Data
Record Real-Time EventsRun Business Logic
Send Push Notifications
AWS Device Farm
• Test your app on real devices in the
AWS cloud
• Fully managed and scalable test
platform
• Many different smartphone and tablet
models available
• Full built-in test suite
• Integration with custom frameworks
(e.g. Appium, Calabash etc.)
AWS Device
Farm
在雲端開發架構支援大規模流量的行動/網頁應用程式
Amazon Mobile
Analytics
Amazon Device Farm
AWS IAM
Amazon Cognito Amazon S3
Amazon CloudFront
Amazon DynamoDB
Amazon Lambda
Amazon SNS
Mobile Push
AWS Mobile SDK
Amazon Kinesis
Authenticate & Sync
Authorize access
Analyze User Behavior
Store Content
Test across Devices
Deliver Content
Store Data
Record Real-Time EventsRun Business Logic
Send Push Notifications
Amazon Mobile Analytics
• Allows to collect, visualize and
understand your mobile app
usage
• Scales seamlessly to billions of
events per day
• You retain full control and
ownership of the data
Amazon Mobile
Analytics
在雲端開發架構支援大規模流量的行動/網頁應用程式
Get insights into app
specific actions that
your users take
Examples
Track the number of
Likes/Shares in a
news app
Player abort rates
per level in a game
Number of songs
playedin a music app
In-app purchase item
popularity
Custom Events
Initialize Mobile Analytics
// Within your activity
private static MobileAnalyticsManager analytics;
// Within your activity onCreate()
try {
AnalyticsConfig options = new AnalyticsConfig();
options.withAllowsWANDelivery(true);
analytics = MobileAnalyticsManager.getOrCreateInstance(
getApplicationContext(),
"YOU MOBILE ANALYTICS APP ID",
Regions.US_EAST_1,
cognitoProvider, // You need a Cognito credential provider
options
);
} catch(InitializationException ex) {
Log.e(this.getClass().getName(), "Failed to initialize Amazon Mobile Analytics", ex);
}
Export to S3, Process Data Anywhere
Mobile
Client
Amazon
S3
Amazon
Redshift
Amazon Mobile
Analytics
Hadoop/Spark
Amazon EMR
Amazon
Glacier
Archive
Batch
在雲端開發架構支援大規模流量的行動/網頁應用程式
Mobile Analytics Schema Overview
Simple Schema
Automatically Collect
Common Attributes
User Extended
Attributes and Metrics
Integrate with Existing
Data Models
event_timestamp arrival_timestamp
event_type app_id
app_title cognito_id
client_id platform
platform_version locale
app_package_name app_version_name
device model device make
monetization_amount monetization_item
a_level
a_promo_code
m_score
m_quantity
StandardFieldsCustomDefined
Fields
attributes
(string)
metrics
(float)
User Retention: Bubble Island
User Retention: Bubble Island
Daily active users
(DAU) dropped,
but why?
Example: Level Progression (One Metric)
0
2
4
6
8
10
L1 L2 L3 L4 L5 L6 L7 L8 L9 L10
Tries / Level
# of Tries
Example: Level Progression (Two Metrics)
0
10
20
30
40
50
60
0
2
4
6
8
10
L1 L2 L3 L4 L5 L6 L7 L8 L9 L10
Tries / Level
% Highest Level # of Tries
User Retention: Bubble Island
Amazon Mobile
Analytics
Amazon Device Farm
AWS IAM
Amazon Cognito Amazon S3
Amazon CloudFront
Amazon DynamoDB
Amazon Lambda
Amazon SNS
Mobile Push
AWS Mobile SDK
Amazon Kinesis
Authenticate & Sync
Authorize access
Analyze User Behavior
Store Content
Test across Devices
Deliver Content
Store Data
Record Real-Time EventsRun Business Logic
Send Push Notifications
AWS Lambda
Auto Scaling
Focus on business
logic, not
infrastructure.
Zero Administration
Lambda scales
the infrastructure
to match the
event rate
Your Own Code
“Run your code in the cloud in response to events and scale without any
servers to manage”
Write your code in
JavaScript or Java
AWS Lambda
• Stateless code called Lambda functions
• Invoke Lambda functions straight from your
mobile app
• Trigger functions by events (state
transitions) in other services:
• New file in your object storage
• New item in your NoSQL database
• New message in your notification service
Amazon
Lambda
Adding a Lambda Backend to your App
Initialize the LambdaFactory and define the Interface for the functions
Call synchronize on the dataset
Create the Lambda Function
lambda = new LambdaInvokerFactory(context, Regions.US_WEST_2, provider);
//interface
@LambdaFunction(functionName="cloudFunction”)
String localFunction(String nameInfo);
lambda.localFunction(“Hello From “); // this will output “Hello From Lambda”
exports.handler = function(event, context) {
context.done(null, event + 'Lambda'); // SUCCESS with message
};
Amazon Mobile
Analytics
Amazon Device Farm
AWS IAM
Amazon Cognito Amazon S3
Amazon CloudFront
Amazon DynamoDB
Amazon Lambda
Amazon SNS
Mobile Push
AWS Mobile SDK
Amazon Kinesis
Authenticate & Sync
Authorize access
Analyze User Behavior
Store Content
Test across Devices
Deliver Content
Store Data
Record Real-Time EventsRun Business Logic
Send Push Notifications
Amazon S3 & Amazon CloudFront
• Amazon S3
• Highly available object storage
• Designed for 99.999999999% durability
• Offers HTTP / HTTPS endpoint to objects
• Amazon CloudFront
• Content Delivery Network with 63 edge
locations across the world
• Caches content on edge locations for low
latency
Amazon S3
Amazon
CloudFront
Amazon S3 ELB, EC2, Custom
OR
User requests
Edge location
(cache + network optimizations)
Origin
Get content Get content
ContentContent
Amazon CloudFront
Amazon Mobile
Analytics
Amazon Device Farm
AWS IAM
Amazon Cognito Amazon S3
Amazon CloudFront
Amazon DynamoDB
Amazon Lambda
Amazon SNS
Mobile Push
AWS Mobile SDK
Amazon Kinesis
Authenticate & Sync
Authorize access
Analyze User Behavior
Store Content
Test across Devices
Deliver Content
Store Data
Record Real-Time EventsRun Business Logic
Send Push Notifications
Amazon SNS Mobile Push Notifications
• Amazon SNS is a fully
managed, cross-platform
mobile push intermediary
service
• Fully scalable to millions
of devices
• Allows to create topics
(e.g. per geo, interest,
usage pattern etc.)
Amazon SNS
Apple APNS
Google GCM
Amazon ADM
Windows WNS and
MPNS
Baidu CP
Android Phones and Tablets
Apple iPhones and iPads
Kindle Fire Devices
Android Phones and Tablets in China
iOS
Windows Phone Devices
Amazon
SNS
Amazon SNS: Direct or Broadcast
Publish
Publish
Publish
Publish
Direct Publishing Broadcast with SNS Topics
Grouping users by SNS Topic
Geography Activity Product
TW – Taipei Daily Actives Flapping Bird Rio
Interest Tier Segment
Vampires Premium Top 100 Players
Amazon SNS
Mobile Apps
Apple APNS
Google GCM
Amazon ADM
Amazon SNS Mobile Push Notifications: Scale
Amazon Mobile
Analytics
Amazon Device Farm
AWS IAM
Amazon Cognito Amazon S3
Amazon CloudFront
Amazon DynamoDB
Amazon Lambda
Amazon SNS
Mobile Push
AWS Mobile SDK
Amazon Kinesis
Authenticate & Sync
Authorize access
Analyze User Behavior
Store Content
Test across Devices
Deliver Content
Store Data
Record Real-Time EventsRun Business Logic
Send Push Notifications
Amazon DynamoDB
Non-Relational Managed NoSQL Database Service
• Schemaless Data Model
• Consistent low latency performance
• Predictable provisioned throughput
• Seamless Scalability
• No storage limits
• High durability and availability
• Replicated across 3 facilities
• Fully Managed and Low Cost
DynamoDBtable
items
attributes
Geo Library for DynamoDB
在雲端開發架構支援大規模流量的行動/網頁應用程式
500,000 writes / second to Amazon
DynamoDB
200 additional servers during Superbowl
0 additional servers right after
Amazon Mobile
Analytics
Amazon Device Farm
AWS IAM
Amazon Cognito Amazon S3
Amazon CloudFront
Amazon DynamoDB
Amazon Lambda
Amazon SNS
Mobile Push
AWS Mobile SDK
Amazon Kinesis
Authenticate & Sync
Authorize access
Analyze User Behavior
Store Content
Test across Devices
Deliver Content
Store Data
Record Real-Time EventsRun Business Logic
Send Push Notifications
Stream in Real Time: Amazon Kinesis
• Real-Time Data Processing over
large distributed streams
• Elastic capacity that scales to
millions of events per second
• React In real-time upon incoming
stream events
• Reliable stream storage replicated
across 3 facilities
Amazon Kinesis
Kinesis
for Real-
Time
Process and Notify in AWS Lambda
exports.handler = function(event, context) {
event.Records.forEach(function(record) {
payload = new Buffer(record.kinesis.data, 'base64').toString('ascii');
UserEvent event = new UserEvent(payload);
if (event.position == TREASURE_BONUS_COORD) {
var message = ’You found the special treasure!';
sns.sendMessage(endpointArn, message);
}
});
context.succeed();
};
What if I don’t want to integrate the SDK into my app?
Amazon API Gateway
• Fully managed and scalable RESTful
API Gateway Service
• Powered through our content delivery
network via 53 global edge locations
• Backend protection through DDoS
prevention mechanisms and Throttling
capabilities
• Provides cached API responses
• Managed authentication mechanisms
Amazon API
Gateway
Amazon API Gateway
• Offers all common RESTful
methods (GET, PUT, POST etc.)
• Multiple API stages which you
define (e.g. dev, test, prod)
• Deploy seamlessly between
stages
• AWS Lambda, Amazon’s
Service APIs or your own API as
backend for the executable code
Amazon
Lambda
Amazon API
Gateway
Amazon
EC2
AWS API
On-Prem
Server
API Call Flow
Internet
Mobile apps
Websites
Services
AWS Lambda
functions
API Gateway
Cache
Endpoints on
Amazon
EC2/AWS
Elastic
Beanstalk
Any other publicly
accessible endpoint
Amazon
CloudWatch
monitoring
Amazon API
Gateway
Thank you!

More Related Content

在雲端開發架構支援大規模流量的行動/網頁應用程式

  • 1. © 2015, Amazon Web Services, Inc. or its Affiliates. All rights reserved. John Chang 張書源 Technology Evangelist, AWS November 2016 在雲端開發架構支援大規模流量的 行動/網頁應用程式
  • 2. What do we expect from modern applications?
  • 3. Modern Applications Expectations • What do we expect from applications? • Highly Availability • Scalability • Predictable Responsiveness • Fault Tolerance • How can we achieve this? • Multiple datacenter facilities • Auto-Scalable databases • Auto-Scalable server infrastructure • Load-Balancing • etc.
  • 5. AWS Global Infrastructure 14 AWS Regions • North America (5) • Europe (2) • Asia Pacific (6) • South America (1) Each Region has at least 2 Availability Zones • 38 Availability Zones (AZs) 63 AWS Edge Locations • North America (24) • Europe (18) • Asia Pacific (18) • South America (3) Availability Zone A Availability Zone B Availability Zone C
  • 6. Web Services Core Services Compute Storage Database Networking Infrastructure RegionsAvailability Zones Edge Locations Platform Services Analytics App Deployment Mobile Virtual Desktops Collaboration & Sharing App Delivery E-Mail Access Control Auditing Monitoring EncryptionSecurity Applications A P I & S D K s
  • 7. Web Services Core Services Compute Storage Database Networking Infrastructure RegionsAvailability Zones Edge Locations Platform Services Analytics App Deployment Mobile Virtual Desktops Collaboration & Sharing App Delivery E-Mail Access Control Auditing Monitoring EncryptionSecurity Applications A P I & S D K s
  • 8. SDKs Java Python (boto) PHP .NET Ruby Node.js iOS Android AWS Toolkit for Visual Studio AWS Toolkit for Eclipse AWS Tools for Windows PowerShell AWS CLI JavaScript
  • 9. Let’s start with a Web App!
  • 10. Components of a Web App • Three tier architecture: • Web Server • App Server • Database • Components • Application Compute • Database Engine • Storage & Delivery
  • 11. Components of a Web App • Three tier architecture: • Web Server • App Server • Database • Components • Application Compute • Database Engine • Storage & Delivery
  • 12. AWS Elastic Beanstalk • Easily deploy, monitor, and scale web applications • Infrastructure provisioned and managed by EB – you maintain complete control. • Preconfigured application containers that are easily customizable.
  • 13. AWS Elastic Beanstalk Environment • Two types: • Single instance • Load balanced, auto scalable • Two tiers • Web Server • Worker • Configures Amazon Route 53 and provides a domain name https://yourapp.elasticbeanstalk.com
  • 14. AWS Elastic Beanstalk Instance Configuration Your code HTTP server Application server Language interpreter Operating system Host • Each EC2 instance comes with the necessary components to run applications • No more worrying about logging into instances to install and configure your app stack Focus on building your app
  • 15. Application Versioning Saved Configurations Allow for easy duplication for A/B testing or non-disruptive deployments Application Versions All versions are stored durably in Amazon S3. Code can also be pushed from a Git repository!
  • 16. Deployment Options 1. Via the AWS Management Console 2. Via Git / EB CLI 3. Via the AWS Toolkit for Eclipse and the Visual Studio IDE $ git aws.push
  • 17. ~11.6s Mean time between deployments (weekday) ~1,079 Max number of deployments in a single hour ~10,000 Mean number of hosts simultaneously receiving a deployment ~30,000 Max number of hosts simultaneously receiving a deployment DEPLOYMENTS AT AMAZON.COM
  • 18. Components of a Web App • Three tier architecture: • Web Server • App Server • Database • Components • Application Compute • Database Engine • Storage & Delivery
  • 19. Amazon RDS Amazon RDS • Fully managed relational database • Automated full daily backups and 5 min incremental point in time recovery • Highly available through Multi-AZ with automatic failover to standby database • Easily create cross-region read replicas • Managed underlying storage layer with configurable IOPS performance Aurora
  • 20. Components of a Web App • Three tier architecture: • Web Server • App Server • Database • Components • Application Compute • Database Engine • Storage & Delivery
  • 21. Amazon S3 (Simple Storage Service) • Scalable & fully managed object storage • Virtually unlimited storage capacity • Pay only for what you use • Trillions of unique customer objects • Millions of transactions per second • Designed for 99.999999999% durability Amazon S3
  • 22. Amazon S3 – Buckets and Objects • Stored in Buckets • Allows Versioning • Access control lists and bucket policies • AES-256 bit encryption at rest • Addressable via HTTP(S) endpoint • Ideal for static assets like images, videos, application data, backups and more
  • 23. Amazon S3 – Static Content Website • S3 becomes your static webserver • Amazon S3 is fully managed and scales to millions of requests • Offload static content to S3 and run dynamic content on EC2
  • 24. Case Study - Sony DADC New Media Solutions “ We have 20 petabytes of content on AWS, the equivalent of more than 800,000 hours of video, available on our platform. We can only move all that content around the world with the scalability we’re getting on the AWS Cloud. “ -- Andy Shenkler, Chief Solutions and Technology Officer
  • 25. Amazon CloudFront • CDN powered by 53 edge locations across the world • Caches content on edge locations for low latency • Allows Geo Targeting and Device Detection • Can route to different origins based on path patterns (e.g. *.jpg à S3) Amazon CloudFront
  • 27. OK, how about a Mobile App?
  • 28. Authenticate & Sync Authorize access Analyze User Behavior Store Content Test across Devices Deliver Content Store Data Record Real-Time EventsRun Business Logic Send Push Notifications Manage users and identity providers and sync prefs across devices Securely access cloud resources Test across multiple devices and operating systems Track active users, engagement Run stateless custom code without servers Store user-generated content and share it Deliver content quickly globally Bring users back to your app by sending messages reliably Store and query fast NoSQL data across users and devices Collect real-time event logs and take actions quickly
  • 29. Amazon Mobile Analytics Amazon Device Farm AWS IAM Amazon Cognito Amazon S3 Amazon CloudFront Amazon DynamoDB Amazon Lambda Amazon SNS Mobile Push AWS Mobile SDK Amazon Kinesis Authenticate & Sync Authorize access Analyze User Behavior Store Content Test across Devices Deliver Content Store Data Record Real-Time EventsRun Business Logic Send Push Notifications
  • 30. AWS Mobile SDK • SDKs for iOS and Android • Connectors to AWS Services • SDK for Unity • Cross Platform Game Development environment • SDK for Xamarin • Cross-Platform App Development Framework for C# iOS Android
  • 31. Amazon Mobile Analytics Amazon Device Farm AWS IAM Amazon Cognito Amazon S3 Amazon CloudFront Amazon DynamoDB Amazon Lambda Amazon SNS Mobile Push AWS Mobile SDK Amazon Kinesis Authenticate & Sync Authorize access Analyze User Behavior Store Content Test across Devices Deliver Content Store Data Record Real-Time EventsRun Business Logic Send Push Notifications
  • 32. • Authenticates your users • Facebook, Google, Amazon,Twitter, OpenID • Anonymous • Manages the users and synchronize data across multiple devices • Allows secure communication with other AWS services Amazon Cognito Amazon Cognito
  • 33. Synchronize data across devices with Cognito Sync Game State Across OS/devices State Transition (link multiple accounts) Sync User Profiles across OS/devices/web
  • 34. 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 Architecture Amazon Cognito Authentication
  • 35. Amazon Mobile Analytics Amazon Device Farm AWS IAM Amazon Cognito Amazon S3 Amazon CloudFront Amazon DynamoDB Amazon Lambda Amazon SNS Mobile Push AWS Mobile SDK Amazon Kinesis Authenticate & Sync Authorize access Analyze User Behavior Store Content Test across Devices Deliver Content Store Data Record Real-Time EventsRun Business Logic Send Push Notifications
  • 36. Enables you to control access to your AWS resources • Create users, groups or roles • Fine grained control access control through IAM policies • Control who can do what in your AWS environments • Permit resource access with social identities or public • Easily add multi factor authentication using hardware tokens or smartphone apps Identity and Access Management (IAM)
  • 37. { "Effect":"Allow", "Action":["s3:*"], "Resource":"*" } { "Effect": "Allow", "Action": ["cognito-sync:*"], "Resource": "*" } { "Effect": "Deny", "Action": ["dynamodb:*"], "Resource": "*" } Allow Actions: All S3 Sync store Operations Resource: All resources within these services Deny Actions: All DDB Operations Resource: All resources Access Policy for IAM Role
  • 38. Allow Actions: S3 Get/Put operations Resource: Only to a specific part of bucket to that identity { "Effect": "Allow”, "Action": ["s3:GetObject","s3:PutObject"], "Resource": ["arn:aws:s3::: myBucket/amazon/myapp/${cognito-identity.amazonaws.com:sub}"] } Allow Actions: DDB Get/Put operations Resource: Only to a specific cells in the database { "Effect": "Allow”, "Action": ["dynamodb:GetItem", "dynamodb:PutItem"], "Resource" : [ "arn:aws:dynamodb:REGION:12345:table/TABLE_NAME”], "Condition": { "ForAllValues:StringEquals”:{ "dynamodb:LeadingKeys": ["${cognito-identity.amazonaws.com:sub}"], "dynamodb:Attributes”: ["Wins","Losses”,"TopScore",”DateTime" ] }, } Access Policy Restriction (Policy Variables)
  • 39. Amazon Mobile Analytics Amazon Device Farm AWS IAM Amazon Cognito Amazon S3 Amazon CloudFront Amazon DynamoDB Amazon Lambda Amazon SNS Mobile Push AWS Mobile SDK Amazon Kinesis Authenticate & Sync Authorize access Analyze User Behavior Store Content Test across Devices Deliver Content Store Data Record Real-Time EventsRun Business Logic Send Push Notifications
  • 40. AWS Device Farm • Test your app on real devices in the AWS cloud • Fully managed and scalable test platform • Many different smartphone and tablet models available • Full built-in test suite • Integration with custom frameworks (e.g. Appium, Calabash etc.) AWS Device Farm
  • 42. Amazon Mobile Analytics Amazon Device Farm AWS IAM Amazon Cognito Amazon S3 Amazon CloudFront Amazon DynamoDB Amazon Lambda Amazon SNS Mobile Push AWS Mobile SDK Amazon Kinesis Authenticate & Sync Authorize access Analyze User Behavior Store Content Test across Devices Deliver Content Store Data Record Real-Time EventsRun Business Logic Send Push Notifications
  • 43. Amazon Mobile Analytics • Allows to collect, visualize and understand your mobile app usage • Scales seamlessly to billions of events per day • You retain full control and ownership of the data Amazon Mobile Analytics
  • 45. Get insights into app specific actions that your users take Examples Track the number of Likes/Shares in a news app Player abort rates per level in a game Number of songs playedin a music app In-app purchase item popularity Custom Events
  • 46. Initialize Mobile Analytics // Within your activity private static MobileAnalyticsManager analytics; // Within your activity onCreate() try { AnalyticsConfig options = new AnalyticsConfig(); options.withAllowsWANDelivery(true); analytics = MobileAnalyticsManager.getOrCreateInstance( getApplicationContext(), "YOU MOBILE ANALYTICS APP ID", Regions.US_EAST_1, cognitoProvider, // You need a Cognito credential provider options ); } catch(InitializationException ex) { Log.e(this.getClass().getName(), "Failed to initialize Amazon Mobile Analytics", ex); }
  • 47. Export to S3, Process Data Anywhere Mobile Client Amazon S3 Amazon Redshift Amazon Mobile Analytics Hadoop/Spark Amazon EMR Amazon Glacier Archive Batch
  • 49. Mobile Analytics Schema Overview Simple Schema Automatically Collect Common Attributes User Extended Attributes and Metrics Integrate with Existing Data Models event_timestamp arrival_timestamp event_type app_id app_title cognito_id client_id platform platform_version locale app_package_name app_version_name device model device make monetization_amount monetization_item a_level a_promo_code m_score m_quantity StandardFieldsCustomDefined Fields attributes (string) metrics (float)
  • 51. User Retention: Bubble Island Daily active users (DAU) dropped, but why?
  • 52. Example: Level Progression (One Metric) 0 2 4 6 8 10 L1 L2 L3 L4 L5 L6 L7 L8 L9 L10 Tries / Level # of Tries
  • 53. Example: Level Progression (Two Metrics) 0 10 20 30 40 50 60 0 2 4 6 8 10 L1 L2 L3 L4 L5 L6 L7 L8 L9 L10 Tries / Level % Highest Level # of Tries
  • 55. Amazon Mobile Analytics Amazon Device Farm AWS IAM Amazon Cognito Amazon S3 Amazon CloudFront Amazon DynamoDB Amazon Lambda Amazon SNS Mobile Push AWS Mobile SDK Amazon Kinesis Authenticate & Sync Authorize access Analyze User Behavior Store Content Test across Devices Deliver Content Store Data Record Real-Time EventsRun Business Logic Send Push Notifications
  • 56. AWS Lambda Auto Scaling Focus on business logic, not infrastructure. Zero Administration Lambda scales the infrastructure to match the event rate Your Own Code “Run your code in the cloud in response to events and scale without any servers to manage” Write your code in JavaScript or Java
  • 57. AWS Lambda • Stateless code called Lambda functions • Invoke Lambda functions straight from your mobile app • Trigger functions by events (state transitions) in other services: • New file in your object storage • New item in your NoSQL database • New message in your notification service Amazon Lambda
  • 58. Adding a Lambda Backend to your App Initialize the LambdaFactory and define the Interface for the functions Call synchronize on the dataset Create the Lambda Function lambda = new LambdaInvokerFactory(context, Regions.US_WEST_2, provider); //interface @LambdaFunction(functionName="cloudFunction”) String localFunction(String nameInfo); lambda.localFunction(“Hello From “); // this will output “Hello From Lambda” exports.handler = function(event, context) { context.done(null, event + 'Lambda'); // SUCCESS with message };
  • 59. Amazon Mobile Analytics Amazon Device Farm AWS IAM Amazon Cognito Amazon S3 Amazon CloudFront Amazon DynamoDB Amazon Lambda Amazon SNS Mobile Push AWS Mobile SDK Amazon Kinesis Authenticate & Sync Authorize access Analyze User Behavior Store Content Test across Devices Deliver Content Store Data Record Real-Time EventsRun Business Logic Send Push Notifications
  • 60. Amazon S3 & Amazon CloudFront • Amazon S3 • Highly available object storage • Designed for 99.999999999% durability • Offers HTTP / HTTPS endpoint to objects • Amazon CloudFront • Content Delivery Network with 63 edge locations across the world • Caches content on edge locations for low latency Amazon S3 Amazon CloudFront
  • 61. Amazon S3 ELB, EC2, Custom OR User requests Edge location (cache + network optimizations) Origin Get content Get content ContentContent Amazon CloudFront
  • 62. Amazon Mobile Analytics Amazon Device Farm AWS IAM Amazon Cognito Amazon S3 Amazon CloudFront Amazon DynamoDB Amazon Lambda Amazon SNS Mobile Push AWS Mobile SDK Amazon Kinesis Authenticate & Sync Authorize access Analyze User Behavior Store Content Test across Devices Deliver Content Store Data Record Real-Time EventsRun Business Logic Send Push Notifications
  • 63. Amazon SNS Mobile Push Notifications • Amazon SNS is a fully managed, cross-platform mobile push intermediary service • Fully scalable to millions of devices • Allows to create topics (e.g. per geo, interest, usage pattern etc.) Amazon SNS Apple APNS Google GCM Amazon ADM Windows WNS and MPNS Baidu CP Android Phones and Tablets Apple iPhones and iPads Kindle Fire Devices Android Phones and Tablets in China iOS Windows Phone Devices Amazon SNS
  • 64. Amazon SNS: Direct or Broadcast Publish Publish Publish Publish Direct Publishing Broadcast with SNS Topics
  • 65. Grouping users by SNS Topic Geography Activity Product TW – Taipei Daily Actives Flapping Bird Rio Interest Tier Segment Vampires Premium Top 100 Players
  • 66. Amazon SNS Mobile Apps Apple APNS Google GCM Amazon ADM Amazon SNS Mobile Push Notifications: Scale
  • 67. Amazon Mobile Analytics Amazon Device Farm AWS IAM Amazon Cognito Amazon S3 Amazon CloudFront Amazon DynamoDB Amazon Lambda Amazon SNS Mobile Push AWS Mobile SDK Amazon Kinesis Authenticate & Sync Authorize access Analyze User Behavior Store Content Test across Devices Deliver Content Store Data Record Real-Time EventsRun Business Logic Send Push Notifications
  • 68. Amazon DynamoDB Non-Relational Managed NoSQL Database Service • Schemaless Data Model • Consistent low latency performance • Predictable provisioned throughput • Seamless Scalability • No storage limits • High durability and availability • Replicated across 3 facilities • Fully Managed and Low Cost DynamoDBtable items attributes
  • 69. Geo Library for DynamoDB
  • 71. 500,000 writes / second to Amazon DynamoDB 200 additional servers during Superbowl 0 additional servers right after
  • 72. Amazon Mobile Analytics Amazon Device Farm AWS IAM Amazon Cognito Amazon S3 Amazon CloudFront Amazon DynamoDB Amazon Lambda Amazon SNS Mobile Push AWS Mobile SDK Amazon Kinesis Authenticate & Sync Authorize access Analyze User Behavior Store Content Test across Devices Deliver Content Store Data Record Real-Time EventsRun Business Logic Send Push Notifications
  • 73. Stream in Real Time: Amazon Kinesis • Real-Time Data Processing over large distributed streams • Elastic capacity that scales to millions of events per second • React In real-time upon incoming stream events • Reliable stream storage replicated across 3 facilities Amazon Kinesis
  • 75. Process and Notify in AWS Lambda exports.handler = function(event, context) { event.Records.forEach(function(record) { payload = new Buffer(record.kinesis.data, 'base64').toString('ascii'); UserEvent event = new UserEvent(payload); if (event.position == TREASURE_BONUS_COORD) { var message = ’You found the special treasure!'; sns.sendMessage(endpointArn, message); } }); context.succeed(); };
  • 76. What if I don’t want to integrate the SDK into my app?
  • 77. Amazon API Gateway • Fully managed and scalable RESTful API Gateway Service • Powered through our content delivery network via 53 global edge locations • Backend protection through DDoS prevention mechanisms and Throttling capabilities • Provides cached API responses • Managed authentication mechanisms Amazon API Gateway
  • 78. Amazon API Gateway • Offers all common RESTful methods (GET, PUT, POST etc.) • Multiple API stages which you define (e.g. dev, test, prod) • Deploy seamlessly between stages • AWS Lambda, Amazon’s Service APIs or your own API as backend for the executable code Amazon Lambda Amazon API Gateway Amazon EC2 AWS API On-Prem Server
  • 79. API Call Flow Internet Mobile apps Websites Services AWS Lambda functions API Gateway Cache Endpoints on Amazon EC2/AWS Elastic Beanstalk Any other publicly accessible endpoint Amazon CloudWatch monitoring Amazon API Gateway