CMSC389L
Week 6
SQS
October, 6, 2017
Recap
- Week 5 Feedback Form: ter.ps/389L5
- Codelab 3 (EC2) Released: ter.ps/389LCL3
- No submission necessary
- However, make sure that you understand the concepts
New Student Facilitator
- Andrej Rasevic will be joining as a second student facilitator.
- He will be helping out with codelabs + projects
- Contact: arasevic@cs.umd.edu
EC2
EC2 Pricing
-
On-Demand Pricing
-
t2.micro: $0.0116 per hour (pro-rated to the second!)
- $8.352 / month, if run 24/7
-
t2.micro: $0.0116 per hour (pro-rated to the second!)
- Free Tier:
-
750 hours / month (of t2.micro)
- 744 hours in a 31-day month
-
750 hours / month (of t2.micro)
EC2 Pricing
-
On-Demand Pricing (cont.)
- smallest: t2.nano for $4.176 / month
- largest: x1e.32xlarge (4TB memory): $26.688 / hour
- ~$20k/month
-
Other options:
-
Spot Pricing: Bid on instance pricing in a market
- AWS's spare compute power
- Can be up to 90% cheaper
-
Reserved Pricing: Request usage in advance and in bulk
- Good for predictable usage
- Can be up to 75% cheaper
-
Spot Pricing: Bid on instance pricing in a market
EC2 Pricing
-
Data Transfer
- In to / Out from AWS:
- Same AZ: Free
- Different AZ/Region*: 1-2¢ / GB
- Out to internet:
- 9¢ / GB
- In to / Out from AWS:
- * = free for some AWS services in the same region (f.e. S3, DynamoDB, SQS)
EBS Pricing
- General Purpose SSD Volumes: 10¢ / GB
- 40GB EBS volume used for one month is $4
SQS
Message Queues
- Message Queue: A shared queue that enables asynchronous communication of messages between processes.
SQS
- Simple Queue Service (SQS): A managed, distributed message queueing service frequently used to communicate between AWS services.
Why decouple components?
- Strongly coupled components form complex systems
- Hard to maintain/expand/refactor
- Instead:
- Encapsulate the inner workings of each component
- Expose a limited API
Why decouple components?
Why use message queues?
- What happens if the Service B dies?
- What happens if Service B can't process requests as quickly as Service A produces them?
- Load spikes?
- What if Service B dies while processing a request?
Real World Use Case
- Nextdoor sends ~30M emails / day
- ~350/second, but very spiky
- 100s of components that need to send emails
- Single service handles email generation and sending
- Components simply call an API from a library which places a message into an SQS queue
SQS Concepts
-
Delivery:
- Want to guarantee that all messages are processed
- We can only guarantee At-Lease-Once Delivery
- Every message will be delivered
- But, it may be delivered more than once
SQS Concepts
-
Ordering:
- We want high throughput of messages
- Standard Queues: "Unlimited" TPS
- FIFO Queues: Max 300 TPS
SQS Concepts
-
Polling:
- How do receivers retrieve messages from the queue?
- Long Polling: Wait until a message is available for processing. Searches all nodes.
- Short Polling: Immediately return if no messages available. Search subset of nodes.
- How do receivers retrieve messages from the queue?
SQS Concepts
-
Visibility Timeouts:
- When a receiver receives a message, that message is hidden from other receivers
- After a predefined amount of time (a few seconds up to 12 hours), it is made visible again
SQS Concepts
- Retention Period: Messages are deleted from a queue if not processed within a certain amount of time (up to 14 days)
- Max Message Size: Up to 256KB per message
- Dead Letter Queue: Messages can be placed in a DLQ after failing to be deleted after a predefined number of receives
SQS Demo
SQS Pricing
- Requests
- Standard: 40¢ per 1M requests
- FIFO: 50¢ per 1M requests
- Data Transfer between SQS/EC2
- Free (if within the same region)
- Can return multiple messages per request
- 1 request = 64KB chunk of a payload
- Free Tier: 1M requests
SQS Worksheet
Complete the worksheet section on SQS.
Previous Lecture Questions
Week 6 Feedback
Closing Notes
Turn in your worksheets!
CMSC389L Week 6
By Colin King
CMSC389L Week 6
- 787