I'm building an infrastructural service with my team. We are building a service that will help other teams in our org send out a notifications to end users when certain events occur. We are currently having an issue agreeing on which service should be listening to occurrences of these events to then trigger a corresponding notification. Maybe I can give an example using Instagram (IG) for relevancy.

Imagine the scenario where one person A follows person B in IG. The requirement here would be to notify person B of this event via a notification. Most likely, there is some sort of "Follower" service that exists as a source of truth for this information. So my question here is, whom should listen in to the "person A followed person" event?

Option 1. One perspective is let the Follower service listen in on its own event and then trigger a side effect by calling the notification service to tell it to explicitly notify person B. The Follower service is aware of the domain event and its the domain that should dictate whom should be notified.

Option 2. Another perspective is to allow the notification service to listen on these events and to send out the notification itself. It would be responsible for interpreting the event and understand whom should be the person that should be reached.

Which of the two perspectives do you think makes sense for scalability?

  • I would choose option 1 for several reasons, but since you specifically ask about scalability, I don’t think it matters. With the info available, both options would scale equally well.
    – Rik D
    Commented Jul 21, 2022 at 20:27
  • can you expand on the "why". I know both would technically work. But i'm looking for rationale
    – alaboudi
    Commented Jul 21, 2022 at 21:11
  • Is scalability really your main concern though? Are we really talking about IG scale here with thousands of notifications per second?
    – Rik D
    Commented Jul 21, 2022 at 22:01
  • It sounds like you are considering "orchestration" vs "choreography", and trying to decide which is a better fit for your system? Commented Jul 22, 2022 at 12:34
  • @VoiceOfUnreason Pretty much. But, I'm also trying to understand choreography makes sense for something that is a horizontal slice (i.e infrastructure services like the notification service in question). Would you get your Email service to subscribe to events? or should those be explicitly called
    – alaboudi
    Commented Jul 22, 2022 at 16:56


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.