SlideShare a Scribd company logo
AWS SQS for better
architecture
23rd
Dec'14
Saurabh S Bangad
Contents
-How did SQS solve a problem?
-Usage guidance
-Architectural patterns
-Example architectures
-Mistakes
-Example cases
-References
How did SQS solve a problem?
“My app has several jobs running based on a cron
setting. That is, some run every 15 minutes, some
once an hour, some once a day.
These are jobs that affect our RDS data and our S3
resources, which are shared amongst all our ec2
instances such that each job only needs to be run
by one machine. Running the same job multiple
times is at best wasteful, and at worst could send
out multiple emails to the same person.
So I want to be able to auto-scale to multiple ec2
instances, yet still have these jobs only run by
one machine. But because each auto-scaled instance
must use the same ami and run the same
application, it is not easy to configure which
particular machine runs which jobs.”
How did SQS solve a problem?
"My app has several jobs running
based on a cron setting." => ????
"That is, some run every 15
minutes, some once an hour, some
once a day." => Randomness
"These are jobs that affect our
RDS data and our S3 resources, :
=> Transactional
How did SQS solve a problem?
"These are jobs that affect our
RDS data and our S3 resources,
which are shared amongst all our
ec2 instances such that each job
only needs to be run by one
machine." => ????
How did SQS solve a problem?
"Running the same job multiple
times is at best wasteful, and at
worst could send out multiple
emails to the same person."
=> Of course! Just make use of an
EC2 instance and you are all set.
How did SQS solve a problem?
"So I want to be able to auto-
scale to multiple ec2 instances"
=> AutoScaling! I like that, but
instances don't talk to each
other.
"yet still have these jobs only
run by one machine"
=> Sorry ?
How did SQS solve a problem?
"But because each auto-scaled
instance must use the same ami
and run the same application, it
is not easy to configure which
particular machine runs which
jobs."
=> I know..
How did SQS solve a problem?
-This is an SQS session, so obviously
the answer is SQS, but how would you
solve this problem otherwise ?
-Problem : This is not a client-server
model
-How would the instances synchronize ?
-How about a protocol for decision
making in a distributed fashion ?
Too much of research!
Usage Guidance
Producer-consumer model
Usage Guidance
"My app has several jobs running
based on a cron setting."
=> The Producer
"These are jobs that affect our RDS
data and our S3 resources, which are
shared amongst all our ec2 instances
such that each job only needs to be
run by one machine."
=> The Consumer
*Do think about it after the
session.*
Usage Guidance
Processing of a message in SQS
P: Producer m:Message
C: Consumer Q:Queue
Story/Flow :
1)P1 sends m1 to Q1 & P2 sends m2,m3 to the Q1
2)Q1={m1,m2,m3} //unordered set
3)C1 requests a message
4)Q1 returns one of the messages
5)m2 is received by the C1
6)C1 processes m2
7)C1 deletes m2 from the queue
8)Q1={m1,m3}
9)C2 requests a message
10)...story continues...
Usage Guidance
What will happen if the two
consumers request at the same
time ?
=> The Visibility timeout
Usage Guidance
What will happen when the
consumer that polled the message
dies/forgets ?
=> Expired visibility timeout
Usage Guidance
What if there are no messages in
the queue for a longer duration?
It would waste resources looking
up continuously and getting empty
responses.
This does affect the billing as
well.
=>sleep on the consumer side
=>long polling while receiving
The wait time
Architectural patterns
Characteristics of SQS :
-Buffer reliably
-Scalable
-Managed/Queue-aaS
-Secured
-Highly available
-SIMPLE-QS
HA in real sense : (Queue==Que==Q)LOL
Architectural patterns
Where can it be used ?
-Asynchronous functioning
-Loosely coupled components
-Stateless system
-Failure resilient system
Example architecture
Chained processing
e.g. Intermediate code generation between multiple
teams and/or components of the system
Example architecture
Priority queuing with SQS
e.g. meeting SLAs based on the type of a customer
Another approach : With a single queue?
Example architecture
File sharing
Possible approaches :
1)Producer AutoScaling group can upload the
files to S3 and share the URLs over the
queue.
2)S3 events can be pushed directly to SQS
3)If the file size is upto 256KB, you can
just share it as a message.
Architectural patterns/example
Publisher-Subscriber model
e.g. independent teams using part of the message
TIMESTAMP Order Shipping-Type
03/03/14:10:10GMT HeadphonesX Two Days Paid
03/03/14:10:10GMT ProductY Three Days Free
A team uses timestamp+shipping, the other ignores that
Example architecture
Automation by signaling
e.g. Polling SQS for Job Status / Event driven
when Elastic Transcoder publishes status messages
to SNS, they ultimately get buffered to the Queue.
When a consumer poll the message, it can resume
the pending operations
Example architecture
Email confirmation
e.g. Sign up of new user where user would be sent
an email to confirm which doesn't happen
interactively
Example architecture
SES bounces and complains
Example architecture
Users talking directly to the SQS which
is backed by DynamoDB
Mobile app
Mistakes
-Can SQS send message to .. ? NO!
-Is SQS FIFO? NO!
-Not deleting the messages
-visibility timeout=0
-visibility timeout=too high
-Using standard/short polling
-Not polling enough
-Retention period=too low
-Synchronous/interactive jobs
-Producer=consumer(same machine)
Example Cases
-How do I deal with the at least once delivery?
-How do I deploy the new code to prod with the
changes in the message format?
-Our website will start splittting the traffic
between two ELBs, one for actual content and
other for logging, we need to get the ELB
prewarmed to support logging.
-Where did that message go?
References
1)www.cs.rpi.edu/~goldsd/docs/fall2014-csci4210/producer-
consumer-problem.jpg
2)docs.aws.amazon.com/sns/latest/dg/SNS_Scenarios.html
3)en.clouddesignpattern.org/index.php/CDP:Queuing_Chain_Patt
ern
4)en.clouddesignpattern.org/index.php/CDP:Priority_Queue_Pat
tern
5)blogs.aws.amazon.com/application-management/blog/tag/SQS
6)Re:invent'14 ARC313
7)blogs.aws.amazon.com/application-
management/post/Tx2PM64E771CQGG/Using-DynamoDB-and-SNS-with-
Elastic-Beanstalk-in-any-Supported-AWS-Region
8)sesblog.amazon.com/post/TxJE1JNZ6T9JXK/Handling-Bounces-
and-Complaints
9)docs.aws.amazon.com/AWSSimpleQueueService/latest
10)Font name : Courier New
Thanks a lot!
Any Questions?

