Developing Solutions with Amazon SQS & SNS Flashcards

1
Q

What is Amazon SQS

A

Amazon Simple Queue Service (Amazon SQS) is a web service that gives you access to a message queue that can be used to store messages while waiting for a computer to process them.

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

What is the disadvantage of not having queue between producer and consumer

A

Interdependency between producer and consumer creates a tightly coupled system. The disadvantage with a tightly coupled system is that it is not fault tolerant. If any one component in our system fails, the entire system will fail.

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

what are the different queue types

A

Standard queues:
- More than one copy of a message might be delivered
- Messages may be delivered out of order

FIFO queues (First-In-First-Out):
- No duplicated messages
- Order is guaranteed
- Limited to 300 transactions per second

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

What is the visibility timeout

A

Period of time during which Amazon SQS prevents other consumers from receiving and processing the message. During this period, a message is invisible to the rest of your application after an application component gets it from the queue.

The default value is 30 seconds, max 12 hours.

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

SQS: When is message deleted?

A

Amazon SQS automatically deletes messages that have been in a queue for more than maximum message retention period.

When you receive the message, you must delete it from the queue to acknowledge that you processed the message and no longer need it.

To delete a message, you must provide the most recently received receipt handle when you request to delete the message

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

Difference between short polling and long polling

A

Short polling returns a response immediately, even if the queue being polled is empty. It’s the default behavior of Amazon SQS queues.

Long polling does not return a response until a message arrives in the queue, or the long poll times out. Unless the connection times out, the response to the ReceiveMessage request contains at least one of the available messages.
If you decide to implement long polling with multiple queues, we recommend that you use one thread for each queue

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

SQS : what are the main identifiers for queue & messages?

A
  • Queue URL
    When creating a new queue, you must provide a queue name that is unique within the scope of all your queues. Amazon SQS assigns each queue you create an identifier called a queue URL, which includes the queue name and other components that Amazon SQS determines.
  • Message ID
    For each message, Amazon SQS returns a system-assigned message ID in the SendMessage response
  • Receipt Handle
    Each time you receive a message from a queue, you receive a receipt handle for that message. If you receive a message more than once, each time you receive it, you get a different receipt handle.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the dead-letter queue

A

A dead-letter queue (DLQ) is an Amazon SQS queue that you configure to receive messages from other Amazon SQS queues, referred to as “source queues”. Typically, you set up a DLQ to receive messages after a maximum number of processing attempts has been reached. DLQ provides the ability to isolate messages that could not be processed.

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

SQS: How can we share a queue?

A

A developer associates an access policy statement (specifying the permissions being granted) with the queue to be shared.
Amazon SQS in each region is totally independent in message stores and queue names; therefore, the messages cannot be shared between queues in different regions.

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

SQS: How does the server-side encryption work?

A

Server-side encryption (SSE) encrypts the body of the message, but does not touch the queue metadata, the message metadata, or the per-queue metrics.
Adding encryption to an existing queue does not encrypt any backlogged messages. Similarly, removing encryption leaves backlogged messages encrypted.
You can use the AWS managed customer master key (CMK) which is unique for each customer and region, or you can create and manage your own keys.

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

Five Amazon SQS Use Cases

A
  • Work queues
    Decouple components of a distributed application that may not all process the same amount of work simultaneously.
  • Buffer and batch operations
    Add scalability and reliability to your architecture and smooth out temporary volume spikes without losing messages or increasing latency.
  • Request offloading
    Move slow operations off of interactive request paths by enqueuing the request.
  • Auto Scaling
    You can use Amazon SQS queues to help determine the load on an application, and when combined with Auto Scaling, you can scale the number of Amazon EC2 instances out or in, depending on the volume of traffic.
  • Fan-out
    Combine Amazon SQS with Amazon SNS to send identical copies of a message to multiple queues in parallel for simultaneous processing.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is Amazon SNS

A

Amazon Simple Notification Service (Amazon SNS) is a web service that makes it easy to set up, operate, and send notifications from the cloud. Amazon SNS follows the “publish-subscribe” (pub-sub) messaging paradigm, with notifications being delivered to clients using a “push” mechanism that eliminates the need to periodically check or “poll” for new information and updates.

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

Describe the use case Fan Out with SNS and SQS

