For eCommerce customers, to build a scalable platform to support their daily business is very important. In this session, we will discuss how to use AWS features to build low-cost and highly scalable web and mobile application on the cloud
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.
4.
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
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
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)
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
41.
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
44.
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
48.
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)
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
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
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