SlideShare uma empresa Scribd logo
1 de 74
Baixar para ler offline
Speed and Reliability at Any Scale –
Combining SQS and DB Services
Jonathan Desrocher, Amazon Web Services
Colin Vipurs, Shazam Entertainment Ltd.
November 14, 2013

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified, or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWS Messaging = Amazon SQS + Amazon SNS
Amazon SQS Core Features

•
•

New and improved

Payload size of up to 256KB
Message batching for higher throughput and reduced costs

•

Supports long polling for reduced costs and latency

•

Cross-origin resource sharing support
SQS Core mechanics
Basic Message Lifecycle

Writer
Basic Message Lifecycle

Writer
Basic Message Lifecycle

Writer
Basic Message Lifecycle

Reader A

Reader B
Basic Message Lifecycle

Reader A

Reader B

ReceiveMessage

A

B
Basic Message Lifecycle

Reader A

Reader B

A

B
Basic Message Lifecycle

B

Reader B
Basic Message Lifecycle

Reader B
Basic Message Lifecycle

B

Reader B
Basic Message Lifecycle

Reader B
Basic Message Lifecycle

Reader B
That covers reliability.
Now let’s go for the scale!
Bulk Transactional Reads

Reader A
Bulk Transactional Reads

A

RAM: 10 Msgs

ReceiveMessage

A

A

A

A

Reader A

A
A

A

A

A
Bulk Transactional Reads

A

ReceiveMessage

A

A

A

A

Reader A

A
A

A

A

A

A

A

A

A

A

A

A

A

A

A

RAM: 20 Msgs
Bulk Transactional Reads

A

ReceiveMessage

A

A

A

A

Reader A

A
A

A

A

A

A

A

A

A

A

A

A

A

A

A

A

A

A

A

A

A

A

A

A

A

RAM: 30 Msgs
Bulk Transactional Reads

Reader A

DeleteMessage
Bulk Transactional Reads

Reader A
Let’s take it to real life!
Scalability example: market trade volume by half hour
350,000
300,000
250,000
200,000
150,000

100,000
50,000
0
Scalability example: market trade volume by half hour
350,000
300,000
250,000
200,000

85%

150,000

100,000
50,000
0

15%
Design pattern #1:
Batch processing
Batch Processing
• Use SQS as a scalable and resilient short-term storage
solution.
• Simply configure the appropriate retention period and
send away!

SendMessage

HTTP PUT

Elastic Beanstalk Application
Batch Processing
• When appropriate, launch a fleet of Amazon EC2
workers and process the messages en masse.

ReceiveMessage
Design pattern #2:
IAM Roles for Amazon EC2
Using IAM Roles for Amazon EC2
• Create an IAM role with the
appropriate permissions to
Amazon SQS.
• Launch EC2 instances with
this role.
• Done!
– Audit logs will correlate
the EC2 instance ID to the
SQS API calls.
– IAM will automatically
rotate the credentials on
our behalf.

{

"Statement": [
{
"Sid": "Stmt1384277213171",
"Action": [
"sqs:ChangeMessageVisibility",
"sqs:DeleteMessage",
"sqs:GetQueueAttributes",
"sqs:GetQueueUrl",
"sqs:ListQueues",
"sqs:ReceiveMessage"
],
"Effect": "Allow",
"Resource": "arn:aws:sqs:us-east1:455320512810:Sensor_Ingestion"
}
]
}
Using IAM Roles for Amazon EC2
• Use the AWS SDK on the
Instance
• No need to type credentials
•
•
•

Not in code
Not in a configuration file
Not via the console either

require ‘rubygems’
require ‘aws-sdk’
sqs = AWS::SQS.new()
myqueue = sqs.queues.named("Sensor_Ingestion")
myqueue.poll do |msg|
# Do something with the message
end
Design pattern #3:
Using SQS to durably batch writes
Using SQS to durably batch writes
• The application:
–
–
–
–

An AWS Elastic Beanstalk application.
Clients upload data to the application through HTTP PUTs.
Each upload is 100KB in size.
Amazon S3 will be used as the permanent data store.

S3 PUT

HTTP PUT

Elastic Beanstalk Application

S3
Bucket
Using SQS to durably batch writes
• The challenge:
– We have an external constraint that requires us to batch the upload into
Amazon S3.
For example:
• Amazon EMR best practices call for Amazon S3 object size of >10MB.
• Hourly Amazon Redshift batch inserts.

