Amazon SQS Flashcards

1
Q

SQS

A

Amazon Simple Queue Service (SQS) is a distributed queue system that enables web service applications to quickly and reliably queue messages that one component in the application generates to be consumed by another component.

Amazon SQS enables you to send, store, and receive messages between software components.

An Amazon SQS queue is a temporary repository for messages that are awaiting processing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

The SQS queue resolves issues …. What Issue ?

A

The SQS queue resolves issues that arise if the producer is producing work faster than the consumer can process it, or if the producer or consumer are only intermittently connected to the network.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Message Size ?

A

Messages are up to 256KB in size.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Message Retention Period

A

Messages can be kept in the queue from 1 minute to 14 days.

The default retention period is 4 days.

SQS guarantees that your messages will be processed at least once.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Default Retention Period

A

The default retention period is 4 days.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Two Types of Queues

A

tandard queues and FIFO queues.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Queue names must be unique within a region ? T/F

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Standard Queue Facts

A

Default queue type.

Nearly unlimited transactions per second.

Guarantee that a message is delivered at least once.

Occasionally more than one copy of a message might be delivered out of order.

Provides best-effort ordering which ensures that messages are generally delivered in the same order as they are sent.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

FIFO Facts

A

Delivers exactly-once processing.

The order in which messages are sent and received is strictly preserved and a message is delivered once and remains available until a consumer processes and deletes it.

Duplicates are not introduced into the queue.

FIFO queues also support message groups that allow multiple ordered message groups within a single queue.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

TPS on FIFO Queues

A

Limited to 300 transactions per second (TPS) but have all the capabilities of standard queues.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Sequencing with FIFO queues Steps

A

To ensure strict ordering between messages, specify a MessageGroupId.

Messages with a different Group ID may be received out of order.

Messages with the same Group ID are delivered to one consumer at a time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is FIFO Message Group ID:

A

The tag that specifies that a message belongs to a specific message group. Messages that belong to the same message group are guaranteed to be processed in a FIFO manner.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is Message Deduplication ID:

A

The token used for deduplication of messages within the deduplication interval.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Standard Queue VS FIFO Queue

A

Standard QueueFIFO Queue

Unlimited Throughput:

Standard queues support a nearly unlimited number of transactions per second (TPS) per API action.High Throughput:

FIFO queues support up to 300 messages per second (300 send, receive, or delete operations per second). When you batch 10 messages per operation (maximum), FIFO queues can support up to 3,000 messages per second

Best-Effort Ordering:

Standard queues Occasionally, messages might be delivered in an order different from which they were sentFirst-ln-First-out Delivery:

FIFO queues The order in which messages are sent and received is strictly preserved

At-Least-Once Delivery: Standard queues A message is delivered at least once, but occasionally more than one copy of a message is delivered

FIFO queues Exactly-Once Processing: A message is delivered once and remains available until a consumer processes and deletes it. Duplicates are not introduced into the queue

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Visibility timeout

A

The amount of time a message is invisible in the queue after a reader picks it up.

Provided the job is processed before the visibility timeout expires, the message will then be deleted from the queue.

If the job is not processed within the visibility timeout, the message will become visible again and another reader will process it.

This could result in the same message being delivered twice.

The default visibility timeout is 30 seconds.

Increase it if your task takes >30 seconds.

The maximum is 12 hours.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

SQL Polling Techniques

A

SQS uses short polling and long polling.

17
Q

what is long polling ?

A

Long polling doesn’t return a response until a message arrives in the message queue or the long poll times out.

Long polling can be enabled at the queue level or at the API level using WaitTimeSeconds.

Long polling is in effect when the Receive Message Wait Time is a value greater than 0 seconds and up to 20 seconds.

18
Q

Short Polling Facts

A
  • Does not wait for messages to appear in the queue.
  • It queries only a subset of the available servers for messages (based on weighted random execution).
  • Short polling is the default.
  • ReceiveMessageWaitTime is set to 0.
  • More requests are used, which implies higher cost.
19
Q

Long polling Facts

