AWS的SQS和SNS有什么区别

SNS是分布式发布订阅系统。 当发布者将消息发送给SNS时,消息将被推送给订阅者。 SQS是分布式排队系统。 消息不会被推送到接收者。 接收方必须轮询SQS以接收消息。 多个接收器不能同时接收消息。 任何一个接收器都可以接收消息,处理并删除它。 其他接收器稍后不会收到相同的消息。 与SNS不同,轮询固有地在SQS中引入了一些消息传递延迟,其中消息被立即推送给订户。 SNS支持多个端点,如电子邮件,短信,http端点和SQS。 如果您想要未知的订户数量和类型来接收消息,则需要SNS

您不必总是将SNSSQS结合在一起。 除了SQS,您可以让SNS向电子邮件,短信或http端点发送消息。 将SNSSQS耦合具有优势。 您可能不希望外部服务与主机建立连接(防火墙可能会阻止从外部到主机的所有传入连接)。 你的终点可能会因为大量的消息而死亡。 电子邮件和短信可能不是您快速处理邮件的选择。 通过将SNSSQS耦合,您可以按照自己的节奏接收消息。 它允许客户端脱机,容忍网络和主机故障。 您也可以保证交货。 如果将SNS配置为将消息发送到http端点或电子邮件或SMS,则若干发送消息失败可能会导致消息被丢弃。

SQS主要用于解耦应用程序或集成应用程序。 消息可以在SQS中存储很短的时间(最多14天)。 SNS向几个订户分发了几个消息副本。 例如,假设您要将应用程序生成的数据复制到多个存储系统。 您可以使用SNS并将此数据发送给多个订阅者,每个订阅者将收到的消息复制到不同的存储系统(s3,主机上的硬盘,数据库等)。

What is the difference between Amazon SNS and Amazon SQS? – Stack Overflow

SNS is a distributed publish-subscribe system. Messages are pushed to subscribers as and when they are sent by publishers to SNS. SQS is distributed queuing system. Messages are NOT pushed to receivers. Receivers have to poll SQS to receive messages. Messages can’t be received by multiple receivers at the same time. Any one receiver can receive a message, process and delete it. Other receivers do not receive the same message later. Polling inherently introduces some latency in message delivery in SQS unlike SNS where messages are immediately pushed to subscribers. SNS supports several end points such as email, sms, http end point and SQS. If you want unknown number and type of subscribers to receive messages, you need SNS.

You don’t have to couple SNS and SQS always. You can have SNS send messages to email, sms or http end point apart from SQS. There are advantages to coupling SNS with SQS. You may not want an external service to make connections to your hosts (firewall may block all incoming connections to your host from outside). Your end point may just die because of heavy volume of messages. Email and SMS maybe not your choice of processing messages quickly. By coupling SNS with SQS, you can receive messages at your pace. It allows clients to be offline, tolerant to network and host failures. You also achieve guaranteed delivery. If you configure SNS to send messages to an http end point or email or SMS, several failures to send message may result in message being dropped.

SQS is mainly used to decouple applications or integrate applications. Messages can be stored in SQS for short duration of time (max 14 days). SNS distributes several copies of message to several subscribers. For example, lets say you want to replicate data generated by an application to several storage systems. You could use SNS and send this data to multiple subscribers, each replicating the messages it receives to different storage systems (s3, hard disk on your host, database, etc.).

此条目发表在aws分类目录,贴了, , 标签。将固定链接加入收藏夹。

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注