EMR Cluster

S3 PUT

HTTP PUT

Elastic Beanstalk Application

S3
Bucket

Redshift Database
Using SQS to durably batch writes
• Enter SQS:
– Persist individual client PUTs as SQS messages.
– Have an Amazon EC2 worker role that performs the following logic:
• Receive SQS message and add to an in-memory buffer.
• Once buffer is full, upload to Amazon S3.
• Upon acknowledgement from S3, delete SQS messages from queue.

SendMessage

HTTP PUT

Elastic Beanstalk Application

ReceiveMessage

EMR
Cluster

S3 PUT

S3
Bucket

Redshift
Database
Using SQS to durably batch writes
• Also to consider:
– Some data stores are optimized for read workloads
– Buffering the writes with Simple Queue Service will ensure both speed
and reliability of data ingestion.

SendMessage

HTTP PUT

Elastic Beanstalk Application

ReceiveMessage

BatchWriteItem

RDS Database
Design pattern #4:
Discarding stale messages
Discarding stale messages
• Controlled via the MessageRetentionPeriod property.
• Useful when there is no business value for data older
than X minutes.
– “Transactions that don’t complete within 5 minutes are abandoned, enabling
client-side failure handling”.

SendMessage

HTTP PUT

Elastic Beanstalk Application

ReceiveMessage

[Stale Messages]

EMR
Cluster

S3 PUT

S3
Bucket

Redshift
Database
Design pattern #5:
Simple Notification Service Fan-out
Simple Notification Service Fan-out
•

Atomically distribute a message to
multiple subscribers over different
transport methods
–
–
–
–

•

SQS queues
HTTP/S endpoints
SMS
Email

Also used to abstract different mobile
device push providers (MBL308)
– Apple Push Notification Service
– Google Cloud Messaging for Android
– Amazon Device Messaging

Publish
Simple Notification Service Fan-out
• Perform different operations on the same data
– Split different facets of the payload into different systems.
– Duplicate the data into short-term and longterm storage systems.

ReceiveMessage

S3 PUT

S3
Bucket

EMR
Cluster

S3
Bucket

Redshift
Database

SNS Publish

HTTP PUT

Elastic Beanstalk Application

ReceiveMessage

S3 PUT
Simple Notification Service Fan-out
• Deliver the same data to different environments

Production
ReceiveMessage

S3 PUT

S3
Bucket

DynamoDB
Table

S3
Bucket

DynamoDB
Table

SNS Publish

HTTP PUT

Test

Elastic Beanstalk Application

ReceiveMessage

S3 PUT
Simple Notification Service Fan-out
• Distribute the same data to a multiple external environments:
– Push data to different locations worldwide.
– Seamlessly synchronize AWS and on-premises environments.
– Pro tip: MessageID field is consistent across locations.

us-east-1
eu-west-1
SNS Publish

HTTP PUT

Elastic Beanstalk Application

ap-northeast-1
On-premises Data Center
Simple Notification Service Fan-out
• Each recipient can have its own preferred transport protocol:
– SQS for guaranteed delivery
– Email for human-friendly delivery
– HTTP/S for real-time push

Partner/Process A
Partner/Process B
SNS Publish

HTTP PUT

Elastic Beanstalk Application

Partner/Process C
Partner/Process D
Design pattern #6:
Send messages from the browser
Send messages from the browser
• Make direct calls to AWS services such as SQS
and DynamoDB directly from the user’s browser.
• Authentication is based on STS tokens.
• Supports S3, SQS, SNS and DynamoDB.
Send messages from the browser
• Back to our sample architecture:
– Browser authenticates against Elastic Beanstalk application
– Response includes location of SQS Queue and STS Token for direct
authentication.

GetToken

Elastic Beanstalk Application

SendMessage

ReceiveMessage

EMR
Cluster

S3 PUT

S3
Bucket

Redshift
Database
Colin Vipurs
Shazam Entertainment Ltd.
375 MILLION
USERS

75 MILLION

MONTHLY ACTIVE USERS

10 MILLION
NEW USERS
PER MONTH
2004

2005

2006

2007

2008

2009

2010

2011

2012

2013
Amazon SQS for surge protection

SQS
shield
c3po

single event

message

update request

queue worker

user data

batch

data req.

Facebook Realtime Updates