A
  • Uses fewer requests and reduces cost.
  • Eliminates false empty responses by querying all servers.
  • SQS waits until a message is available in the queue before sending a response.
  • Requests contain at least one of the available messages up to the maximum number of messages specified in the ReceiveMessage action.
  • Shouldn’t be used if your application expects an immediate response to receive message calls.
  • ReceiveMessageWaitTime is set to a non-zero value (up to 20 seconds).
  • Same charge per million requests as short polling.
20
Q

Dead-Letter Queue

A

The main task of a dead-letter queue is handling message failure.

A dead-letter queue lets you set aside and isolate messages that can’t be processed correctly to determine why their processing didn’t succeed.

Messages are moved to the dead-letter queue when the ReceiveCount for a message exceeds the maxReceiveCount for a queue.

Dead-letter queues should not be used with standard queues when your application will keep retrying transmission.

Dead-letter queues will break the order of messages in FIFO queues.

21
Q

SQS Delay Queues

A

A delay queue postpones delivery of new messages to a queue for a number of seconds.

Messages sent to the Delay Queue remain invisible to consumers for the duration of the delay period.

Default delay is 0 seconds, maximum is 900 seconds (15 minutes).

22
Q

When to use delay queues ?

A

Large distributed applications which may need to introduce a delay in processing.

You need to apply a delay to an entire queue of messages.

For example, adding a delay of a few seconds to allow updates to sales or stock control databases before sending a notification to a customer confirming an online transaction.

23
Q

Lambda with SQS

A

You can use an AWS Lambda function to process messages in an Amazon Simple Queue Service (Amazon SQS) queue.

Lambda event source mappings support standard queues and first-in, first-out (FIFO) queues.

Lambda polls the queue and invokes your Lambda function synchronously with an event that contains queue messages.

Lambda reads messages in batches and invokes your function once for each batch.

When your function successfully processes a batch, Lambda deletes its messages from the queue.

24
Q

SQS Extended Client

A

You can use Amazon S3 and the Amazon SQS Extended Client Library for Java to manage Amazon SQS messages.

Useful for storing and consuming messages up to 2 GB in size.

You can use the Amazon SQS Extended Client Library for Java library to do the following:

  • Specify whether messages are always stored in Amazon S3 or only when the size of a message exceeds 256 KB.
  • Send a message that references a single message object stored in an Amazon S3 bucket.
  • Get the corresponding message object from an Amazon S3 bucket.
  • Delete the corresponding message object from an Amazon S3 bucket.
25
Q

SQS Monitoring

A

CloudWatch is integrated with SQS and you can view and monitor queue metrics.

CloudWatch metrics are automatically collected every 5 minutes.

CloudWatch considers a queue to be active for up to 6 hours if it contains any messages or if any API action accesses it.

No charge for CloudWatch (no detailed monitoring).

CloudTrail captures API calls from SQS and logs to a specified S3 bucket.

26
Q

SQS Security

A

You can use IAM policies to control who can read/write messages.

Authentication can be used to secure messages within queues (who can send and receive).

SQS is PCI DSS level 1 compliant and HIPAA eligible.

In-flight security is provided using HTTPS.

Can enable server-side encryption (SSE) using KMS.

Can set the CMK you want to use.

SSE only encrypts the message body not the message attributes.

IAM policy must allow usage of SQS.

You can also specify permissions in an SQS queue access policy:

  • Providers finer grained control.
  • Control over the requests that come in.
27
Q

Amazon SQS API’s, you should know for EXAM

A

CreateQueue (aws sqs create-queue):

DeleteQueue (aws sqs delete-queue):

PurgeQueue (aws sqs purge-queue):

SendMessage (aws sqs send-message):

ReceiveMessage (aws sqs receive-messsage):

DeleteMessage (aws sqs delete-message):

ChangeMessageVisibility (aws sqs change-message-visibility):

28
Q

Amazon SQS API - Batch

A

To reduce costs or manipulate up to 10 messages with a single action, you can use the following actions:

  • SendMessageBatch
  • DeleteMessageBatch
  • ChangeMessageVisibilityBatch