WHATSAPP System Design: Chat Messaging Systems for Interviews

Sdílet
Vložit
  • čas přidán 30. 06. 2024
  • The Whatsapp system architecture is a common system design interview question. This interview question asks us to select a set of features like sending chat messages, read receipts, group messaging and last seen visibility.
    The chat system must be scalable and have other non functional requirements like message ordering, retrial, idempotency, load balancing and image sharing.
    Recommended system design video course:
    interviewready.io
    Along with video lectures, this course has architecture diagrams, capacity planning, API contracts and evaluation tests. It's a complete package.
    Use the coupon code 'earlybird' for a 20% discount!
    Check out the other system design videos on the channel here:
    • System Design for Begi...
    References:
    Designing Data-Intensive Applications - amzn.to/2yQIrxH
    spectrum.ieee.org/tech-talk/c...
    highscalability.com/blog/2014/...
    highscalability.com/blog/2014/...
    Tinder video - • System Design: TINDER ...
    System Design Playlist - • System Design for Begi...
    Load balancer - • What is LOAD BALANCING...
    Consistent Hashing - • What is CONSISTENT HAS...
    Message Queues - • What is a MESSAGE QUEU...
    Messaging idempotency and ordering - • System Design - Messag...
    Chapters
    00:00 Requirement Setting
    02:35 Image storage
    03:07 System Design
    15:00 Load balancer
    21:00 Consistent Hashing
    21:55 Message Queues
    23:05 Messaging idempotency and ordering
    #SystemDesign #DesignWhatsapp #gkcs
    You can follow me on:
    LinkedIn: / gaurav-sen-56b6a941
    Instagram: / applepie404
    Quora: www.quora.com/profile/Gaurav-...
    GitHub: github.com/coding-parrot

