Learning about SQS
SQS is a fully managed distributed queue system which comes in two flavours:
-
Standard Queue:
- Unlimited throughput -> no restrictions
- At-least once delivery -> occasionally deliver more than once so application code must handle it through Idempotency.
- Best effort ordering -> messages may come occasionally out of order.
- Usage:
- Decouple and process background jobs
- Batch message and doing heavy processing
-
FIFO Queue:
- Limited throughput -> as maintaining FIFO order would bound system to use a single node to server (can't fully scalable like standard queue) everything hence limited throughput bound by that system bandwidth.
- Exactly once processing
- Ordering is FIFO
- Usage:
- User entered commands needs to be processed in order
- Prevent a student from enrolling in a course if event of admission hasn't reached.
Features to know:
- Payload size: Each message is counted as single for payload size at max 64KB. One message can have upto 256KB but billed for 4 messages.
- Batching support: Each batch can have at-most 10 messages and billed as single message.
- Long polling: If manual consumer like EC2, ECS then prefer long polling. For lambda, it is handled by AWS internally.
- Fair queue: A high performant tenant doesn't impact throughput/latency of normal tenant.
- Message retention: upto 14 days
- Message locking/visibility timeout: Once a consumer consumes a message it becomes in-visible for other consumers till visibility timeout.
- DLQ support: When retries have exhausted or other issues are there.