1

I have a requirement to design a notification system for multi-user(~1000 users) application, here are the high level requirements.

  1. System event gets triggered on specific operations.
  2. On event trigger, individual notification for all(or sometimes only for relevant) users gets generated and stored in database.
  3. While user logs in, all unread notifications for him will be pulled and displayed in ui.
  4. While user reads the notification, we capture the read status.
  5. A scheduler in background evicts all the stale notifications.

This seems like a very typical use case and straight forward to implement with the database.

But my doubt is, is there any way we can replace the Database with the Queue based messaging system? The reason I think this way is because, the use case I have seems like asynchronous in nature(like events, notifications and timely eviction of messages).

While I replace the Database with Queues, the first 2 points from above fits well, but on later part I have some doubts -

  1. In General, are queues flexible to store and query notifications based on user ids ?

  2. Consider this scenario - Notifications gets generated and stored in the queue, and the user is not logged in, what is the best way to handle consumer messages.

    a. Should the consumer constantly listen for the messages ?, If so should the messages be stored in application memory(does not seems to be good option) ?

    b. Or the consumers should be created for each users dynamically on user login? Is this a regular pattern ?

Any other recommended ways ?

Thanks

Yuvaraj G
  • 111
  • 2
  • Although durable queues might be an option the question is how the system will behave in case of a sudden outage. I doubt it will be possible to recover or notifications in case you'll employ queues for this task. – Bohdan Stupak Sep 23 '20 at 15:23
  • @BohdanStupak, Thanks for replying. Yes, outage is also a concern, since our current approach is not to deploy the services independently(app, queue and everything will be in single box), the chances of queue service alone going down is comparatively less, but yes we have deal with it. The questions I posted above are something more fundamental, looking to get clarified on those and then take a call. – Yuvaraj G Sep 23 '20 at 18:25

0 Answers0