More Related Content

PPTX
Amazon SQS overview
PDF
An introduction to Amazon SQS
PDF
Sqs and loose coupling
PDF
AWS와 부하테스트의 절묘한 만남 :: 김무현 솔루션즈 아키텍트 :: Gaming on AWS 2016
PPTX
Spring Boot+Kafka: the New Enterprise Platform
PPTX
AWS SQS SNS
PDF
Best Practices with Azure Kubernetes Services
PDF
AWS CLOUD 2017 - AWS 기반 하이브리드 클라우드 환경 구성 전략 (김용우 솔루션즈 아키텍트)
Amazon SQS overview
An introduction to Amazon SQS
Sqs and loose coupling
AWS와 부하테스트의 절묘한 만남 :: 김무현 솔루션즈 아키텍트 :: Gaming on AWS 2016
Spring Boot+Kafka: the New Enterprise Platform
AWS SQS SNS
Best Practices with Azure Kubernetes Services
AWS CLOUD 2017 - AWS 기반 하이브리드 클라우드 환경 구성 전략 (김용우 솔루션즈 아키텍트)

What's hot (20)

PPTX
AWS ELB - Fundamentals
PPTX
Microservices design patterns
PPTX
Azure Security Fundamentals
PDF
Building robust and friendly command line applications in go
PDF
AWS AutoScaling
PDF
Amazon EventBridge
PPTX
Introduction to DevOps on AWS
PDF
AWS 서비스로 웹 애플리케이션 만들기 – 김주영, AWS 솔루션즈 아키텍트:: AWS Builders Online Series
PDF
서버리스 아키텍처 패턴 및 로그 처리를 위한 파이프라인 구축기 - 황윤상 솔루션즈 아키텍트, AWS / Matthew Han, SendBi...
PPTX
Microservices in the Apache Kafka Ecosystem
PDF
Api observability
PDF
Amazon EKS를 위한 AWS CDK와 CDK8s 활용법 - 염지원, 김광영 AWS 솔루션즈 아키텍트 :: AWS Summit Seou...
PDF
[AWS Builders] AWS 네트워크 서비스 소개 및 사용 방법 - 김기현, AWS 솔루션즈 아키텍트
PPTX
Google app engine - Overview
PPTX
Introduction to microservices
PPTX
AWS Introduction
PDF
AWS와 함께하는 클라우드 컴퓨팅 - 강철, AWS 어카운트 매니저 :: AWS Builders 100
PPTX
PPTX
소프트웨어 개발 트랜드 및 MSA (마이크로 서비스 아키텍쳐)의 이해
PPTX
An Authentication and Authorization Architecture for a Microservices World
AWS ELB - Fundamentals
Microservices design patterns
Azure Security Fundamentals
Building robust and friendly command line applications in go
AWS AutoScaling
Amazon EventBridge
Introduction to DevOps on AWS
AWS 서비스로 웹 애플리케이션 만들기 – 김주영, AWS 솔루션즈 아키텍트:: AWS Builders Online Series
서버리스 아키텍처 패턴 및 로그 처리를 위한 파이프라인 구축기 - 황윤상 솔루션즈 아키텍트, AWS / Matthew Han, SendBi...
Microservices in the Apache Kafka Ecosystem
Api observability
Amazon EKS를 위한 AWS CDK와 CDK8s 활용법 - 염지원, 김광영 AWS 솔루션즈 아키텍트 :: AWS Summit Seou...
[AWS Builders] AWS 네트워크 서비스 소개 및 사용 방법 - 김기현, AWS 솔루션즈 아키텍트
Google app engine - Overview
Introduction to microservices
AWS Introduction
AWS와 함께하는 클라우드 컴퓨팅 - 강철, AWS 어카운트 매니저 :: AWS Builders 100
소프트웨어 개발 트랜드 및 MSA (마이크로 서비스 아키텍쳐)의 이해
An Authentication and Authorization Architecture for a Microservices World
Ad

