我有一个用例,将有数据流到来,我不能以相同的速度消费它,需要一个缓冲区。这可以使用SNS-SQS队列来解决。我后来才知道,Kinesis解决了同样的目的,所以有什么不同?为什么我应该喜欢(或不应该喜欢)运动?


当前回答

从表面上看,它们有点相似,但是用例将决定哪种工具是合适的。在我看来,如果你可以使用SQS,那么你应该——如果它能做你想做的事情,它会更简单、更便宜,但这里有一个来自AWS FAQ的更好解释,它给出了两个工具的适当用例示例,以帮助你决定:

常见问题的

其他回答

从表面上看,它们有点相似,但是用例将决定哪种工具是合适的。在我看来,如果你可以使用SQS,那么你应该——如果它能做你想做的事情,它会更简单、更便宜,但这里有一个来自AWS FAQ的更好解释,它给出了两个工具的适当用例示例,以帮助你决定:

常见问题的

对我来说,最大的优势是Kinesis是一个可重玩的队列,而SQS不是。因此,您可以有多个Kinesis的相同消息的消费者(或在不同时间的相同消费者),而在SQS中,一旦消息被ack,它就从队列中消失了。 因此,SQS更适合工作者队列。

In very simple terms, and keeping costs out of the picture, the real intention of SNS-SQS are to make services loosely coupled. And this is only primary reason to use SQS where the order of the msgs are not so important and where you have more control of the messages. If you want a pattern of job queue using an SQS is again much better. Kinesis shouldn't be used be used in such cases because it is difficult to remove messages from kinesis because kinesis replays the whole batch on error. You can also use SQS as a dead letter queue for more control. With kinesis all these are possible but unheard of unless you are really critical of SQS.

如果你想要一个好的分区,那么SQS将不会有用。

Kinesis用例

日志和事件数据收集 实时分析 移动数据采集 “物联网”数据馈送

SQS用例

应用程序集成 解耦microservices 将任务分配给多个工作节点 将实时用户请求与密集的后台工作分离 批处理消息以供将来处理

定价模型是不同的,因此根据您的用例,一种或另一种可能更便宜。使用最简单的情况(不包括SNS):

SQS对每个消息收费(每个64 KB算作一个请求)。 Kinesis对每个分片每小时收费(一个分片最多可以处理1000条消息或1 MB/秒),也对您放入的数据量收费(每25 KB)。

考虑到当前的价格,不考虑免费级别,如果您以最大消息大小每天发送1gb的消息,Kinesis的成本将远远高于SQS (Kinesis每月10.82美元,SQS每月0.20美元)。但如果你每天发送1tb, Kinesis会稍微便宜一些($158/月vs. SQS $201/月)。

详细信息:SQS每百万请求收费0.40美元(每次64 KB),因此每GB收费0.00655美元。以每天1gb计算,每月不到0.20美元;按每天1tb计算,每月的费用略高于201美元。

Kinesis charges $0.014 per million requests (25 KB each), so $0.00059 per GB. At 1 GB per day, this is less than $0.02 per month; at 1 TB per day, it is about $18 per month. However, Kinesis also charges $0.015 per shard-hour. You need at least 1 shard per 1 MB per second. At 1 GB per day, 1 shard will be plenty, so that will add another $0.36 per day, for a total cost of $10.82 per month. At 1 TB per day, you will need at least 13 shards, which adds another $4.68 per day, for a total cost of $158 per month.