Data processing
SQS¶
General Info¶
- Description
-
- Message queueing service
- SQS Queue = buffer between the app components that receive data & those that process data
- Features
- Ensures delivery of each message at least once
- Supports multiple readers/writers on the same queue
- Limitations
- Design your system to be IDEMPOTENT
- FIFO not guaranteed (use FIFO queues)
- Data stored within SQS is not encrypted by AWS (user has to encrypt before pushing to SQS)
- Message Lifecycle
-
- Component 1 (
C1) sends message A (MA) to a queue - When
C2is ready to process a message, it retrieves it from the queue - While
MAis being processed, it remains in the queue & is not returned for the duration of the visibility timeout C2deletesMAfrom the queue once it is done processing it
- Component 1 (
Message Identifiers
| Identifier | Description |
|---|---|
QUEUE URL |
Includes QUEUE NAME, provided at creation time and unique in the scope of all your queues |
MESSAGE ID |
|
RECEIPT HANDLE |
|
Sending¶
Parameters
Message Group ID |
|
Message Deduplication ID |
Specific to each <issue, user> |
- Retry
-
- If the producer detects a failed
SendMessageaction, it can retry sending as many times as necessary, using the same message deduplication ID - Assuming that the producer receives at least one acknowledgement before the deduplication interval expires, multiple retries neither affect the ordering of messages nor introduce duplicates
- If the producer detects a failed
- Delay Queue
-
- Let you postpone the delivery of new messages to a queue for a number of seconds
- Similar to visibility timeouts because both make messages unavailable to consumers for a specific period of time
- The difference is that, for delay queues, a message is hidden when it is first added to queue
- Whereas for visibility timeouts a message is hidden only after it is consumed from the queue
- To set delay seconds on individual messages, rather than on an entire queue, use message timers to allow SQS to use the message timer's
DelaySecondsvalue instead of the delay queue'sDelaySecondsvalue - Message timers let you specify an initial invisibility period for a message added to a queue
- Let you postpone the delivery of new messages to a queue for a number of seconds
- Dead-Letter Queue
-
- Queues, which other queues (source queues) can target for messages that can't be processed (consumed) successfully
- The redrive policy specifies the source queue, the dead-letter queue, and the conditions under which Amazon SQS moves messages from the former to the latter if the consumer of the source queue fails to process a message a specified number of times
- When the
ReceiveCountfor a message exceeds themaxReceiveCountfor a queue, SQS moves the message to a dead-letter queue (with its original message ID) - Configure an alarm for any messages delivered to a dead-letter queue
Receiving¶
Parameters
Visibility Timeout |
|
MaxNumberOfMessages |
|
- Return
-
- When you receive a message with a
message group ID, no more messages for the samemessage group IDare returned unless you delete the message or it becomes visible - SQS FIFO does not guarantee only once delivery when used as a Lambda trigger. If only once delivery is important in your serverless application, it's recommended to make your function idempotent.
- When you receive a message with a
- Long Polling
-
ReceiveMessagecheck for existence of a message in the queue & returns IMMEDIATELY (with or without a message)- Long polling sends
WaitTimeSeconds(<=20secs) argument toReceiveMessage - If no message in the queue → call will wait
WaitTimeSecondsfor a message to appear before returning
SNS¶
- Description
-
- Web service for mobile & messaging to manage notifications
- PUB/SUB Paradigm
- Notifications pushed to clients, eliminating need to poll periodically
- Allows for parallel async processing
- FANOUT = SNS message sent to a topic & then replicated & pushed to multiple SQS queues/HTTP endpoints/email addresses
Components
PUBLISHERS |
Communicate with SUBSCRIBERS ASYNC by sending a message to a TOPIC |
SUBSCRIBERS |
|
TOPIC |
|
DELIVERY METHOD |
SQS, HTTP/HTTPS, email, SMS, Lambda |
Kinesis¶
Streaming data platform consisting of 3 services
Use Cases
| Use Case | Description |
|---|---|
| DATA INGESTION | Ensure data is accepted reliably & successfully stored in AWS |
| REALTIME PROCESSING of massive data streams | Act on knowledge gleaned from a big data stream right away |
| NOT for BATCH Jobs | Not appropriate for batch jobs (ETL) |
Services
| Service | Description |
|---|---|
| FIREHOSE |
![]() |
| STREAMS |
|
| ANALYTICS |
|