Viewers also liked (14)

PPT
Amazon simple queue service
PPTX
Andes: a Scalable persistent Messaging System
PPTX
PPTX
Push Notification
ODP
Caching and tuning fun for high scalability
PPTX
AWS Cloud Disaster Recovery Plan Checklist - Are you ready?
PDF
AWS Cloudfront Howto
PPTX
Aws certificate managerを使ってみたよ
PDF
Azure 機器學習 - 使用Python, R, Spark, CNTK 深度學習
PPTX
Hive + Amazon EMR + S3 = Elastic big data SQL analytics processing in the cloud
PPT
develop security policy
PPT
Arduino technical session 1
PDF
GPUDirect RDMA and Green Multi-GPU Architectures
PPTX
AWS Services overview and global infrastructure
Amazon simple queue service
Andes: a Scalable persistent Messaging System
Push Notification
Caching and tuning fun for high scalability
AWS Cloud Disaster Recovery Plan Checklist - Are you ready?
AWS Cloudfront Howto
Aws certificate managerを使ってみたよ
Azure 機器學習 - 使用Python, R, Spark, CNTK 深度學習
Hive + Amazon EMR + S3 = Elastic big data SQL analytics processing in the cloud
develop security policy
Arduino technical session 1
GPUDirect RDMA and Green Multi-GPU Architectures
AWS Services overview and global infrastructure
Ad

Similar to AWS SQS for better architecture (20)

PPTX
Lecture- Loosely Coupled Cloud Native Architectures-- (1).pptx
PPTX
Module 2 of cloud computing of CSE student. hope this helps in your subject
PPT
Building Highly Scalable Web Applications
PPT
Amazon
PPTX
AWS: Messaging Services in AWS Presentation
PPT
Cloud computing @ slideshare
PPTX
Captial One: Why Stream Data as Part of Data Transformation?
PPTX
AWS Serverless key services
PDF
Architecting applications in the AWS cloud
PDF
Cloud Computing With Amazon Web Services, Part 4: Reliable Messaging With SQS
PPTX
Amazon web services session 4
PPTX
Aws Architecture Training
PPTX
Algorithmic Trading
PDF
Cloud- IaaS in Perspective AWS
PPTX
2 5404811386729530203
PDF
Lets SAASify that Desktop Application
PPTX
Amazon web services(aws)
PDF
OSCON Data 2011 -- NoSQL @ Netflix, Part 2
PPTX
Creating scalable solutions with aws
PDF
Software Architecture for Cloud Infrastructure
Lecture- Loosely Coupled Cloud Native Architectures-- (1).pptx
Module 2 of cloud computing of CSE student. hope this helps in your subject
Building Highly Scalable Web Applications
Amazon
AWS: Messaging Services in AWS Presentation
Cloud computing @ slideshare
Captial One: Why Stream Data as Part of Data Transformation?
AWS Serverless key services
Architecting applications in the AWS cloud
Cloud Computing With Amazon Web Services, Part 4: Reliable Messaging With SQS
Amazon web services session 4
Aws Architecture Training
Algorithmic Trading
Cloud- IaaS in Perspective AWS
2 5404811386729530203
Lets SAASify that Desktop Application
Amazon web services(aws)
OSCON Data 2011 -- NoSQL @ Netflix, Part 2
Creating scalable solutions with aws
Software Architecture for Cloud Infrastructure

Recently uploaded (20)

PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Machine learning based COVID-19 study performance prediction
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Empathic Computing: Creating Shared Understanding
PPTX
sap open course for s4hana steps from ECC to s4
PPT
Teaching material agriculture food technology
PDF
KodekX | Application Modernization Development
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Network Security Unit 5.pdf for BCA BBA.
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Review of recent advances in non-invasive hemoglobin estimation
Building Integrated photovoltaic BIPV_UPV.pdf
Approach and Philosophy of On baking technology
Machine learning based COVID-19 study performance prediction
20250228 LYD VKU AI Blended-Learning.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Empathic Computing: Creating Shared Understanding
sap open course for s4hana steps from ECC to s4
Teaching material agriculture food technology
KodekX | Application Modernization Development
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Unlocking AI with Model Context Protocol (MCP)
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Profit Center Accounting in SAP S/4HANA, S4F28 Col11

AWS SQS for better architecture