This article is participating in the “Network protocol must know must know” essay contest

directory

preface

The body of the

SQS

​SNS

The difference between the two

The connection between the two

preface

When it comes to SQS and SNS, everyone wants Amazon’s SQS and SNS, and it’s true that Amazon came up with the original definition. In fact, we can talk about SQS and SNS separately from the specific vendor.

The body of the

In general, SQS and SNS are two distributed solutions for message queues proposed by Amazon. More or less, we can borrow many of the best ideas. Next, INTRODUCE SQS and SNS respectively.

SQS

SQS is a distributed message queue service proposed by Amazon. After receiving tasks or messages, the queue service will not actively send them to the client. In order to perform these tasks and obtain such information, the client must actively poll the message queue service. In this way, different clients can perform corresponding operations according to their query tasks and messages, and finally call back the execution results, so as to achieve a distributed system.

​SNS

SNS is a distributed publish-subscribe message service proposed by Amazon. When publishers send messages to the message service, the message service will push the message to the corresponding subscribers. The subscriber (client) receives the message and then performs the corresponding operation, and finally calls back the execution result, thus realizing the distributed system.

The difference between the two

As for the differences between SQS and SNS, here is a simple table.

1. The real time

The former is poor, which requires queuing when there are too many messages, while the latter is better, which can ensure the real-time transmission of messages when there are enough subscribers.

2. Service policy complexity

The former is simple, while the latter is complex and needs to deal with the task scheduling problem.

3. How the client obtains messages

The former polling actively, the latter waiting to be pushed.

4. How the server processes messages

The former is placed in a message queue for polling by the client. The latter actively pushes to subscribers.

The connection between the two

When it comes to the connection between SQS and SNS, in fact, the two can be used together in many scenarios, taking the advantages of each mode and implementing different strategies in different scenarios to ensure the stability and real-time performance of services.

About the author: Hello everyone, I am Data-Mining (Liuzhen007), an audio and video technology enthusiast. I have worked for traditional broadcasting giants and audio and video Internet companies before and after. I have rich experience in audio and video live broadcast and vod, and have a very deep understanding of WebRTC, FFmpeg and Electron. Public account: play audio and video. Also CSDN blog expert, Huawei cloud community cloud sharing expert, signed the author, welcome to pay attention to me to share more dry goods!