user data

user updater

DynamoDB
Facebook Realtime Updates
Queue Worker Anatomy
operation
read msg

versioned msg

data object

target system
pollers

unmarshallers

handlers
SQS for SLAs

data
ingester
SQS for SLAs
high priority
batch
data
ingester

std priority

queue worker
low priority
SQS as DynamoDB Buffer
data
API

DynamoDb
Time

Traffic Volume
Traffic Volume

large volume
event

Time
SQS as DynamoDB Buffer
data
API

DynamoDb

throughtput exceeded

data

data
data message
queue worker
SQS as DynamoDB Buffer
data
API

client fails
fast

DynamoDb

data

queue worker

client
retries
SQS as DynamoDB Buffer

public interface Writer <T> {
void write(T t);
}
SNS/SQS Datastore Segregation
SNS/SQS Datastore Segregation
Reporting
S3
tag data
API

API
SNS/SQS Datastore Segregation
Reporting
S3
tag data
API

API

Dev Hacking
SQS for Shazam is…
•
•
•
•

Protection from the outside world
Short term, unbounded persistence
Cost effective elastic capacity
Scalable data segregation
Thank you Colin!
Design patterns recap
1.
2.
3.
4.
5.
6.

Batch processing
IAM Roles for EC2
Using SQS to durably batch writes
Discard stale messages
Simple Notification Service Fan-out
Send messages from the browser
Additional messaging resources
• Application Services Booth
• re:Invent sessions:
– ARC301 Controlling the Flood: Massive Message Processing with
AWS SQS and DynamoDB
– MBL308 Engage Your Customers with Amazon SNS Mobile Push

• AWS Support and Discussion Forums
• AWS Architecture Center:
http://aws.amazon.com/architecture
• Documentation:
http://aws.amazon.com/documentation/sqs
Next stop:
ARC301 - Controlling the Flood!
Right here in this room.
Please give us your feedback on this
presentation

SVC206
As a thank you, we will select prize
winners daily for completed surveys!

Mais conteúdo relacionado

Mais procurados

9월 웨비나 - AWS에서의 네트워크 보안 (이경수 솔루션즈 아키텍트)
9월 웨비나 - AWS에서의 네트워크 보안 (이경수 솔루션즈 아키텍트)9월 웨비나 - AWS에서의 네트워크 보안 (이경수 솔루션즈 아키텍트)
9월 웨비나 - AWS에서의 네트워크 보안 (이경수 솔루션즈 아키텍트)
Amazon Web Services Korea
 
Amazon Virtual Private Cloud VPC Architecture AWS Web Services
Amazon Virtual Private Cloud VPC Architecture AWS Web ServicesAmazon Virtual Private Cloud VPC Architecture AWS Web Services
Amazon Virtual Private Cloud VPC Architecture AWS Web Services
Robert Wilson
 
Decouple and Scale Applications Using Amazon SQS and Amazon SNS - July 2017 A...
Decouple and Scale Applications Using Amazon SQS and Amazon SNS - July 2017 A...Decouple and Scale Applications Using Amazon SQS and Amazon SNS - July 2017 A...
Decouple and Scale Applications Using Amazon SQS and Amazon SNS - July 2017 A...
Amazon Web Services
 

Mais procurados (20)

9월 웨비나 - AWS에서의 네트워크 보안 (이경수 솔루션즈 아키텍트)
9월 웨비나 - AWS에서의 네트워크 보안 (이경수 솔루션즈 아키텍트)9월 웨비나 - AWS에서의 네트워크 보안 (이경수 솔루션즈 아키텍트)
9월 웨비나 - AWS에서의 네트워크 보안 (이경수 솔루션즈 아키텍트)
 
AWS Basics .pdf
AWS Basics .pdfAWS Basics .pdf
AWS Basics .pdf
 
Deep Dive on AWS Lambda
Deep Dive on AWS LambdaDeep Dive on AWS Lambda
Deep Dive on AWS Lambda
 
Amazon_SNS.pptx
Amazon_SNS.pptxAmazon_SNS.pptx
Amazon_SNS.pptx
 
Introduction to AWS VPC, Guidelines, and Best Practices
Introduction to AWS VPC, Guidelines, and Best PracticesIntroduction to AWS VPC, Guidelines, and Best Practices
Introduction to AWS VPC, Guidelines, and Best Practices
 
