其他分享
首页 > 其他分享> > [AWS - DA] AWS Integration & Messaging: SQS, SNS

[AWS - DA] AWS Integration & Messaging: SQS, SNS

作者:互联网

SQS

Cusming Messages

 

Multi EC2 instance consumers + Auto Sscaling Group (ASG)

If you have lots of Queue message, we can scale consumers horizontally to imporve throughput of processing.

We can use CloudWatch Metric to check `ApproximateNumberOfMessages` in the queue, if it is larger than a number, will fire an Alarm by CloudWatch Alarm, it will trigger Consumers' ASG to increase the numbers of EC2 instance to consume the message.

 

Security

 

SQS Queue Access Policy

In first case, we want to allow an EC2 instance in another AWS account to poll the message from the queue. It wirtes `Principal` of another AWS account id, allow to perform `action` of `sqs:ReceiveMessage` and queue which is itself in the `Resouce`.

 

Second case, we want to allow another AWS service to `sqs:sendMessage` to the queue. Condition should match S3's arn and S3's own account id; Resouce should be the queue itslef.

 

Visibility Timeout

 

Dead Letter Queue

 

Delay Queue

 

WaitTimeSeconds can esaily be set in console

1-20 seconds for long polling

 

If your message is larger than 256KB, use Extended Client, which will send your mesage to S3 and metadata to SQS, then consumer can pull the data from S3.

The same partten used by DynamoDB, the limit in DyanmoDB is 400kb.

 

ReceiveMessageWaitTimeSeconds by default is 0: short polling, if we set to 1-20 seconds, then it is longer polling.

 

The name has to be `<name>.fifo`, if you don't end with `.fifo`, it will not be a FIFO queue.

 

SQS FIFO - Deduplication

FIFO can do `content hashing`, for example if you send `hello world` content twice, the first time content will be hashed. Second time, becaseu the content is the same, it will be ingored.  Or you can provide `MessageDeDuplicationID`, if two times, the id is same, then second will be ignored.

 

Message Grouping

 

SNS

 

Fan Out partten

Why has to ues Fan Out?

If one event source only trigger one action.. then we don't need Fan out

But If one event source trigger multi actions..then we need Fan out.

For example, S3 Object created event want to trigger two Queue and one Lambda, we need to use Fan out.

 

Message Filting

For the same topic, we contain lots of information which multi subscribers only interested in part of it. 

Then we can apply filtering in SNS 

 

Protocol

 

标签:queue,SQS,AWS,Integration,Queue,will,S3,message
来源: https://www.cnblogs.com/Answer1215/p/14842507.html