Design A Scalable Notification System | System Design

Поделиться
HTML-код
  • Опубликовано: 5 сен 2024

Комментарии • 85

  • @Imrohanroy
    @Imrohanroy Год назад +10

    The design is neat and crisp. And I think with little more consideration it would become awesome. I have some suggestions,
    1. Notification Microservice is still SPOF. You can add multi instance with a multi LB config
    2. You could have used a DLQ for failed messages as we can set replay interval directly. You don't need a schedular here as it would introduce additional complexity.
    3. Payload could have the user info as most notification services are internal services which wouldn't allow exposing any sensitive information outside. And if any sensitive information required you can have another internal service to provide those. This way we can decouple each services.
    4. For priority messages you can have separate worker group.

    • @Imrohanroy
      @Imrohanroy Год назад

      One more thing, how would the upstream get to know about the status of the notification?
      What would be the api structure?

    • @irtizahafiz
      @irtizahafiz  9 месяцев назад +2

      Those are some great suggestions! Thank you!

    • @venkatasriharsha4227
      @venkatasriharsha4227 8 месяцев назад

      We use unique Id while sending it to the email/SMS services. And there will be a status scheduler which fetches message status based on uid@@Imrohanroy

  • @dyeyyuen5837
    @dyeyyuen5837 Год назад +5

    This is gold! A lot of pointers included! I'll definitely share it to my team.

    • @irtizahafiz
      @irtizahafiz  9 месяцев назад

      Thank you! Glad you found it valuable.

  • @thoughtworks1984
    @thoughtworks1984 2 года назад +3

    Thanks .. very useful video.. 2 suggestions I know everyone has their own way to design but I have 2 following sessions 1) When messages are read from the queue like (SQS) you can set visibility timeout and if worker fail to send notification it is back in the queue when message visibility time out is expired. 2) Rather than ruing CRON job for failed notification and again reading DB we can add DLQ to our main queue and another micro service or lambda can reprocess failed notifications that way we can avoid another trip to DB and decouple more . But at the end very nicely presented and very good content not just this video but all others as well.

    • @irtizahafiz
      @irtizahafiz  2 года назад +1

      Those are some fantastic ideas! Thanks for sharing!
      Glad you found the video helpful and checked out some other ones too. Stay tuned for more system design videos coming up : )

    • @user-eq4oy6bk5p
      @user-eq4oy6bk5p 2 года назад

      I think it's still good to store all the notification history in the database for auditing purposes.

    • @mukulb82
      @mukulb82 Год назад

      Regarding the second suggestion of using DL queue, will the failure in case exception which occurred after messages has been read (but any processing failed later, lets say to email user) can be also put back in the DL queue to be reprocessed?

  • @adelekebright2490
    @adelekebright2490 Год назад +2

    Nice video, I think using SQL table to store the state of the notification makes your system more complex and redundant.
    The workers can communicate with the queue in acknowledging message delivery success.
    So, if a message was delivered successfully, it can be dropped from the queue, else it would still be retained in the queue.
    Updating your table for each message is therefore not necessary.

    • @FreakStyler
      @FreakStyler 10 месяцев назад

      Might still need to retry later, otherwise, it's clogging up the queue.

    • @irtizahafiz
      @irtizahafiz  9 месяцев назад

      You don't want to rely on the queue as a source of truth. Queues are designed for immediate processing, not permanent storage.

  • @chitranshugupta2615
    @chitranshugupta2615 2 года назад +4

    Great video bro , teaching complex thing in easy way

  • @kushangowda
    @kushangowda 10 месяцев назад

    Great video, One suggestion.
    Instead of messaging queue we can use Amazon SQS and use error handling efficiently. When message is pulled we can set inflight time to reappear after sometime and if not processed we can move to DLQ.

    • @irtizahafiz
      @irtizahafiz  9 месяцев назад

      That's a great suggestion!

  • @rahulvaish3034
    @rahulvaish3034 5 месяцев назад

    More like Software architecture, less System design, but loved watching it. Thanks

  • @prabaljain5462
    @prabaljain5462 7 месяцев назад

    I really liked the way you have simplified the things.

  • @sunjayroska7391
    @sunjayroska7391 2 года назад

    This is very helpful for the development of our Capstone Project. Thank you for the information.

    • @irtizahafiz
      @irtizahafiz  2 года назад

      Eyy that's awesome! It always makes me super happy to hear that. Hope the other videos help you too. Good luck on the Capstone project!

  • @user-mf1tg6df4k
    @user-mf1tg6df4k 2 года назад

    This video helps me!
    I was just about to consider a notification service architecture.

    • @irtizahafiz
      @irtizahafiz  2 года назад

      Glad you found value! Let me know if you have any feedback.

  • @venkatasriharsha4227
    @venkatasriharsha4227 8 месяцев назад

    Great video pal. I easily related it with my work in my company.

  • @firezdog
    @firezdog 5 месяцев назад

    Agree with others that a new SQL table for message status might lead to a lot of complications. It seems like it could lead to concurrency issues (how is work being reassigned? what issues might come up if there are races between the workers' updates from the progress table and the service's reads from that table?)

  • @vijaybabaria3253
    @vijaybabaria3253 2 года назад +1

    Thanks for keeping these designs simple to understand. When you get a chance, would you pls make video for zoom system design? (After you settle at your new place you are moving to) … thanks a lot

    • @irtizahafiz
      @irtizahafiz  2 года назад

      YES! I do have a Zoom System design in my backlog. I think it’s like the 7th video coming up.

  • @GrowwithAyansh
    @GrowwithAyansh Год назад +1

    Wow, excellent piece of knowledge. Thanks a lot!

  • @rahul_singh_rajput3292
    @rahul_singh_rajput3292 10 месяцев назад

    great example ❤🔥
    Query -> For a celebrity user who has millions of followers, will the approach be the same ?

    • @irtizahafiz
      @irtizahafiz  10 месяцев назад

      Depends on whether you are thinking of "incoming notifications" to the celebrity user or "outgoing" to all the followers of the celebrity.

  • @user-bs1ck6sc3s
    @user-bs1ck6sc3s Год назад

    This video is perfect. Thank you very much!

    • @irtizahafiz
      @irtizahafiz  10 месяцев назад +1

      Glad you found it helpful!

  • @uzoo6000
    @uzoo6000 2 года назад

    I watched this again.. very good video.

  • @emmsdan
    @emmsdan Год назад

    Solid tutorial, great lecture

  • @deepjyotkaurbindra
    @deepjyotkaurbindra Год назад

    Beautifully explained, thanks!! Subscribed for more such quality content.

    • @irtizahafiz
      @irtizahafiz  9 месяцев назад

      Thank you for the feedback!

  • @rick-kv1gl
    @rick-kv1gl Год назад

    ur channel is so underrated. liked & subd

    • @irtizahafiz
      @irtizahafiz  9 месяцев назад

      Thank you! Glad you found it valuable.

  • @nicolasoliveira6827
    @nicolasoliveira6827 2 года назад

    Thank you for this very helpful video

    • @irtizahafiz
      @irtizahafiz  2 года назад

      You are welcome! I hope you stay subscribed and get more value out of the channel.

  • @sabuein
    @sabuein 5 месяцев назад

    Thank you.

  • @divyanshubajpai2560
    @divyanshubajpai2560 Год назад +1

    How we will handle notifications related to transactions such as OTP ? For this scenario, I think we need some prioritization in the message queue

    • @kalpeshmali8498
      @kalpeshmali8498 10 месяцев назад +1

      yes we need some kind of prioritization

  • @jonathanhle
    @jonathanhle 2 года назад

    Man - you're awesome.

  • @zemmouriyassine3802
    @zemmouriyassine3802 Год назад

    Amazing ❤

  • @areshbabu
    @areshbabu 2 года назад

    Awesome presentation and easy to understand. I have a question. How to ensure notification is not lost when the notification microservice goes down before it pushes to the message queue? Thanks alot for the video

    • @irtizahafiz
      @irtizahafiz  2 года назад +1

      Glad you enjoyed the video : )
      To do that, you would need to keep track of notifications in some persistent storage before even hitting the notification microservice.
      But I would suggest, instead just focus on keeping the notification microservice highly available by horizontally scaling.

  • @user-eq4oy6bk5p
    @user-eq4oy6bk5p 2 года назад

    Should we have a message queue for each type of notification? For example, if email service is offline then message queues for SMS or push notifications won't be affected by it.

    • @irtizahafiz
      @irtizahafiz  2 года назад

      Yup that's a good abstraction too!

  • @shkshk8482
    @shkshk8482 11 месяцев назад

    Thank you for a very helpful tutorial. Should there be a one queue per user/connection?

    • @FreakStyler
      @FreakStyler 10 месяцев назад +1

      No the queues are not related to users.
      You would have one queue in total for your workers. Or you could have one queue per type of message.

    • @shkshk8482
      @shkshk8482 10 месяцев назад

      @@FreakStyler Thank you, how do I send different messages to each user?

  • @kaleemullahnizamani7436
    @kaleemullahnizamani7436 2 года назад +1

    Share these ppt so easy to revise later otherwise hard to retain details and rewatching same video is not the most optimal thanks

    • @irtizahafiz
      @irtizahafiz  2 года назад +1

      Hi! Thanks for the feedback. I will go ahead and add the slide deck / notes in the description from my next video.
      For now, hopefully the chapters and timestamps will help you move around a bit easier.

    • @kaleemullahnizamani7436
      @kaleemullahnizamani7436 2 года назад

      Thanks and also add these slides for previous video too including this notification service, rate limiter etc

  • @basheeral-momani2032
    @basheeral-momani2032 11 месяцев назад

    19:07 can we not acknoledge the message unless is consume it properly? instead of the table?

  • @yahyamlaouhi9508
    @yahyamlaouhi9508 Год назад

    Thanks for your explination,i want to know how can you implement a message queue using django i wish if you can give precise answer with exemples

    • @irtizahafiz
      @irtizahafiz  9 месяцев назад

      I can consider making a video about message queues on Django in the future.

  • @uzoo6000
    @uzoo6000 2 года назад

    Question - Why do you need the user info in the database? Why can't the client send all the info through the payload?
    If you have the user database with user info.. What is the client sending in the payload? Also do we need a service that stores the template ?

    • @irtizahafiz
      @irtizahafiz  2 года назад +2

      Sure the client can send all the information through the payload. Depends on how complex your notifications are.
      Usually, you don't want to transmit the sensitive user information across the network every single time you send a notification. Also, in terms of performance, it makes sense to store some kind of a materialized view of user data in the service if you use it regularly.
      You can store the templates in your notification service, unless you have super complex template logic.

    • @uzoo6000
      @uzoo6000 2 года назад

      @@irtizahafiz Thanks Much...

  • @ganeshbankar5953
    @ganeshbankar5953 11 месяцев назад

    Why Cafe , table , tree and Subscribe button taking 30% screen space. It is difficult to see the diagram.

    • @irtizahafiz
      @irtizahafiz  10 месяцев назад

      Appreciate the feedback! I was trying out a few things, but turns out this was a horrible idea, haha. I stopped adding those.

  • @ihtasham9237
    @ihtasham9237 Год назад

    Great video! Btw isn't the notification service a single point of failure?

    • @irtizahafiz
      @irtizahafiz  Год назад +1

      You will have multiple instances of the notification service running to handle scale.

    • @nehapurohit684
      @nehapurohit684 Год назад

      Why did you choose not to scale stateless micro service and instead mentioned that worker should be scaled

  • @lokeshchouhan4227
    @lokeshchouhan4227 Год назад

    Hi Irtiza, how response will be handled for success and retry exceeds ?

    • @irtizahafiz
      @irtizahafiz  9 месяцев назад

      I am not sure I understand. Could you elaborate?

  • @selimdogan3482
    @selimdogan3482 Год назад

    If we want store all notifications what will happen if we send all users. Let's say we have 10000 users and we will send 10000 message each how we should keep this in database, is it not too much?

    • @irtizahafiz
      @irtizahafiz  Год назад

      That's not too much. You can easily keep that information in any database you want.

  • @firezdog
    @firezdog 5 месяцев назад

    i'm immediately thinking: "we're storing emails and other personal contact information -- how are we going to address security and legal concerns?"

    • @irtizahafiz
      @irtizahafiz  4 месяца назад

      Yeah, that's something to always think about. I don't think the intention of this design was to dive deep into compliance/legal stuff.

  • @kamalnathlp4415
    @kamalnathlp4415 2 года назад

    Let us take scripts wanna to send push notification to 10k users, did the notification microservice need to create a batch of message or single message?

    • @irtizahafiz
      @irtizahafiz  2 года назад

      You want to batch up the messages in that case for better performance.

  • @AkhileshKumar-li6me
    @AkhileshKumar-li6me 10 дней назад

    Nice video, but 30% of the screen is wasted.

  • @Nitinmehra1994
    @Nitinmehra1994 2 года назад

    Excellent presentation but I want to discuss something related to the Database as you have mentioned Mysql, in this scenario, it will scale vertically and which will make things slower as the data grows so we have to do sharding for horizontal scaling but that will lead to a lot of maintenance and also increase in cost.
    But if we use the NoSQL database we get the horizontal scaling but we compromise with the JOINS of RDBMS. Because of that, we might end up iterating unnecessary data because we can't filter the data at the DB level, which will again make the process slower.
    So which database will be best suited for the notification system, is there any other approach to tackle this issue or do we just have to trade off one feature over another?
    Thanks!

  • @poonam-kamboj
    @poonam-kamboj Год назад

    Background music is annoying 😭 please remove it

    • @irtizahafiz
      @irtizahafiz  10 месяцев назад

      Thank you for the feedback! Many people said the same. I have removed it since.

  • @uzoo6000
    @uzoo6000 2 года назад +1

    I requested u on LinkedIn. I need to ask you a question about notification design

    • @irtizahafiz
      @irtizahafiz  2 года назад

      Hopefully our discussion helped you out : )