Amazon Virtual Private Cloud VPC Architecture AWS Web Services
Amazon Virtual Private Cloud VPC Architecture AWS Web ServicesAmazon Virtual Private Cloud VPC Architecture AWS Web Services
Amazon Virtual Private Cloud VPC Architecture AWS Web Services
 
Getting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless Architectures
 
Deep dive into AWS fargate
Deep dive into AWS fargateDeep dive into AWS fargate
Deep dive into AWS fargate
 
Aws
AwsAws
Aws
 
AWS RDS
AWS RDSAWS RDS
AWS RDS
 
Amazon SQS overview
Amazon SQS overviewAmazon SQS overview
Amazon SQS overview
 
AWSome Day Leeds
AWSome Day Leeds AWSome Day Leeds
AWSome Day Leeds
 
AWS networking fundamentals
AWS networking fundamentalsAWS networking fundamentals
AWS networking fundamentals
 
AWS Secrets Manager
AWS Secrets ManagerAWS Secrets Manager
AWS Secrets Manager
 
Decouple and Scale Applications Using Amazon SQS and Amazon SNS - July 2017 A...
Decouple and Scale Applications Using Amazon SQS and Amazon SNS - July 2017 A...Decouple and Scale Applications Using Amazon SQS and Amazon SNS - July 2017 A...
Decouple and Scale Applications Using Amazon SQS and Amazon SNS - July 2017 A...
 
Accelerating App Development with AWS Amplify
Accelerating App Development with AWS AmplifyAccelerating App Development with AWS Amplify
Accelerating App Development with AWS Amplify
 
AWS X-Ray를 통한 서버리스 분산 애플리케이션 추적하기 - 윤석찬 (AWS 테크에반젤리스트)
AWS X-Ray를 통한 서버리스 분산 애플리케이션 추적하기 - 윤석찬 (AWS 테크에반젤리스트)AWS X-Ray를 통한 서버리스 분산 애플리케이션 추적하기 - 윤석찬 (AWS 테크에반젤리스트)
AWS X-Ray를 통한 서버리스 분산 애플리케이션 추적하기 - 윤석찬 (AWS 테크에반젤리스트)
 