A

In a fan-out scenario, an Amazon SNS message is sent to a topic and then replicated and pushed to multiple Amazon SQS queues, HTTP endpoints, or email addresses.
This allows for parallel asynchronous processing.
For example, you could develop an application that sends an Amazon SNS message to a topic whenever an order is placed for a product. Then, the Amazon SQS queues that are subscribed to that topic would receive identical notifications for the new order.

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

Describe SNS operation CreateTopic

A

The CreateTopic request creates a topic to which notifications can be published. Users can create a maximum of 3000 topics. This action is idempotent, so if the requester already owns a topic with the specified name, that topic’s ARN is returned without creating a new topic. The response from the CreateTopic request contains the Amazon Resource Name (ARN) of the created topic.

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

Describe SNS operation Subscribe

A

The Subscribe request prepares to subscribe an endpoint by sending the endpoint a confirmation message. To actually create a subscription, the endpoint owner must call the ConfirmSubscription action with the token from the confirmation message. Confirmation tokens are valid for three days. The response of the Subscribe request includes the ARN of the subscription, if the service was able to create a subscription immediately (without requiring endpoint owner confirmation)

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

Describe SNS operation ConfirmSubscription

A

The ConfirmSubscription request verifies an endpoint owner’s intent to receive messages by validating the token sent to the endpoint by an earlier Subscribe action. If the token is valid, the action creates a new subscription and returns its ARN. This call requires an AWS signature only when the AuthenticateOnUnsubscribe flag is set to “true“.

17
Q

Describe SNS operation DeleteTopic

A

The DeleteTopic request deletes a topic and all its subscriptions. Deleting a topic might prevent some messages previously sent to the topic from being delivered to subscribers. This action is idempotent, so deleting a topic that does not exist does not result in an error.

18
Q

Describe SNS operation Publish

A

Publish sends a message to all of a topic’s subscribed endpoints. When a messageId is returned, the message has been saved and Amazon SNS will attempt to deliver it to the topic’s subscribers shortly. The format of the outgoing message to each subscribed endpoint depends on the notification protocol selected.

19
Q

SNS: How can subscribers filter messages?

A

By default, a subscriber of an Amazon SNS topic receives every message published to the topic. To receive only a subset of the messages, a subscriber assigns a filter policy to the topic subscription. This feature simplifies the pub/sub messaging architecture by offloading the filtering logic from subscribers, as well as the routing logic from publishers, to SNS.
Amazon SNS message filtering now supports both numeric and string matching. Specifically, string matching operators allow for exact, prefix, and “anything-but” comparisons, while numeric matching operators allow for exact and range comparisons.

20
Q

Some technical characteristics of Amazon SNS

A
  • Each notification message contains a single published message.
  • A message cannot be deleted after it has been published.
  • Amazon SNS delivery policy can be used to control retries in case of message delivery failure.
  • Messages can contain up to 256 kB of data, including XML, JSON and unformatted text.
21
Q

How can we manage access to SNS

A

Amazon SNS integrates with AWS Identity and Access Management (IAM) so that you can specify which Amazon SNS actions a user in your AWS account can perform with Amazon SNS resources. You can specify a particular topic in the policy. For example, you could use variables when creating an IAM policy that gives certain users in your organization permission to use the Publish action with specific topics in your AWS account.
You use an IAM policy to restrict your users’ access to Amazon SNS actions and topics. An IAM policy can restrict access only to users within your AWS account, not to other AWS accounts.
You use an Amazon SNS policy with a particular topic to restrict who can work with that topic (for example, who can publish messages to it, who can subscribe to it). Amazon SNS policies can give access to other AWS accounts, or to users within your own AWS account.

22
Q

What is Amazon MQ

A

Amazon MQ is a managed message broker service for Apache ActiveMQ that makes it easy to set up and operate message brokers in the cloud. Message brokers allow different software systems–often using different programming languages, and on different platforms–to communicate and exchange information.

23
Q

Where is the storage of Amazon MQ

A

By default, Amazon MQ uses Amazon Elastic File System (Amazon EFS) for broker storage. To take advantage of low latency and high throughput, use Amazon Elastic Block Storage (Amazon EBS). To take advantage of low latency and high throughput, use Amazon Elastic Block Storage (Amazon EBS).