Mehran
Mehran

Reputation: 16821

Can I use SNS for a server side Pub/Sub?

Right now I'm using Redis for Pub/Sub pattern on my server-side application. Moving to AWS, I was wondering if SNS can satisfy the same requirements.

As far as I've read so far, SNS is implementing the same pattern but it's a little strange. All the documentation I've found assume that the subscriber is a client layer application (email, sms, mobile app etc.) while I was hoping to use SNS solely for server side.

One strange part of the SNS that I've faced so far is that there's an unsubscribe method! To me, once you stop subscribing, you won't be getting messages and there's no need to unsubscribe anything. But when I see an unsubscribe method it makes me think that in this Pub/Sub the publisher attempts to make the connection each time there's a new message to deliver. Which is totally different from what I am looking for where the connection is kept alive for the subscriber to be able to receive messages. Could someone please confirm this?

Can someone please point me to an example subscribing to a topic using a server-side javascript (node) code?

Upvotes: 2

Views: 3058

Answers (1)

Matt Houser
Matt Houser

Reputation: 36043

For a server-side pub/sub pattern, where your servers are coming and going (like in an Auto Scaling scenario), SNS is not a good service to use. Unsubscribing is an issue with SNS and connections are not persisted.

Instead, you should stick with using Redis for your pub/sub. You can use AWS ElastiCache for your Redis server(s) in order to use AWS services.

Upvotes: 3

Related Questions