1

Say I want to send emails to users.

  • When users sign up for an account they get an email.
  • When they complete an order they get an email.
  • When they receive a message they get an email.

My hunch is that a event Fanout is a good approach to use here. Say I have multiple SNS topics e.g. orders, users, messages. Each topic has their respective events e.g. order_created, user_created, message_created.

My question is which one to choose:

  1. Create a single queue that subscribes to all of these topics with an attached worker that will send the appropriate email based on the event
  2. Create a separate queue for each of these topics where the attached worker only sends a specific email

I am having a hard time identifying obvious pros / cons. Also more generally what are scenarios where you would have one queue subscribe to multiple topics vs multiple queues each subscribed to a single topic.

Thanks!

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
delisdeli
  • 839
  • 9
  • 20

1 Answers1

3

Here are my pros and cons for the two options that you have listed.

Single queue for multiple topics

Pros

  • Less components that needs to be monitored
  • Better resource utilization if the individual topics have not too many messages

Cons

  • If one topic can have a lot more messages than others then it can cause delay for other topics' messages
  • It is easier to reach the max messages / queue quota with a single queue
  • If the queue becomes temporarily unreachable then none of the message types processing can advance

Dedicated queue per topic

Pros

  • One queue could be setup as FIFO while others as standard
    • Different settings can be used for each queue (like: retention period, maximum message size, etc.)
  • Easier to introduce different workers for different queues if the increased load requires that
    • Also you can scale up and down different workers based on the different queues' length

Cons

  • If you introduce more and more message types then the number of topics, queues and workers can impose some maintenance burden on you
  • It is harder to correlate two messages from different topics
Peter Csala
  • 17,736
  • 16
  • 35
  • 75