Тёмный

Design A Scalable Notification System | System Design 

Code with Irtiza
Подписаться 12 тыс.
Просмотров 36 тыс.
50% 1

Build a scalable notification system using a microservice architecture, message queues and relational and non relational databases.
We start with a basic functioning version of the sysstem and then start adding things on top to make the system more scalable. We talk through the different tradeoffs when picking different technologies too.
System Design Playlist: • System Design Beginner...
0:00 Final Design Teaser
0:35 What are Notifications?
2:15 Basic System Design
9:36 First Database
10:30 Scalability Problems
13:20 Message Queues
15:50 Lightweight Consumers / Workers
18:00 Notifications Database
21:00 MySQL vs Cassandra
22:20 Failed Notifications
24:30 System Design Summary
27:30 Future Videos
#systemDesign #programming #tech #tutorial
Visit me at: irtizahafiz.com
Reach me at: irtizahafiz9@gmail.com

Опубликовано:

 

4 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 84   
@dyeyyuen5837
@dyeyyuen5837 Год назад
This is gold! A lot of pointers included! I'll definitely share it to my team.
@irtizahafiz
@irtizahafiz 7 месяцев назад
Thank you! Glad you found it valuable.
@Imrohanroy
@Imrohanroy 11 месяцев назад
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 11 месяцев назад
One more thing, how would the upstream get to know about the status of the notification? What would be the api structure?
@irtizahafiz
@irtizahafiz 7 месяцев назад
Those are some great suggestions! Thank you!
@venkatasriharsha4227
@venkatasriharsha4227 6 месяцев назад
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
@prabaljain5462
@prabaljain5462 5 месяцев назад
I really liked the way you have simplified the things.
@emmsdan
@emmsdan 11 месяцев назад
Solid tutorial, great lecture
@user-bs1ck6sc3s
@user-bs1ck6sc3s Год назад
This video is perfect. Thank you very much!
@irtizahafiz
@irtizahafiz 8 месяцев назад
Glad you found it helpful!
@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.
@jonathanhle
@jonathanhle Год назад
Man - you're awesome.
@GrowwithAyansh
@GrowwithAyansh Год назад
Wow, excellent piece of knowledge. Thanks a lot!
@irtizahafiz
@irtizahafiz Год назад
My pleasure!
@deepjyotkaurbindra
@deepjyotkaurbindra Год назад
Beautifully explained, thanks!! Subscribed for more such quality content.
@irtizahafiz
@irtizahafiz 7 месяцев назад
Thank you for the feedback!
@zemmouriyassine3802
@zemmouriyassine3802 Год назад
Amazing ❤
@chitranshugupta2615
@chitranshugupta2615 Год назад
Great video bro , teaching complex thing in easy way
@irtizahafiz
@irtizahafiz Год назад
Glad you liked it
@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.
@venkatasriharsha4227
@venkatasriharsha4227 6 месяцев назад
Great video pal. I easily related it with my work in my company.
@irtizahafiz
@irtizahafiz 6 месяцев назад
Glad you enjoyed it!
@uzoo6000
@uzoo6000 2 года назад
I watched this again.. very good video.
@irtizahafiz
@irtizahafiz 2 года назад
Thank you again!
@sabuein
@sabuein 3 месяца назад
Thank you.
@irtizahafiz
@irtizahafiz 2 месяца назад
You're welcome!
@thoughtworks1984
@thoughtworks1984 2 года назад
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 года назад
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?
@rick-kv1gl
@rick-kv1gl Год назад
ur channel is so underrated. liked & subd
@irtizahafiz
@irtizahafiz 7 месяцев назад
Thank you! Glad you found it valuable.
@vijaybabaria3253
@vijaybabaria3253 2 года назад
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.
@rahulvaish3034
@rahulvaish3034 3 месяца назад
More like Software architecture, less System design, but loved watching it. Thanks
@irtizahafiz
@irtizahafiz 2 месяца назад
Glad you liked it!
@adelekebright2490
@adelekebright2490 10 месяцев назад
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 8 месяцев назад
Might still need to retry later, otherwise, it's clogging up the queue.
@irtizahafiz
@irtizahafiz 7 месяцев назад
You don't want to rely on the queue as a source of truth. Queues are designed for immediate processing, not permanent storage.
@kushangowda
@kushangowda 7 месяцев назад
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 7 месяцев назад
That's a great suggestion!
@basheeral-momani2032
@basheeral-momani2032 9 месяцев назад
19:07 can we not acknoledge the message unless is consume it properly? instead of the table?
@firezdog
@firezdog 3 месяца назад
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?)
@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 Год назад
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.
@rahul_singh_rajput3292
@rahul_singh_rajput3292 8 месяцев назад
great example ❤🔥 Query -> For a celebrity user who has millions of followers, will the approach be the same ?
@irtizahafiz
@irtizahafiz 8 месяцев назад
Depends on whether you are thinking of "incoming notifications" to the celebrity user or "outgoing" to all the followers of the celebrity.
@divyanshubajpai2560
@divyanshubajpai2560 Год назад
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 8 месяцев назад
yes we need some kind of prioritization
@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 7 месяцев назад
I can consider making a video about message queues on Django in the future.
@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 Год назад
Yup that's a good abstraction too!
@shkshk8482
@shkshk8482 9 месяцев назад
Thank you for a very helpful tutorial. Should there be a one queue per user/connection?
@FreakStyler
@FreakStyler 8 месяцев назад
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 8 месяцев назад
@@FreakStyler Thank you, how do I send different messages to each user?
@lokeshchouhan4227
@lokeshchouhan4227 Год назад
Hi Irtiza, how response will be handled for success and retry exceeds ?
@irtizahafiz
@irtizahafiz 7 месяцев назад
I am not sure I understand. Could you elaborate?
@kamalnathlp4415
@kamalnathlp4415 Год назад
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 Год назад
You want to batch up the messages in that case for better performance.
@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 года назад
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...
@kaleemullahnizamani7436
@kaleemullahnizamani7436 2 года назад
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 года назад
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
@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.
@ihtasham9237
@ihtasham9237 Год назад
Great video! Btw isn't the notification service a single point of failure?
@irtizahafiz
@irtizahafiz Год назад
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
@Nitinmehra1994
@Nitinmehra1994 Год назад
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!
@ganeshbankar5953
@ganeshbankar5953 8 месяцев назад
Why Cafe , table , tree and Subscribe button taking 30% screen space. It is difficult to see the diagram.
@irtizahafiz
@irtizahafiz 8 месяцев назад
Appreciate the feedback! I was trying out a few things, but turns out this was a horrible idea, haha. I stopped adding those.
@firezdog
@firezdog 3 месяца назад
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 2 месяца назад
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.
@poonam-kamboj
@poonam-kamboj 10 месяцев назад
Background music is annoying 😭 please remove it
@irtizahafiz
@irtizahafiz 8 месяцев назад
Thank you for the feedback! Many people said the same. I have removed it since.
@uzoo6000
@uzoo6000 2 года назад
I requested u on LinkedIn. I need to ask you a question about notification design
@irtizahafiz
@irtizahafiz 2 года назад
Hopefully our discussion helped you out : )
Далее
Designing Notifications Service for Instagram
37:18
Просмотров 65 тыс.
Introduction to Payment Systems | System Design
40:56
Design A Scalable Rate Limiter | System Design
24:32
Просмотров 10 тыс.
System Design Interview - Notification Service
25:11
Просмотров 248 тыс.
Design Twitter - System Design Interview
26:16
Просмотров 464 тыс.
How Razorpay scaled their notification system
17:32
Просмотров 19 тыс.