Messaging Flashcards
List some feature of Amazon SQS
Unlimited Throughput
Unlimited number of messages in the queue
default retention of messages, maximum of 14 days
low latency (< 10 ms on publish and receive)
limit of 256 kb per message sent
can have duplicate messages
can have out of orrder messages
at least once delivery
How does message consumption work?
Consumers are computing entities (EC2, on-premises, Lambda) that poll messages, up to 10 at atime, after processing the message, the consumer deletes the message using the DeleteMessage Api
SQS with ASG (Auto Scaling Group) -
Which metric is responsible to trigger the scaling?
Queue Length - ApproximateNumberOfMessages
Alarm is set up once limit is triggered scaling the consumers
SQS and Security
Encryption:
In-flight enryption using HTTPS API
At-rest encryption using KMS Key
Access Controls:
IAM policies to regulate access to the SQS API
SQS Access policies (Similar to S§ bucket policies):
useful for cross-account access
useful for other services (SNS, S3, …) to write to SQS queues
How do Access Policies work with SQS?
Cross Account access:
Poll messages
specify policy in source account that the consumer in the target account assumes
policy has to specify the account id of target account, the actions to take place, and the arn of the sqs resource
Let S3 write messages to sqs queue
specify in policy the sqs arn, the action to take place, and in the condition section the arn of the s3 bucket as well as the S3 account id
What is Message invisibilty time out in SQS?
After a message is polled by a consumer it is invisible to other consumers for 30 seconds (default)
If message is not deleted during the timeout it returns to the queue
Hence, if a message is not processed and deleted during the time out, it will be processed twice
The ChangeMessageVisibilty API to increase time out from the consumer-side
too high timeout => slow processing
too small timeout => message is processed multiple times
What are Dead Letter Queues in SQS?
A threshold can be set on how many times a message is returned to the queue after timeout
After the MaximumReceives threshold is exceeded, the message is put into the dead letter queue
useful for debugging
make sure to process the messages before they expire
set retention to 14 days
What is a delay queue in SQS?
Delay a message up to 15 minutes until the consumers can see it
Default is 0 seconds
Can be set at queue level
Can override default on send using the DelaySeconds parameter
What is Long Polling in SQS?
When a consumer requests messags from a queue it can optionally wait until a message arrives
Reduces api calls made to the SQS queue, while improving latency and increasing efficiancy of the application
Wait times between 1 sec to 20 sec
Long Polling is preferred to Short Polling using WaitTimeSeconds
What is SQS Extended Client?
A java library to increase message size (256kb) up to 1 gb?
A small metadata message is sent to the queue that contains a pointer to the S3 bucket holding the big data
Hence, the large message is sent to and retrieved from S3
Usefule SQS API calls
CreateQueue (MessageRetentionPeriod), DeleteQueue
PurgeQueue: delete all messages in queue
SendMessage (DelaySeconds), ReceiveMessage, DeleteMessage
MaxNumberOfMessages: default 1, max 10 (for ReceiveMessage Api)
ReceiveMessageWaitTimeSeconds: Long Polling
ChangeMessageVisibility: change the message time out
Batch APIs for SendMessage, DeleteMessage, ChangeMessageVisibility help to reduce costs
What about the FIFO queue in SQS?
More ordering than in a standard queue
Limited Throughput: 300 msg/s without Batch, 3000 msg/s with batch
Exactly once-send capability, by deleting duplicates - feature of fifio queues
Messages are processed in order by the consumer
What is Deduplication in a FIFO queue?
If the same message arrives within 5 minutes, the second one is refused
Two methods:
Content-based Deduplication using a message hash with sha256
Explicilty provide a Message Deduplication ID
What is Message Grouping in a FIFO queue?
If the same value for MessageGroupID is provided then all of these messages will be processed by the same consumer in the order they appear
TO get a level of ordering for a subset of messages then use different values for MessageGroupID
Each Group id can have a different consumer
Ordering across groupd is not guaranteed
Maybe the total ordering of all messages is not needed, only consumer specific
What is AWS Simple Message Service SMS?
Want to send one message to many receivers
uses Pub/Sub
one topic posts to many subscribers
event producer sends messages to only one SNS topic
as many receivers as we want will listen to the SNS topic notifications
each subscriber to the topic will get all the messages (new filter is implemented)
up to 10 mil subs per topic
100k topics limit
Subscribers can be:
Lambda, SQS, Emails, HTTP/S, SMS messages, Mobile Notifications