[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...
[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...
[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...
 
Amazon EC2 & VPC HOL
Amazon EC2 & VPC HOLAmazon EC2 & VPC HOL
Amazon EC2 & VPC HOL
 
Deep Dive on Amazon RDS (Relational Database Service)
Deep Dive on Amazon RDS (Relational Database Service)Deep Dive on Amazon RDS (Relational Database Service)
Deep Dive on Amazon RDS (Relational Database Service)
 

Semelhante a Speed and Reliability at Any Scale: Amazon SQS and Database Services (SVC206) | AWS re:Invent 2013

AWS Cloud Kata | Manila - Getting to Scale on AWS
AWS Cloud Kata | Manila - Getting to Scale on AWSAWS Cloud Kata | Manila - Getting to Scale on AWS
AWS Cloud Kata | Manila - Getting to Scale on AWS
Amazon Web Services
 
Amazon
AmazonAmazon
Amazon
iamzkz
 

Semelhante a Speed and Reliability at Any Scale: Amazon SQS and Database Services (SVC206) | AWS re:Invent 2013 (20)

Build A Website on AWS for Your First 10 Million Users
Build A Website on AWS for Your First 10 Million UsersBuild A Website on AWS for Your First 10 Million Users
Build A Website on AWS for Your First 10 Million Users
 
Scaling Up to Your First 10 Million Users
Scaling Up to Your First 10 Million UsersScaling Up to Your First 10 Million Users
Scaling Up to Your First 10 Million Users
 
윈도 닷넷 개발자를 위한 솔루션 클라우드 데브옵스 솔루션
윈도 닷넷 개발자를 위한 솔루션 클라우드 데브옵스 솔루션윈도 닷넷 개발자를 위한 솔루션 클라우드 데브옵스 솔루션
윈도 닷넷 개발자를 위한 솔루션 클라우드 데브옵스 솔루션
 
Why Scale Matters and How the Cloud is Really Different (at scale)
Why Scale Matters and How the Cloud is Really Different (at scale)Why Scale Matters and How the Cloud is Really Different (at scale)
Why Scale Matters and How the Cloud is Really Different (at scale)
 
AWS Cloud Kata 2014 | Jakarta - 2-1 AWS Intro and Scale 2014
AWS Cloud Kata 2014 | Jakarta - 2-1 AWS Intro and Scale 2014AWS Cloud Kata 2014 | Jakarta - 2-1 AWS Intro and Scale 2014
AWS Cloud Kata 2014 | Jakarta - 2-1 AWS Intro and Scale 2014
 
AWS Summit Auckland 2014 | Running your First Application on AWS
AWS Summit Auckland 2014 | Running your First Application on AWSAWS Summit Auckland 2014 | Running your First Application on AWS
AWS Summit Auckland 2014 | Running your First Application on AWS
 
Best Practices Scaling Web Application Up to Your First 10 Million Users
Best Practices Scaling Web Application Up to Your First 10 Million UsersBest Practices Scaling Web Application Up to Your First 10 Million Users
Best Practices Scaling Web Application Up to Your First 10 Million Users
 
What is Amazon Web Services & How to Start to deploy your apps ?
What is Amazon Web Services & How to Start to deploy your apps ?What is Amazon Web Services & How to Start to deploy your apps ?
What is Amazon Web Services & How to Start to deploy your apps ?
 
Running your First Application on AWS
Running your First Application on AWSRunning your First Application on AWS
Running your First Application on AWS
 
AWS re:Invent 2016: IoT Visualizations and Analytics (IOT306)
AWS re:Invent 2016: IoT Visualizations and Analytics (IOT306)AWS re:Invent 2016: IoT Visualizations and Analytics (IOT306)
AWS re:Invent 2016: IoT Visualizations and Analytics (IOT306)
 
AWS Cloud Kata 2013 | Singapore - Getting to Scale on AWS
AWS Cloud Kata 2013 | Singapore - Getting to Scale on AWSAWS Cloud Kata 2013 | Singapore - Getting to Scale on AWS
AWS Cloud Kata 2013 | Singapore - Getting to Scale on AWS
 
ENT309 Scaling Up to Your First 10 Million Users
ENT309 Scaling Up to Your First 10 Million UsersENT309 Scaling Up to Your First 10 Million Users
ENT309 Scaling Up to Your First 10 Million Users
 
ENT309 Scaling Up to Your First 10 Million Users
ENT309 Scaling Up to Your First 10 Million UsersENT309 Scaling Up to Your First 10 Million Users
ENT309 Scaling Up to Your First 10 Million Users
 
ENT309 scaling up to your first 10 million users
ENT309 scaling up to your first 10 million usersENT309 scaling up to your first 10 million users
ENT309 scaling up to your first 10 million users
 
AWS Cloud Kata | Manila - Getting to Scale on AWS
AWS Cloud Kata | Manila - Getting to Scale on AWSAWS Cloud Kata | Manila - Getting to Scale on AWS
AWS Cloud Kata | Manila - Getting to Scale on AWS
 
Amazon
AmazonAmazon
Amazon
 
Building Highly Scalable Web Applications
Building Highly Scalable Web ApplicationsBuilding Highly Scalable Web Applications
Building Highly Scalable Web Applications
 
Serverless Architecture Patterns
Serverless Architecture PatternsServerless Architecture Patterns
Serverless Architecture Patterns
 
serverless_architecture_patterns_london_loft.pdf
serverless_architecture_patterns_london_loft.pdfserverless_architecture_patterns_london_loft.pdf
serverless_architecture_patterns_london_loft.pdf
 
Scaling on AWS for the First 10 Million Users at Websummit Dublin
Scaling on AWS for the First 10 Million Users at Websummit DublinScaling on AWS for the First 10 Million Users at Websummit Dublin
Scaling on AWS for the First 10 Million Users at Websummit Dublin
 

Mais de Amazon Web Services

Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
Amazon Web Services
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
Amazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
Amazon Web Services
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
Amazon Web Services
 

Mais de Amazon Web Services (20)

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

Speed and Reliability at Any Scale: Amazon SQS and Database Services (SVC206) | AWS re:Invent 2013

  • 1. Speed and Reliability at Any Scale – Combining SQS and DB Services Jonathan Desrocher, Amazon Web Services Colin Vipurs, Shazam Entertainment Ltd. November 14, 2013 © 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified, or distributed in whole or in part without the express consent of Amazon.com, Inc.
  • 2. AWS Messaging = Amazon SQS + Amazon SNS
  • 3. Amazon SQS Core Features • • New and improved Payload size of up to 256KB Message batching for higher throughput and reduced costs • Supports long polling for reduced costs and latency • Cross-origin resource sharing support
  • 9. Basic Message Lifecycle Reader A Reader B ReceiveMessage A B
  • 16. That covers reliability. Now let’s go for the scale!
  • 18. Bulk Transactional Reads A RAM: 10 Msgs ReceiveMessage A A A A Reader A A A A A A
  • 19. Bulk Transactional Reads A ReceiveMessage A A A A Reader A A A A A A A A A A A A A A A A RAM: 20 Msgs
  • 20. Bulk Transactional Reads A ReceiveMessage A A A A Reader A A A A A A A A A A A A A A A A A A A A A A A A A A RAM: 30 Msgs
  • 23. Let’s take it to real life!
  • 24. Scalability example: market trade volume by half hour 350,000 300,000 250,000 200,000 150,000 100,000 50,000 0
  • 25. Scalability example: market trade volume by half hour 350,000 300,000 250,000 200,000 85% 150,000 100,000 50,000 0 15%
  • 27. Batch Processing • Use SQS as a scalable and resilient short-term storage solution. • Simply configure the appropriate retention period and send away! SendMessage HTTP PUT Elastic Beanstalk Application
  • 28. Batch Processing • When appropriate, launch a fleet of Amazon EC2 workers and process the messages en masse. ReceiveMessage
  • 29. Design pattern #2: IAM Roles for Amazon EC2
  • 30. Using IAM Roles for Amazon EC2 • Create an IAM role with the appropriate permissions to Amazon SQS. • Launch EC2 instances with this role. • Done! – Audit logs will correlate the EC2 instance ID to the SQS API calls. – IAM will automatically rotate the credentials on our behalf. { "Statement": [ { "Sid": "Stmt1384277213171", "Action": [ "sqs:ChangeMessageVisibility", "sqs:DeleteMessage", "sqs:GetQueueAttributes", "sqs:GetQueueUrl", "sqs:ListQueues", "sqs:ReceiveMessage" ], "Effect": "Allow", "Resource": "arn:aws:sqs:us-east1:455320512810:Sensor_Ingestion" } ] }
  • 31. Using IAM Roles for Amazon EC2 • Use the AWS SDK on the Instance • No need to type credentials • • • Not in code Not in a configuration file Not via the console either require ‘rubygems’ require ‘aws-sdk’ sqs = AWS::SQS.new() myqueue = sqs.queues.named("Sensor_Ingestion") myqueue.poll do |msg| # Do something with the message end
  • 32. Design pattern #3: Using SQS to durably batch writes
  • 33. Using SQS to durably batch writes • The application: – – – – An AWS Elastic Beanstalk application. Clients upload data to the application through HTTP PUTs. Each upload is 100KB in size. Amazon S3 will be used as the permanent data store. S3 PUT HTTP PUT Elastic Beanstalk Application S3 Bucket
  • 34. Using SQS to durably batch writes • The challenge: – We have an external constraint that requires us to batch the upload into Amazon S3. For example: • Amazon EMR best practices call for Amazon S3 object size of >10MB. • Hourly Amazon Redshift batch inserts. EMR Cluster S3 PUT HTTP PUT Elastic Beanstalk Application S3 Bucket Redshift Database
  • 35. Using SQS to durably batch writes • Enter SQS: – Persist individual client PUTs as SQS messages. – Have an Amazon EC2 worker role that performs the following logic: • Receive SQS message and add to an in-memory buffer. • Once buffer is full, upload to Amazon S3. • Upon acknowledgement from S3, delete SQS messages from queue. SendMessage HTTP PUT Elastic Beanstalk Application ReceiveMessage EMR Cluster S3 PUT S3 Bucket Redshift Database
  • 36. Using SQS to durably batch writes • Also to consider: – Some data stores are optimized for read workloads – Buffering the writes with Simple Queue Service will ensure both speed and reliability of data ingestion. SendMessage HTTP PUT Elastic Beanstalk Application ReceiveMessage BatchWriteItem RDS Database
  • 38. Discarding stale messages • Controlled via the MessageRetentionPeriod property. • Useful when there is no business value for data older than X minutes. – “Transactions that don’t complete within 5 minutes are abandoned, enabling client-side failure handling”. SendMessage HTTP PUT Elastic Beanstalk Application ReceiveMessage [Stale Messages] EMR Cluster S3 PUT S3 Bucket Redshift Database
  • 39. Design pattern #5: Simple Notification Service Fan-out
  • 40. Simple Notification Service Fan-out • Atomically distribute a message to multiple subscribers over different transport methods – – – – • SQS queues HTTP/S endpoints SMS Email Also used to abstract different mobile device push providers (MBL308) – Apple Push Notification Service – Google Cloud Messaging for Android – Amazon Device Messaging Publish
  • 41. Simple Notification Service Fan-out • Perform different operations on the same data – Split different facets of the payload into different systems. – Duplicate the data into short-term and longterm storage systems. ReceiveMessage S3 PUT S3 Bucket EMR Cluster S3 Bucket Redshift Database SNS Publish HTTP PUT Elastic Beanstalk Application ReceiveMessage S3 PUT
  • 42. Simple Notification Service Fan-out • Deliver the same data to different environments Production ReceiveMessage S3 PUT S3 Bucket DynamoDB Table S3 Bucket DynamoDB Table SNS Publish HTTP PUT Test Elastic Beanstalk Application ReceiveMessage S3 PUT
  • 43. Simple Notification Service Fan-out • Distribute the same data to a multiple external environments: – Push data to different locations worldwide. – Seamlessly synchronize AWS and on-premises environments. – Pro tip: MessageID field is consistent across locations. us-east-1 eu-west-1 SNS Publish HTTP PUT Elastic Beanstalk Application ap-northeast-1 On-premises Data Center
  • 44. Simple Notification Service Fan-out • Each recipient can have its own preferred transport protocol: – SQS for guaranteed delivery – Email for human-friendly delivery – HTTP/S for real-time push Partner/Process A Partner/Process B SNS Publish HTTP PUT Elastic Beanstalk Application Partner/Process C Partner/Process D
  • 45. Design pattern #6: Send messages from the browser
  • 46. Send messages from the browser • Make direct calls to AWS services such as SQS and DynamoDB directly from the user’s browser. • Authentication is based on STS tokens. • Supports S3, SQS, SNS and DynamoDB.
  • 47. Send messages from the browser • Back to our sample architecture: – Browser authenticates against Elastic Beanstalk application – Response includes location of SQS Queue and STS Token for direct authentication. GetToken Elastic Beanstalk Application SendMessage ReceiveMessage EMR Cluster S3 PUT S3 Bucket Redshift Database
  • 49.
  • 50.
  • 51.
  • 52. 375 MILLION USERS 75 MILLION MONTHLY ACTIVE USERS 10 MILLION NEW USERS PER MONTH
  • 54. Amazon SQS for surge protection SQS shield
  • 55. c3po single event message update request queue worker user data batch data req. Facebook Realtime Updates user data user updater DynamoDB
  • 57. Queue Worker Anatomy operation read msg versioned msg data object target system pollers unmarshallers handlers
  • 59. SQS for SLAs high priority batch data ingester std priority queue worker low priority
  • 60. SQS as DynamoDB Buffer data API DynamoDb
  • 63. SQS as DynamoDB Buffer data API DynamoDb throughtput exceeded data data data message queue worker
  • 64. SQS as DynamoDB Buffer data API client fails fast DynamoDb data queue worker client retries
  • 65. SQS as DynamoDB Buffer public interface Writer <T> { void write(T t); }
  • 69. SQS for Shazam is… • • • • Protection from the outside world Short term, unbounded persistence Cost effective elastic capacity Scalable data segregation
  • 71. Design patterns recap 1. 2. 3. 4. 5. 6. Batch processing IAM Roles for EC2 Using SQS to durably batch writes Discard stale messages Simple Notification Service Fan-out Send messages from the browser
  • 72. Additional messaging resources • Application Services Booth • re:Invent sessions: – ARC301 Controlling the Flood: Massive Message Processing with AWS SQS and DynamoDB – MBL308 Engage Your Customers with Amazon SNS Mobile Push • AWS Support and Discussion Forums • AWS Architecture Center: http://aws.amazon.com/architecture • Documentation: http://aws.amazon.com/documentation/sqs
  • 73. Next stop: ARC301 - Controlling the Flood! Right here in this room.
  • 74. Please give us your feedback on this presentation SVC206 As a thank you, we will select prize winners daily for completed surveys!