Komentáře • 1,2K

  • @gkcs
    @gkcs  Před rokem +15

    You can watch more system design videos here: interviewready.io

    • @architkapoor2503
      @architkapoor2503 Před 5 dny

      Gaurav, there is one thing you missed discussing here. How is the service-to-service communication bidirectional here. Gateway and Sessions are also peer-to-peer. But perhaps, that can achieved via gRPC, or again through web-sockets, or asynchronously through an event bus.
      Great if you can clarify.

  • @louis-ericsimard7659
    @louis-ericsimard7659 Před 5 lety +1809

    Hi Gaurav, I have been a developer for 43 years and a system architect for 30. As a very experienced professional all I can say is: good work ! You are the real deal.

    • @gkcs
      @gkcs  Před 5 lety +88

      Thank you Louis! 😁

    • @BackToBackSWE
      @BackToBackSWE Před 5 lety +34

      nice

    • @jawwadismail9419
      @jawwadismail9419 Před 4 lety +5

      @@BackToBackSWE r u real?

    • @umangmalhotra1222
      @umangmalhotra1222 Před 3 lety +4

      @@jawwadismail9419 Apparently Yes.

    • @judisjeevan4908
      @judisjeevan4908 Před 3 lety +34

      43 years..!!!! wtf..which language did you use..what kind of developer you have been..? World wide web just came into existence on 1989.

  • @zippytyro
    @zippytyro Před 5 lety +346

    I learn more on CZcams than school !!

    • @gkcs
      @gkcs  Před 5 lety +11

      Yey!

    • @dailyupdates7282
      @dailyupdates7282 Před 4 lety +1

      Learn from pune University
      It is very tough
      Very difficult subjects

    • @developerforcloud1478
      @developerforcloud1478 Před 4 lety +4

      Lately i started seeing so many posts all over saying "I learn more on youtube than school/college" No, need to demotivate young generation. They cannot teach you system design in school, this is specialization, not general subjects like PCM. Even in kinder garden, they teach kids about movement of hands to write, ultimately at home parents have to help kids in practice. We cannot expect nursey schools to teach kids writing.

    • @marioleon86
      @marioleon86 Před 3 lety +1

      That is a fact. I said the same 8 years ago in some countries the quality of contents in university is really poor, so when you discover youtube is a tool for learning you agree with this sentence

    • @headoverbars8750
      @headoverbars8750 Před 3 lety

      I would say by now that is true for me as well and I have a college education

  • @ashishchourasia2830
    @ashishchourasia2830 Před 3 lety +13

    I don't know anything about system design or even what it is, yet I clicked the video and watched it full. Just understood everything, great teaching skills :)

  • @asurakengan7173
    @asurakengan7173 Před 3 lety +84

    This was great. A minor nitpick, this is not what peer to peer means although it can be confusing. Peer to peer would mean apart from one time registration, the connection never touches your server and instead is established directly between 2 clients(friends on whatsapp). Also HTTP now has server push and whatsapp actually uses XMPP(slightly modified).

  • @maggiemu4650
    @maggiemu4650 Před 4 lety +22

    I really amazed by how good you are at explaining complex concept in such a simple way. I can just keep watching all your video. Great job! ❤️

  • @kushagrak960
    @kushagrak960 Před 4 lety +24

    CZcams recommendation, thank you so much for this gem

  • @varunmahanot5766
    @varunmahanot5766 Před 4 lety +439

    occasions like good morning in India putting a lot of pressure on the servers🤣🤣

  • @yaraye5397
    @yaraye5397 Před 4 lety +4

    One thing I really like about your video is that you always tried to explain things from the client side, which makes it highly understandable for us as clients in our daily life. Thanks for your video!

  • @GaneshAcharyaAnEngineer
    @GaneshAcharyaAnEngineer Před 5 lety +65

    Great video, this kind of stuff is not easy to learn and not enough resources out to explain. Thank you for your great efforts

    • @gkcs
      @gkcs  Před 5 lety

      Glad to help 😁

  • @clinton11994
    @clinton11994 Před 4 lety +11

    I watched other videos on messaging systems and this video has a very detailed approach, I was hunting for videos just to know how to have multiple servers for socket processes when the client is a mobile app and I feel this video has helped me a lot with that.

    • @theverybestdev
      @theverybestdev Před 3 lety +1

      @@SK18459 you both didn't post anything yet

  • @svgi1210
    @svgi1210 Před 4 lety +11

    Age and experience doesn't matter to achieve, you proved it bro

  • @rajchoudhary4349
    @rajchoudhary4349 Před 4 lety +27

    well narrated and presented. never knew whatsapp and tinder has so much thing at backend. interesting when you ask someone for a coffee. and she accepts the coffee invitation. both are important sugar in coffee and web sockets and the micro services. lol. Hats off. truly brilliant .

  • @abhisheknair_music
    @abhisheknair_music Před 4 lety +38

    These videos clearly shows how far away are university syllabuses from the real-world problems

    • @ImEli2215
      @ImEli2215 Před 21 dnem +1

      4 years ago and your comment is still valid today.

  • @ammarshareef462
    @ammarshareef462 Před 5 lety +7

    Yet another great video on system design! Keep up the good work, also now I can watch in 1080p YAY!

  • @suthan2003
    @suthan2003 Před 3 lety

    I really like the way he smiles and teaches. I know nothing about systems but that smile alone made me comfortable to watch the video......keep the same passion my friend......

  • @inasuma8180
    @inasuma8180 Před 2 lety

    i'm interviewing this week for systems design for the first time in my 6 year career. this isn't part of my job. but here i am, learning an irrelevant (to me anyway) skill to be better at tech interviews. thanks for sharing!

  • @BiancaAguglia
    @BiancaAguglia Před 5 lety +5

    Yours are some of the most helpful videos I've come across. Thank you for doing such a wonderful job.

    • @gkcs
      @gkcs  Před 5 lety +1

      Thank you!

  • @hridayeshsharma1058
    @hridayeshsharma1058 Před 2 lety +13

    12:43 Now I understand why my gf would still show online for sometime even after we have sent goodnight messages. 😂😂

  • @F1mus
    @F1mus Před 4 lety +250

    Hey man, nice video, but there's a mistake: long polling is not polling every minute to get updates. Long polling is when you keep an HTTP request open (think: spinner in Chrome while the page is loading) forever, until the server decides to respond. This in effect makes it near real-time. It's one of the ways websockets work.

    • @puru.gupta901
      @puru.gupta901 Před 2 lety +5

      He meant Ajax polling probably, a lot of people refer to normal polling as long polling

    • @RaghvendraSinghIIITA
      @RaghvendraSinghIIITA Před 2 lety +3

      I was going to mention the same. Major problem in long polling is that if the amount of data on server is too much then you need to keep creating the new paginated requests. But otherwise for small push messages long polling works well.

    • @shilashm5691
      @shilashm5691 Před rokem

      Yes, if he is worried about sending messages from server to client. He can use Server Side events

    • @kobew1351
      @kobew1351 Před rokem

      long polling still requires client to send a request first, in this case websocket works the best. or a custom protocol on top of tcp also ok.

    • @joshuakoehler6457
      @joshuakoehler6457 Před 4 měsíci

      Yep, he meant to say *short* polling.

  • @miafar7212
    @miafar7212 Před rokem

    I'm from a non technical background and this video was super helpful and clear. On a side note, "Check with your doctor if group messaging is right for you" - hilarious :'D

  • @user-oy4kf5wr8l
    @user-oy4kf5wr8l Před 4 lety +8

    This video is awesome! Hoping I can find a good job after months of watching ur videos again and again! Thx! U r amazing!

    • @gkcs
      @gkcs  Před 4 lety +1

      Thank you!

    • @shobhitsingh7735
      @shobhitsingh7735 Před 3 lety

      Have you got the job?

    • @user-oy4kf5wr8l
      @user-oy4kf5wr8l Před 3 lety

      @@shobhitsingh7735 i got other thing in priority last year. but now i will have microsoft interview for sde2 in 1/2 weeks......... jesus.....so now i am reviewing everything...

    • @mahendramungamuru9500
      @mahendramungamuru9500 Před 2 měsíci

      @@user-oy4kf5wr8l got placed buddy ?

  • @kartik180rajesh1
    @kartik180rajesh1 Před 4 lety +48

    You're really underrated in the developer circle. People need to watch all this a lot more than programming basics.

    • @varunmanjunath6204
      @varunmanjunath6204 Před 3 lety +5

      He doesn't have enough videos .plus partial knowledge. Although he us very good

  • @faysoufox
    @faysoufox Před 4 lety

    Nice, I like the fact that you put links to other videos for reference, this makes it easy for the audience.

  • @dieddzaandam
    @dieddzaandam Před 2 lety +12

    Great video! About the 'last seen' feature: I don't think the Last Seen is based on the last activity (e.g. sending a chat) but rather when the user closed the connection to whatsapp. So in my opinion, as soon as 1) the network is interrupted or 2) the user closes the application, the 'last seen' should be updated.

    • @shenth27
      @shenth27 Před rokem +3

      It should be updated as well when the user comes online and every 10 or 15 secs. So simple health probing from the app to the gateway should work

  • @charlieporciuncula3300
    @charlieporciuncula3300 Před 3 lety +12

    Dude! As a beginner, I'm mind blown! Subscribed!

  • @abhijit-sarkar
    @abhijit-sarkar Před 9 měsíci +9

    Having sat in FAANG interviews both as an interviewer and as a candidate, I can say that this is not going to hold up for someone interviewing for a senior position.If you have less than 5-7 years of experience, you may get away with some hand waving, but for 10+ years, we want to see more depth. Some of the users have already brought up questions like delivery of offline messages, which is a basic feature missing. Apart from that, there are some crucial things missing in this video:
    1. **API**: You want to discuss basic API (like REST) design, verbs supported, payload etc. You don't need to spend 30 minutes creating a JSON schema, but mention the endpoints and what's being sent and received. This matters for latency, and for some advanced things like security, API versioning, bandwidth usage etc.
    2. **Back of the envelope calculations**: This is important for scalability, availability and storage. How many daily active users? Is there a limit to the message size? (you probably don't want people dropping 5 GB pirated movies in a group). How many gateway servers do you need? How long are the messages stored? Do you need to shard the DB? What is your partition key, and how do you deal with hot partitions?
    3. Most importantly, **offer alternative design options and discuss trade offs**. If you can only talk about one thing, then you most likely learned it from some blog/video/whatever. There's no perfect solution in system design, so, we want to know you can think out of the box, and why you are choosing to go one way or the other.

    • @YeetYeetYe
      @YeetYeetYe Před 7 měsíci

      Yeah there is A LOT missing here. Like.. A LOT

    • @anchalsharma0843
      @anchalsharma0843 Před 3 měsíci

      thanx Abhijit! This comments gives me an idea of what else to think of rather than taking a fixed approach. If you could suggest some resources/or just general advice to me for preparing sys design, i'd really appreciate it. (I've 2 yrs of exp )

  • @cmdaltctr
    @cmdaltctr Před rokem

    I found your channel randomly and I was so grateful, thank you so much.

  • @TheOriginalDonPablo
    @TheOriginalDonPablo Před 5 lety +5

    I have hit the like button. I have subscribed. You are awesome!. So happy I found your channel.

  • @adamhughes9938
    @adamhughes9938 Před 3 lety +34

    interview: "ya I'd have a lst seen microservice". Reality: "ok just add that as a function in your monolith we don't have time for a new service"

    • @gkcs
      @gkcs  Před 3 lety +7

      Exactly! I've seen this happen in real life 🙈😂

  • @michaelgaines6320
    @michaelgaines6320 Před 3 lety

    Great job as always! Thank you for actually enjoying what you are explaining.

  • @venkatasundararaman
    @venkatasundararaman Před 2 lety

    Wonderful video which covers all the technical concepts involved. This is incomplete without any resource estimates like storage/bw and what kind of stores to use like a Key/Value store like etcd will work etc.

  • @ankushmaheshwari
    @ankushmaheshwari Před 2 lety +13

    Good video! Would have liked even more if you had included following points as well becuase I felt lost there.
    1. How does the gateway manage the TCP connections for each user? Is it in memory or in external store? What happens to the clients connection and messages when the gateway goes down?
    2. How does the session service talks to gateway? Is it using RPC or message passing etc?

    • @ankitjain6787
      @ankitjain6787 Před rokem

      Same question

    • @aditya.chandel
      @aditya.chandel Před rokem

      1. A map of userId and its corresponding connection object is stored in the chat server's (gateway) memory/RAM. If a gateway goes down then all of the online clients connected to the effected gateway will loose their websocket connection, but quickly they will make a new connection to the another functioning gateway.

  • @RicardoSilvaTripcall
    @RicardoSilvaTripcall Před 5 lety +7

    Amazing content, kudos from Brazil !!!

    • @gkcs
      @gkcs  Před 5 lety

      Thank you!

  • @parthasud624
    @parthasud624 Před 4 lety

    Great work!!!! Many thanks for putting all this together, Gaurav!

  • @arghamaz
    @arghamaz Před 4 lety +1

    Brilliant communication skills and very good English accent... great job keep it up

  • @samyakjain6698
    @samyakjain6698 Před 3 lety +10

    You did a great job of listing the microservices and interaction between them. One thing which I would like to know more is the database design. How do we maintain a system with so many chats each with thousands of messages growing over time.

    • @DebajyotiDev
      @DebajyotiDev Před 2 lety +1

      Once WhatsApp successfully sends a message to B, they will delete it from their end and save whatever to your GDrive / iCloud. They do not store billions of messages. N.B: I don’t work in whatsapp.

    • @aditya.chandel
      @aditya.chandel Před rokem

      A moderately sized server can maintain around 25k-35k simultaneous TCP connections, so a single server can serve about 25k-35k users (assuming that every user uses just one client). And to handle the ever-growing user base there no option other than adding more physical servers.

  • @ashishupadhyay3368
    @ashishupadhyay3368 Před 5 lety +3

    I wish there was a 100 like button for the video, thanks Gaurav. You've been an inspiration for me in cracking Amazon in 2018 placements. :)

    • @gkcs
      @gkcs  Před 5 lety

      Congratulations Ashish!
      Thanks for the feedback 😎
      P.S. You could be a channel member now if you like 😉

    • @gkcs
      @gkcs  Před 5 lety

      It's explained by me here :D
      gkcsblog.wordpress.com/2018/11/06/gaurav-sen-channel-memberships/

  • @nootics
    @nootics Před 5 lety +2

    I'm happy that I know what the most important part of programing is which is what you just showed, and not the writing part. It's the pen and paper part that matters.
    This really satisfies my superiority complex

  • @pradeeppradyumna601
    @pradeeppradyumna601 Před 3 lety

    Kudos to you Gaurav. Your contents are always easy n straight forward to grasp. Thank you for making life better

  • @Cyborg1170
    @Cyborg1170 Před 2 lety +4

    Thank you Sir. I moved from India to San Antonio as new college grad. Amazon offering me 500K per year. Excited. Thanks for video.

  • @vijaybabaria3253
    @vijaybabaria3253 Před 4 lety +4

    thanks for the amazing contents, brother.. another topic suggestion is system design for payment processing system like venmo or paypal

  • @siddheshswnt
    @siddheshswnt Před 5 lety +1

    Thankfully I came across this channel. Really awesome videos and explained in easy way. Keep up the great work!

    • @gkcs
      @gkcs  Před 5 lety

      Thank you!

  • @chrisburd9751
    @chrisburd9751 Před 3 lety +1

    Excellent video - as a former data architect from JP Morgan Chase looking to expand their knowledge for social applications - excellent.

    • @gkcs
      @gkcs  Před 3 lety +1

      Thank you 😁

  • @shoban2090
    @shoban2090 Před 5 lety +3

    Your system design videos are excellent! very easy to understand when comparing to others. It would be great if you explain multiple recursion(more than one recursive call in a function). I've reffered some online resources but It looks more confusing. I know you could make it easy to understand :)

    • @gkcs
      @gkcs  Před 5 lety +2

      I'll add this to my list of videos to do 😁

    • @shoban2090
      @shoban2090 Před 5 lety

      Wow! Thanks Gaurav 😊

  • @kaushalkishore9792
    @kaushalkishore9792 Před 3 lety +15

    Good work. There are a few important topics worth covering though.
    1. What happens to a message sent to an offline user.
    2. What choices of storage do we have ?
    3. What kind of load + image/video messages ?

    • @unmeshchougule5666
      @unmeshchougule5666 Před rokem

      I believe the 1st point is already covered by him, the message is stored in queue/db.

    • @aditya.chandel
      @aditya.chandel Před rokem

      1. All messages are stored in the database. Once the receiver comes online, receiver's client application checks with the chat server if the receiver has any pending messages that he/she should receive. If there are, then those messages are delivered to the user's client application via websocket.
      2. A wide column database like HBase will be good for this use-case (i.e. lots of small messages with very low relation).
      3. I didn't understand what you mean here. For storing images and videos we should make use of CDNs.

    • @kobew1351
      @kobew1351 Před rokem

      for no.1 , the answer depends on how you "persist" the messages. In case of queues, a pull request can suffice as all messages in the queues are "pending to be delivered". The trouble (if it's indeed a trouble) would be how you should manage such a big amount of queues (e.g. one queue per friend pair). however if messages are stored in db, there has to be information like "what's the oldest message that client A hasn't received yet ?". this is so that message order can be retained, And more questions come like how sharding/partitioning is done...etc

  • @anirudhrowjee1378
    @anirudhrowjee1378 Před 5 lety +1

    Great one! Thank you for these videos. I'm in class 11 now, and I learn a lot from these videos.

    • @gkcs
      @gkcs  Před 5 lety +1

      Wow, awesome time to start!

  • @LettersByPooja
    @LettersByPooja Před 4 lety +1

    Bang on! the tech depth, the teaching style. extra +1 for making the learner think. Great video. Thanks Gaurav

  • @PradeepMahato007
    @PradeepMahato007 Před 3 lety +9

    Great Video, Helpful !!
    I feel the 'Last Seen' feature could be improved (based on the steps described in the video). The only shortcoming I see with the current approach is, 'What if the user replies a message (i.e an action taken by the user) from the notification directly without opening the application !!'. One approach could be if a flag is sent in the request { 'fromNotif': true } that could be used to determine to decide if the Last_Seen table needs to be updated. Another could be to use the WebSocket connection itself and using the disconnect callback (once the user gets out of the application, the WebSocket connection can be disconnected). Push Notification can be used to update the message count once the user is outside an application and more approaches could be formulated further. Nevertheless, your video does help for beginners in system design.👍

  • @anurag3487
    @anurag3487 Před 5 lety +11

    Great video brother...There seems to be fluctuations in the room lights where in you're recording...
    Subscribed

    • @gkcs
      @gkcs  Před 5 lety +3

      Will keep that in mind, thanks!

  • @chandanadas7860
    @chandanadas7860 Před 4 lety +2

    Found CZcams recommendations today. Great video indeed.

  • @ramamurthikumar3116
    @ramamurthikumar3116 Před 5 lety +2

    Thank you so much for the video. The best part I liked is, you asked us prior, which is the next video to be uploaded. Thanks again.
    Just take care of voice modulation in the video next time :)

    • @gkcs
      @gkcs  Před 5 lety

      Thanks! I forgot to record the microphone for that time, so had to make do with the camera audio 😛

  • @susheelmadwani
    @susheelmadwani Před 5 lety +5

    @Gaurav: Man I envy you, you are a gem explaining the complex things.
    I have 1 basic question: As we are using websockets for communication, don't we require not million but thousands of servers to connect billions of users ??
    If you can help me understand this part can help a lot.

    • @deepbrar6152
      @deepbrar6152 Před 4 lety +2

      I don't think WhatsApp uses WebSockets. A traditional method to scale this kind of application is using telecom technologies such as Jabber or core ErLang.

    • @bhavikgarg5662
      @bhavikgarg5662 Před 4 lety

      @@deepbrar6152 Yes Whatsapp uses EJabbered which is implemented in ErLang

    • @adamhughes9938
      @adamhughes9938 Před 3 lety +1

      I also am confused here. If A and B are both connected to the server, is the websocket connection direct between A and B or is it still going through the server?

    • @nehadalvi409
      @nehadalvi409 Před 3 lety +1

      @@adamhughes9938 I think the websocket connection is between both A and the server and also between B and the server.

  • @riazbacchus3962
    @riazbacchus3962 Před 5 lety +3

    dude you are the man.

  • @parashararamesh4252
    @parashararamesh4252 Před 5 lety

    Great video Gaurav , really makes sense when it's broken down . I would say one key takeaway at least for me is that whenever a specific microservice/ component has too much on it's plate to handle you delegate that additional burden to another microservice. Wish people could be like that sometimes in real life😂

    • @gkcs
      @gkcs  Před 5 lety

      Hahaha, thanks Parashara!
      We can always try and delegate though :P

  • @adambright5416
    @adambright5416 Před 2 lety

    And here I am, looking at some guy teaching IT things I should probably know already... Thanks :D

  • @iitgupta2010
    @iitgupta2010 Před 5 lety +7

    Hi Gaurav, Great video
    few suggestions;
    1. Keeping too many gateway would kill you latency [or may be I'm overthinking] but if we have some services which basically authenticate and establish the web socket connection, there after other services which work as mediator and communicate back-n-forth with client then we can simply reduce the number of gateway we need. [ essentially the gate would do this, but we don't need as many gateway as client are there; imagine 50 million clients at a time on whatsApp]
    2. We should not stick with only push mechanism, where you said that "server will keep trying to to send the message to B" instead here it should be pull technique should be use. What I. mean is, once a user successfully establish the connection to Chat server, it AsK "do you any thing for me" and server response back (through queue technique so that message order are persisted ) and then after its all push technique until same thing happen for different user
    This way we keep server doing less and redundant work, to keep checking. Again think about 50 million user there. on Percent, 0.01% [5K users at least] of them chat each other. then there would be very high number of user might not be online, and for that server keep trying.
    3. We don't need to keep checking in server database for where the user is, we should cache them. That may be 50 million entries at max at a time.
    As soon as the user goes off, remove him [ make sure the app should send the right information, don't send that when user just stack the application and will come back in a minute or so. it should be only when there is no internet connected.] In the essence, the connection would be of two types {1. active 2. ideal- help to build last seen too} when connection is ideal, we can utilise the connection for other chat and as soon as the user receive a message then we'll either create a new (if that connection goes off) or use the same.
    This is trade off you see, making a new connection is costly but keeping lot of the ideal is also poor.
    incase , if we mark offline the user who is connected to internet, we'll lost real time communication.

    • @shivujagga
      @shivujagga Před 2 lety

      For point 2 - Notification service and chat-service will be push, whereas, first time client connection would be pull.

    • @shubhimohta8488
      @shubhimohta8488 Před 2 lety

      If first time client connection is pull, will that not create an overhead as client can connect disconnect too frequently due to unstable internet connection or is that acceptable?

    • @kobew1351
      @kobew1351 Před rokem

      no,2 makes sense when queues are in place or messages themselvs are persisted somewhere in database (so that a select can be performed).
      for no.1 a server box likely can only handle a few millions at most, so for whatsapp scale, several tens of gateways will be needed.

    • @kobew1351
      @kobew1351 Před rokem

      @@shubhimohta8488 that should be fine, 1. for most users, connections are there for some time. 2. the payload over a pull is generally not very big and is acceptable .

  • @dinotumu
    @dinotumu Před 4 lety +5

    This is just that amazing video I was looking for. Regarding de-priotising, there is this feature called broadcast messages in whatsapp which I presume is used to send messages like "happy new year" etc. Can you tell me if I am right?

  • @shashankcool
    @shashankcool Před 4 lety

    Hi Gaurav,
    Thanks for sharing videos on system design.
    You explain very well.
    God bless you and keep sharing such great videos.

  • @michaeldang8189
    @michaeldang8189 Před 4 lety

    Making educational video in a happy mode desires a big thumb up!

  • @Gualcm
    @Gualcm Před 5 lety +10

    I love you man, I used this to get an offer in my interview today.

    • @gkcs
      @gkcs  Před 5 lety +2

      Congratulations!

    • @vikrant4666
      @vikrant4666 Před 5 lety +6

      u wrote same thing under facebook system design video

    • @dasamlan9874
      @dasamlan9874 Před 3 lety

      @@vikrant4666 whatsapp is owned by fb, right?

  • @junko78
    @junko78 Před 4 lety +4

    Hi Gaurav!! Thank you for educating me with all your awesome videos!
    I have a request for a video! Can you talk about building a cloud-native system? Things like what's the benefit of using cloud and where we should be careful when designing a system. Also, as Hadoop is dying recently, I feel like some of the solutions are out-dated. For example, HDFS and HBase won't be a good option anymore as they require Hadoop cluster.

  • @utkarshkore4076
    @utkarshkore4076 Před 5 lety +1

    Great video brotha.. @gauravsen. Nice work you're doing thumbs up for that. Hope we had lectures for these topics and lecturers like you🤗

  • @ruchirai5775
    @ruchirai5775 Před 3 lety

    Thanks, this is good session for UI developers also to understand on high level how chat system works.

  • @itssantanu
    @itssantanu Před 2 lety +17

    Hi Gaurav , fantastic architecture design and explanation . But, for group massaging, "session" micro service is calling another "Group" micro service , which is kind of http chaining and potentially example of anti-pattern. Can't we implement messaging mechanism like "distributed Kafka" to make it more decoupled. Just a thought of mine. Let me know your take on this.

  • @arturkomyakov7729
    @arturkomyakov7729 Před 4 lety +9

    QQ: if you try to keep gateways light and delegating all complicated logic and memory usage to other services, you will still have to scale them per number of users/messages. So either there should be some discussion around batching between gateway and sessions or you can just scale the number of gateways and keep some logic there (for example parsing).

  • @sriramv4306
    @sriramv4306 Před 5 lety +1

    Excellent stuff buddy. Very useful. Keep up the good work.

  • @balaramkantipudi3728
    @balaramkantipudi3728 Před 5 lety +2

    With this video I got interest in the topic of system design completely,even I don't know what it was before...

    • @gkcs
      @gkcs  Před 5 lety

      Glad to hear that!

  • @Frigno
    @Frigno Před 5 lety +8

    I'm not into programming, though I appreciated this video. I'd really like you to publish a similar lesson, but for Telegram. Thanks in advance, and keep up the good work.

    • @gkcs
      @gkcs  Před 5 lety +1

      I'll check out Telegram and see if I can make time for it 🙂

  • @jonahlin6399
    @jonahlin6399 Před 4 lety +19

    Hey Gaurav - thanks so much for putting up such quality content! You're truly a wizard.. I've been learning so much about system design purely from your videos.
    I was wondering though, where exactly should I be placing the message queue in this example? Would it be after the sessions microservice confirms with the group-service which users are part of the specific group that the message is directed towards?

  • @therealb888
    @therealb888 Před 5 lety

    Finally an Indian tech/engineering related youtuber who can speak English! But more importantly a very well explained video. Keep it up!

    • @gkcs
      @gkcs  Před 5 lety +1

      That's quite a demeaning comment b888, considering English is rarely our first language.
      Thanks for the compliment though 🙂

  • @MsAneesh007
    @MsAneesh007 Před 4 lety +2

    Really like your videos. Keep up the good work . Cheers !!

  • @yangangye5819
    @yangangye5819 Před 4 lety +6

    Thanks for your effort! It's great to learn lots of things from your video. But I still have a question after watching this video. Why consistent hashing can help to reduce duplicate information (on 20:57 explaining the group service)? Isn't it just a way of knowing which record should be found on which server?

    • @phildinh852
      @phildinh852 Před 2 lety

      Probably for vertically partitioning table?

  • @kushal1
    @kushal1 Před 5 lety +3

    Would be great if you have another video to break it down feature wise and why these were the final choices in terms of languages/tools/concepts used to implement all this. Maybe helpful for people coming from non-backend development

    • @gkcs
      @gkcs  Před 5 lety

      Have a look at the playlist mentioned in the description. Each feature is explained with alternatives.

    • @kushal1
      @kushal1 Před 5 lety

      @@gkcs Concepts of system design are in place. I saw that playlist.
      What I mean is if one has to implement this architecture. We have to think which features in in what languages. Should this part be in Python/Node. Shall we consider gateway to database communication in Golang routines or Java etc... kind of questions.

    • @gkcs
      @gkcs  Před 5 lety +1

      @@kushal1 Aren't those questions, too vague? I have never seen a system design interviewer ask them.
      At the end of the day, I may like everything implemented in binary opcodes for efficiency, but I have to perform as per the deadlines set by the product.

    • @kushal1
      @kushal1 Před 5 lety

      @@gkcsWow! Someone is rude now.
      I never mentioned from interview perspective. It was a suggestion to dig into tech stack and make another video maybe. Thanks anyway for your content.

    • @gkcs
      @gkcs  Před 5 lety

      @@kushal1 Sorry if I sounded rude, it wasn't my intention in the slightest. Replying to comments all day has taken off my tact perhaps.
      I'll look into this a little more and get back to you. Digging into the tech stack will certainly be of use :)

  • @codewithidan
    @codewithidan Před 5 měsíci +1

    Hey, just wanted to clarify a bit about long polling.
    Long polling is actually more of a request from the client to the server and instead of the server returning a response immediately, the server is waiting for a change of some kind, and when there is a change, the server returns the response finally to the client.
    It was more common back in days before Websockets were introduced and adopted by browsers around 2011 roughly.

  • @tahatungekar6809
    @tahatungekar6809 Před 5 lety

    Amazing explanation. Subscribed!

  • @mervekaymak1703
    @mervekaymak1703 Před 5 lety +4

    Great!Thank you. Next topic should be "Service discovery"

  • @hemantjain6016
    @hemantjain6016 Před 5 lety +236

    Great Video, Really liked this one...!!!
    Just wanted to ask that for the last seen timestamp wouldn't it be better if the client sends a request(Or should I say message!) to the server when the user exits the messaging app(maybe when he exits the main app activity)., Wouldn't it save a lot of overhead for the last seen timestamp(Not taking into consideration the online stamp)?

    • @gkcs
      @gkcs  Před 5 lety +57

      That's a really good idea...it should save a lot of bandwidth in general.
      It would also be quite accurate. Nice point!

    • @hemantjain6016
      @hemantjain6016 Před 5 lety +24

      @@gkcs I didn't know anything about system design until I started watching your videos. Starting to get interested in system design because of your effort.

    • @hiteshgoyal1620
      @hiteshgoyal1620 Před 5 lety +3

      Nice idea..well thought..!!

    • @mrgotu
      @mrgotu Před 5 lety +77

      There might be chance that user lost internet connectivity before exiting app

    • @toddmoore112
      @toddmoore112 Před 5 lety +3

      why don't you create one watshapp like app when you know the design and overtake it ?

  • @SreekarAnugu
    @SreekarAnugu Před 3 lety

    I only had one or two serious system design interviews till now and the face expressions of the interviewer really put you off sometimes. I have never seen anyone explaining system design like this, it's good to know that I'm not very far off.

  • @AolaDIY
    @AolaDIY Před 4 lety +1

    Gaurav! Thank you for uploading these videos. System design made easy !!

    • @AolaDIY
      @AolaDIY Před 4 lety

      Gaurav do you have any tips for uber interview? I have been invited to Onsite for the final round here in Chicago office! Aoladiy@gmail.com

  • @gunasekaranpalanisami6182
    @gunasekaranpalanisami6182 Před 5 lety +11

    nice super, and shirt like good professional look

  • @TheVenkcast
    @TheVenkcast Před 5 lety +5

    Nice Video! Regarding authentication though, most of the applications in the real world rely on client directly calling the authentication service, get a valid token(JWT?) which can be used by other services before responding. This avoids the extra parsing/un-parsing hop between gateway and sessions service.

  • @dexw4
    @dexw4 Před 5 lety +1

    Hey, man first time watching your video but just want to say your explanation is awesome. Appreciated!

    • @gkcs
      @gkcs  Před 5 lety

      Thank you 😁

  • @jeffsmith1284
    @jeffsmith1284 Před 3 lety +2

    This is a good explanation from the sessions micro services perspective. But one area you need to expose a bit more is client caching.

  • @varungupta2045
    @varungupta2045 Před 2 lety +8

    A critical piece that I feel is missing here is delivery of messages when the user is offline. You might not have an active connection to all users at all but you do need to deliver all the messages that were sent to them once they are connected.

    • @beibit-ds
      @beibit-ds Před rokem

      maybe store the message in the db, and when client status changes retry

    • @paulhatcher951
      @paulhatcher951 Před 9 měsíci

      +1 I was asked this question in an interview a while back. First question when I'd done simple send receive was "What If user B is offline and not in session".

  • @aww_rijit
    @aww_rijit Před 4 lety +24

    How does Telegram can function having lakhs of members in each group?

  • @KiprutoR
    @KiprutoR Před 4 měsíci

    CZcams is such an amazing platform. Thanks for the video

  • @alsan378
    @alsan378 Před rokem

    Thank you Gaurav, you cant imagine how much this video helped me last year.

    • @gkcs
      @gkcs  Před rokem

      Thanks Alvaro!

  • @vinayagamnatarajan
    @vinayagamnatarajan Před 3 lety +10

    Hi @Gaurav Sen
    This is very good session.
    Just wanted to ask, If use MQTT instead of web sockets. Does the native support for publish/subscribe would bring any advantage for the chat application?

  • @StefAmpersand
    @StefAmpersand Před 4 lety +4

    Great video, Gaurav! Chapeau!
    I was wondering why the messages are stored in message queues. Why not a low-latency publish&subscribe mechanism? I would think a persistent event stream (e.g. Kafka topics) yields a simpler architecture for this particular use case. Just give each user group a Kafka-topic of its own. Now WhatsApp has smart software engineers on board, so I'm wondering what they have done to compare these two (MQ vs. Kafka) and why it turned out to be an MQ-architecture.

  • @saifrnaik
    @saifrnaik Před 4 lety

    Hi Gaurav, thank you so much for these videos. You're the real deal :-) I was trying to dig in deeper (apologies if these are trivial queries). I was trying to understand the handshake between your gateway and the Sessions Server.
    Let's say Person A is chatting with Person B.
    Step 1: Person A hits the gateway (a reverse proxy) that will do most of the heavy lifting (auth, TLS termination etc) and detect the websocket handshake.
    Step 2: The gateway forwards the request to your Sessions Server(which is your websocket server)
    Step 3: The Sessions server receives the request and sends back a reponse HTTP/1.1 101 Switching Protocols Upgrade: websocket.
    My understanding goes a bit gray from here (please also correct if something is a miss in the above three steps)
    Do all further communications between A and the the proxy now use websockets and then the same protocol to hit the sessions server? Hence, the client calls something like - wss://www.whatsapp.com/socketserver and hits the reverse proxy, and that forwards the request to the sessions server? or am i missing something.
    If this is in an application like slack... then it would switch between wss and http based on the service it's trying to invoke (say chatting vs creating a channel)

    • @saifrnaik
      @saifrnaik Před 4 lety +1

      Most of the answers are in the tinder video
      czcams.com/video/tndzLznxq40/video.html
      Not deleting the comment in case someone has similar questions

  • @jatinderarora2261
    @jatinderarora2261 Před 5 lety

    Thanks Gaurav. Nice explanation.

  • @harisbashir6074
    @harisbashir6074 Před 5 lety +4

    You are amazing . love from Pakistan

  • @rishabhdixit4214
    @rishabhdixit4214 Před 5 lety +24

    Again a masterpiece...nice work Gaurav 😊😊...can you create a playlist for OOPS and Design pattern?..thanks in advance

    • @gkcs
      @gkcs  Před 5 lety +2

      Thank you!
      I have them on my list. Going as per the polls now :D

    • @ankitjain6787
      @ankitjain6787 Před rokem

      @@gkcs voting for design patterns

  • @aliasgar1648
    @aliasgar1648 Před 4 lety

    well done !! you made it really simple to understand

  • @chandeshify
    @chandeshify Před 3 lety

    Very clear narration and provides a high level overview

  • @Gondkar86
    @Gondkar86 Před 5 lety +4

    Hey Gaurav, excellent video. Learning a lot from your system design videos. However, i had a question related to last seen/online feature. Wouldn't something like hearbeat mechanism be useful for this to update the timestamp of the user?

    • @gkcs
      @gkcs  Před 5 lety +1

      Thanks! Heartbeat for everyone would be too expensive. Especially as many users are active for a short period of time. 🙂

    • @aditya.chandel
      @aditya.chandel Před rokem

      A better approach would be to log the timestamp at which the user last interacted with the client application (android, ios, etc).

  • @ankitmaurya3591
    @ankitmaurya3591 Před 5 lety +3

    After watching this.... I am highly interested in system design

  • @mohammedsharikuzama5518

    I visited the Uber Hyderabad office the other day for an event. Thought of meeting you. Never had a chance to reach out hope I will meet you someday. Thanks a lot for your amazing videos man. They help a lot.

    • @gkcs
      @gkcs  Před 5 lety

      Thanks Sharik!

  • @ahsan4life2020
    @ahsan4life2020 Před 5 lety

    Thank you so much, it is a very useful channel.