oharlem
oharlem

Reputation: 1010

Selecting message queue approach for multiple consumers in AWS

Please help selecting a MQ app/system/approach for the following use-case:

Check for incoming messages for a specific user -> read the message if available -> delete from the queue, ideally, staying within AWS.

Context:

I'm in AWS. Initially thought of SQS, but the more I read the less it looks like a good match - cannot set message recipient ID in a way to filter by recipient, etc, however maybe I'm wrong. One of the options I also thought about is to just use DynamoDB's "messages" table, partition key being userId and sort key being a messageId, thus I'll be able to easily query by a user, however concerned with costs.

If possible, I would much more prefer to stay within AWS or at least use SAAS like SQS, as being a 1-person startup I really want to avoid headaches supporting self-hosted system.

Thank you! D

Upvotes: 0

Views: 224

Answers (1)

ketan vijayvargiya
ketan vijayvargiya

Reputation: 5659

You are right on both these counts:

  • SQS won't work, because of the limitation you pointed.
  • DynamoDB would work, but cost a lot.

I can suggest the following:

  • Create a Redis cluster, possibly on Amazon ElastiCache.
  • In it, make one List per user.
  • Whenever a new message comes, append it to concerned User's list.
  • To deliver the message, just read from the User's list. Also, flush the queue if needed.

What I am suggesting is very similar to how Twitter manages each User's news-feed and home-feed.

It should also be cheap.

Upvotes: 1

Related Questions