WhatsApp System Design | FB Messenger System Design | System Design Interview Question

Поділитися
Вставка
  • Опубліковано 29 вер 2024

КОМЕНТАРІ • 193

  • @maheshwari9321
    @maheshwari9321 3 роки тому +2

    You are PRO. Thanks for so many amazing videos. I have seen others video as well on chat system but none can beat you in terms of deep knowledge, clarity.What a wonderful explainations..

  • @harshac8095
    @harshac8095 3 роки тому +2

    By far the best system design videos you can find on UA-cam. Amazing how you have so much clarity on these. I would love to have a video on tools like Smartsheet. Thanks in advance.

  • @sowjanyav6570
    @sowjanyav6570 3 роки тому +3

    Great information and explanation! As a continuation, here are some thoughts or questions, to help clarify myself.
    1. Whenever a group msg is sent, on the client side, a group msg to be shown in the group window, but not in the individual msg window right? to do this, when server is sending group msg to individual users in the group, it needs to tell client that its a group msg
    2. May be if data model is defined, showing tables, what fields each table has, the above point can be more clear, not sure how imp it is to describe data model in an interview
    3. Last seen service could get info from "Web Socket Manager' from the previous diagram, as it knows which is user is connected to which handler, the moment a user loses connection, this service can inform Last seen service to stop updating time, right? (SORRY MY BAD, the understanding was wrong! Last seen time is based on when the user is "on the app", not just when he has a "live connection with the server") --------------This comment might help others as well
    4. How long whatsapp server keeps the connection alive? is it forever until user logs out? or until we kill the running instance of the app on the client side?

  • @chetanyachopra6716
    @chetanyachopra6716 3 роки тому

    This is goldmine for system design resources .. Thanks a lot for this

  • @beinspired9063
    @beinspired9063 3 роки тому

    Bhaiya, please keep making videos like this. It help us a lot. Please dont stop. 🙏

  • @kuldipmishra2280
    @kuldipmishra2280 Рік тому

    Amazing content. Really this what i was looking for after watching many video from other creators.

  • @qussay
    @qussay 2 роки тому +1

    Thank you so much for your dedication and the great content very helpful.
    In your blog summary, I think there's a slight correction to be done the diagram. In 1:1 messaging where "Websocket Manager" is not communicating with "Message Service" which I think it should given that "Message Service" is the one handling storing the messages to Cassandra

  • @trybeingakr
    @trybeingakr 4 роки тому +28

    Love your content, esp because you capture a lot of breadth for all problems. I don't think 64k limit is true on the server side. The server is always listening on a single port and supports simultaneous connections by accepting connections on a different socket. So for a server, the number of file descriptors a server can create is the limiting criterion AFAIK

    • @pankajsingh17787
      @pankajsingh17787 4 роки тому +17

      That's correct. A connection is uniquely defined by the (client IP, client Port, Server IP, Server Port) tuple. A server can serve multiple clients on the same port. For each such connection server keeps the track using file descriptors. So, essentially file descriptors become the bottleneck. That theoretically can be in the millions range. But, practically serving each request requires other resources like memory and cpu. Usually, modern commodity hardware servers (8 core cpu, 16GB RAM) can easily handle 60-100k "lightweight" connection.

    • @arushkharbanda
      @arushkharbanda 3 роки тому +1

      @@pankajsingh17787 A server can handle6 4k websocket connections with one network interface, more network interfaces can be added to the server to allow it to handle more websocket connections.

    • @AbhishekKumar-vf3cu
      @AbhishekKumar-vf3cu 3 роки тому +1

      Kuch bhi

    • @bhatanand
      @bhatanand 2 роки тому +1

      @@pankajsingh17787 No really. Any TCP connection has the 5 tuple and every accepted connection needs to have a dynamic port associated with it. There are 64K ports. So per IP address, you can have at max 64K connections.

    • @bhatanand
      @bhatanand 2 роки тому

      @@arushkharbanda This could be the case if the memory is less on the system. Assuming abundant memory, number of connections are limited by number of ports supported by the TCP/IP stack. First 1024 ports are special ports and are associated with processes with euid 0. You don't want to run your websocket server as root due to obvious security concerns. So, at max you can have 63K connections per IP address per server assuming resources hold up.

  • @gouravgarg6756
    @gouravgarg6756 9 місяців тому

    Thank you for the amazing video! I have a question, what should to do if the group message fails to broadcast to some users?

  • @richardnorth1881
    @richardnorth1881 2 роки тому

    Hey you make such great designs and explanations, A+. But it would be so much better if you fixed the sound quality! Your videos would then be perfect.

  • @abcd12272
    @abcd12272 4 роки тому +2

    Please make one on Dropbox. Good job! One question my not use a MySQL cluster it is multi-master and any node can accept writes?

    • @codeKarle
      @codeKarle  3 роки тому +1

      Thanks buddy!
      We could use a MySQL as well here, and it'll work well to a great extent, but the parameters that you can consider to decide on a DB are many more other than just the scale.
      For example, in this case, we might always query just on one field(let's say user_id) to fetch the chats of a person. Here we don't need complicated where clauses, we can just live with a DB that provides all values(chat details) against a key(user_id). If you look at it from this angle, there are a lot of DBs that are more optimal than a MySQL for this kind of a query pattern.
      I would recommend to have a look at this video: ua-cam.com/video/cODCpXtPHbQ/v-deo.html.
      Here, I am covering exactly this question of which DB should be used when, and hopefully it'll answer your question :)

  • @piyushsinha8705
    @piyushsinha8705 2 роки тому +1

    One question - how are web socket handlers talking to each other? via rest, grpc, ws between themselves? why can't they talk via a queue?

  • @tarankaranth8782
    @tarankaranth8782 2 роки тому

    this is great stuff. i have also brought your udemy course. couple of questions 1. shouldnt we offload what we offload some of things websocket handler does 2. how is msg order achieved and 3. why isnt kafka used for passing messages between services as every thing happening in the system is essentially asyc in nature. thanks

  • @uditagrawal6603
    @uditagrawal6603 2 роки тому

    Cassandra has performance issues with the updates of done on regular basis because of its append only architecture, so Cassandra might not be a good choice , maybe we can use redis.

  • @mdsardar5936
    @mdsardar5936 7 місяців тому

    Well prepared and gracefully delivered. It would be glad if you can back to this channel and post video whenever you get some time or may be short videos. Thanks BTW.

  • @preetigupta5565
    @preetigupta5565 2 роки тому

    Hi @codeKarle and @Sandeep, Thanks for the video! I did not get how one websockethandler will talk to another websockethandler on which user u2 is having an open connection .. Can you please share some thoughts on this?

  • @NeerajPahuja
    @NeerajPahuja 3 роки тому

    You explained WSM stores 2 sets of info: i) Which user is connected to which WSH ii) Which WSH is connected to which users . What is the purpose for storing the second piece of info here?

  • @KanishkJainEngineeringLovesMe
    @KanishkJainEngineeringLovesMe 3 роки тому

    Does a web socket handler has a capability to talk to every other web socket handler? Even if they are like spread geographically?

  • @sandrolezhava329
    @sandrolezhava329 4 роки тому

    great content, but please take care of the audio of the video, it is really hard to follow...

  • @neeranchalgupta1644
    @neeranchalgupta1644 4 роки тому +1

    Its elaborative !! Nice

    • @codeKarle
      @codeKarle  4 роки тому

      Glad that it was helpful :)

  • @tarankaranth8782
    @tarankaranth8782 2 роки тому

    for group service will there be specific topic in kaftka for that group conversation?

  • @sakcee
    @sakcee 2 роки тому

    how did you come up with this design? what are the pro/con which led you to this

  • @viditmathur8437
    @viditmathur8437 3 роки тому

    For identifying duplicate image uploads can we use a bloom filter?

  • @randomguy4822
    @randomguy4822 2 місяці тому

    Can you please make HLD of Book my Show ?

  • @Gerald-iz7mv
    @Gerald-iz7mv Рік тому

    what happens if they user which will receive a message goes offline?

  • @super-ulitka
    @super-ulitka 2 роки тому

    The same story reproduced over and over. Whatsapp doesn't use p2p sockets for messages between users..

  • @InsaniyatSoch
    @InsaniyatSoch 2 роки тому

    what is throughput and latency in the system

  • @bhargavreddy7038
    @bhargavreddy7038 2 роки тому

    GOAT

  • @orkylabs4505
    @orkylabs4505 4 роки тому +20

    Amazing video. A suggestion: Mentioning about sharding mechanisms, configuration svcs such as ZK, consistent hashing etc. might help clarify the complete picture for a particular service

  • @ayeshaarzbegi3178
    @ayeshaarzbegi3178 3 роки тому +106

    Of all the system design prep videos, I find Sandeep’s videos to be the most comprehensive. I’ve been interviewing the past month and I ended up with 7 offers with system design interview being my strongest in those. All thanks to code karle videos - I cannot appreciate enough how much of a help those were during interview prep.

    • @chintamalli695
      @chintamalli695 3 роки тому +1

      agreed

    • @AbhishekKumar-vf3cu
      @AbhishekKumar-vf3cu 3 роки тому +7

      7 offer you got because of diversity hiring benefit with low hiring bar..Not due to video

    • @ayeshaarzbegi3178
      @ayeshaarzbegi3178 3 роки тому +8

      @@AbhishekKumar-vf3cu I don't think I could get lucky 7 times over. Based off the feedback from those companies, my offers did not look like pity hires. But if you still think the hiring bar is been low across the board, well everyone can benefit from it. Good luck with your interviews!

    • @AbhishekKumar-vf3cu
      @AbhishekKumar-vf3cu 3 роки тому +2

      @@ayeshaarzbegi3178 hiring bar is low for diverse people. Every company is crazily hiring diverse people.

    • @ayeshaarzbegi3178
      @ayeshaarzbegi3178 3 роки тому +5

      ​@@AbhishekKumar-vf3cu I think its time for you to get some diverse skills that'll help you navigate the interviews. Good luck!

  • @ismailcenik8892
    @ismailcenik8892 4 роки тому +13

    Good job. I watched similar videos on the same topic. This is actually the most informative for me. Thank you so much.

    • @codeKarle
      @codeKarle  4 роки тому +1

      Thanks for the kind words!! We'll keep making more overtime.

  • @Aditya-mk5sm
    @Aditya-mk5sm 3 роки тому +2

    A server can handle much more than 65k connections depending on its cpu and memory. Please do correct this in your video.

  • @abinvarghese9286
    @abinvarghese9286 4 роки тому +8

    pretty good Sandeep. I feel you cover more in very less amount of time. I was wondering what your thought process was in having group messaging as separate. You can also think of direct 1-1 messaging as a group of 2 , no ? Also when in case of 1-1 messaging, when you are sending message directly from websocket_handler_A => websocket_handler_B, wouldn't it lead to system crash in case of rush hour ? In short my thought is like handling 1-1 messaging same as group messaging, in this case the async queue can buffer the messages and send with a slighter more delay, instead of a web_socker server crash. Let us know.
    Anyways it was fun video dude. Keep posting.

    • @namanmishra08
      @namanmishra08 9 місяців тому

      I was also thinking in that direction due to the decoupling provided inherently by Kafka but I think the problem with that is creating a topic for each user in Kafka can lead to performance issues since there are billions of users, but since there are lesser number of groups (maybe millions) this approach works for group messaging.

  • @jrwang537
    @jrwang537 3 роки тому +2

    Your voice is not quite clear. I can only know you are speaking but don't know what you are talking about.

  • @DharminChothani
    @DharminChothani 6 місяців тому +1

    How does Web Socket Handler 1 communicate with Web Socket Handler 2?

  • @Vivek-je1og
    @Vivek-je1og 3 роки тому +2

    Thanks for efforts. Your content is such a gem that it made a dumb(like me) good at these concepts. Thank you so much.
    Also, I do have question, at 18.50, you talked about web-socket handler would talk to asset service if there is any image/video upload. I was thinking if it is good that web-socket handler talk to message service in case of image/video upload as well. And then, message service can decide that I am getting a static media in message so I should call asset service first and tell asset service to do all the transformation with image/video and send the CDN link to message service. This way we can also store the link in cassandra as well. What do you think ? Does this make any sense(I am still a beginner and it is just a thought so pls bear me up)

  • @vineetkasat
    @vineetkasat 3 роки тому +2

    How will cassandra address queries like "Give me all unread messages for a user" ? If partition key is user_id for message table, then hot partitions will be a potential issue but if message_id is partition_key then all shards need to be queried for getting all the messages for the user and that will be costly.

    • @rjarora
      @rjarora 3 місяці тому

      Why will user_id as the sharding key create hot shards? Will a particular user be sending or receiving millions of messages in a day?

  • @saidattathallam
    @saidattathallam 3 роки тому +4

    since you have mentioned cassandra and redis databases. Sharing sample table structure and queries would surely help us in the visualization of the data and would give us some ideas about the underlying databases as well. But Great Effort in making the concepts very simple

  • @kipkip6712
    @kipkip6712 3 роки тому +2

    why handle group service through kafka? Why cant we have the Group service get all users of a group; iterate through users and do the same direct messaging.

    • @rjarora
      @rjarora 3 місяці тому

      Because it will increase the latency then

  • @hanspeterpfister2253
    @hanspeterpfister2253 4 роки тому +5

    This is a great video. It would be great if you could also talk about how message ordering is ensured in case of FB messenger. I doubt it can solely happen on basis of timestamps (client/server), since depending on where users are and the timezones they are in, they might have different timestamps value. This is typically done through messageID's generated by client. You did pick up that, but that can be used for ensuring a consistent ordering of messages is missed. Please do include that as well if you can.

    • @codeKarle
      @codeKarle  4 роки тому

      I would rather to it as a combination of an auto increment numeric message id from a user who is sending and a timestamp in UTC for a conversation /group. The message ID was more of a UUID/primary-key that I had talked about in the video. It's not efficient to use it for ordering I believe

  • @srtvenkat215
    @srtvenkat215 3 місяці тому

    Thank you so much for this wonderful video. I have a question. Isn't the web-socket manager a single point of failure? If it briefly goes down, how will it know the scope of the existing web-socket connections on the handlers?

  • @bhaskarsharan4280
    @bhaskarsharan4280 10 місяців тому

    I have a query in image upload part, how will the msg reach asset service? mobile -> LB1 -> web socket handler -> LB2 -> asset service? If yes why so, why can we directly have something that will store blob data for msg and return msg_link? i.e., mobile -> LB1 -> asset service?

  • @protyaybanerjee5051
    @protyaybanerjee5051 7 місяців тому

    There are various nuances of the group messaging service.
    - What should be the workflow for delivering messages to a group, Assuming the group has a huge membership. do we want to delay the delivery ? Does the Group service cache the information for user to machine mapping so as not to overwhelm the redis instance ?
    - How to handle duplicate message delivery ? Should we delegate the deduplication at the client end so that devices will keep track ?
    - Should all messages be delivered by a single node ? What happens if that crashes ? How to store the delivery status ?
    - How should the failed delivery messages be retried ?

  • @MayankSharma-en5rt
    @MayankSharma-en5rt 3 місяці тому

    Please explain why are we using kafka or any messaging queue for group messaging, can't the web socket handler directly call the group service and fetch which all users it needs to send the message to? I mean why do we need kafka here, isn't it same as one to one messaging ?

  • @KanishkJainEngineeringLovesMe
    @KanishkJainEngineeringLovesMe 3 роки тому +1

    Great video.
    What happens when a web socket handler fails. How does a web socket handler communicate with web socket manager.

  • @gauravkatariya8281
    @gauravkatariya8281 3 місяці тому

    why there is a loadbalancer in front of the websocket manager? is only first request is going through the load balancer? is loadbalancer is also communicating to websocket manager to make decision about where to forward the request?

  • @raghusrinivasan7309
    @raghusrinivasan7309 Рік тому +3

    Videos by Sandeep are the most comprehensive system design videos anyone can see - The flow of information is smooth, logical and easy to follow. Heartfelt thanks to Sandeep for being one of the best tutors on the net.

  • @ritubhandarimusic
    @ritubhandarimusic Рік тому

    Do you really think msgs should be analysed or put into some hadoop clusters? Wouldn’t it be against user privacy?
    Btw, i guess you love redis and cassandra :)

  • @dataman4503
    @dataman4503 2 роки тому +1

    Just wondering, what is the difference between 'Low latency' and 'No lag'?

  • @MrDrabiv
    @MrDrabiv 10 місяців тому

    @sandeep could you please explain why we need Kafka to send group messages. Wouldn't it be easier to send message directly to group messages handler?

  • @DataRevolution10
    @DataRevolution10 13 днів тому

    Awesome explanation. Thanks so much for making such an insightful video

  • @abhisheksinghal1746
    @abhisheksinghal1746 3 роки тому +15

    No doubt the content of video is informative for all the system design enthusiasts but I have few points that I was looking for but was missing .
    1. If you could have talked about services interfaces like design of some api's , request and response high level design .
    2. If you could have talked about the guess estimates like on requests per min , no of users and bandwidth consumption and how we can optimize on those points .
    3. Clear cut explanation of why we used Kafka as it's a fancy term and what's the actual use case why not simple and lightweight messaging components if at all we require like active mq .
    4 . Some deep dive on internals of redis how we use in this use case .
    5 . How we can handle failure scenarios as they can be many in such an interconnected system.
    6. Some internals of database design , concepts of indexing , sharding, partitioning as there would be lot of read/writes .

  • @risbha5505
    @risbha5505 3 роки тому +3

    Thanks @Sandeep @codeKarle for the great explanation. Myself Rishi, currently working as a Senior Software Engineer having completed my Bachelors in Computer Science from BITS. As is the case with most Design discussions I do have a few questions:
    1) For the Group messages how do we handle the sequence of messages from a particular user. I understand that messages from multiple users can/need not be guaranteed a specific sequence, but all messages in a Group chat need to be in a proper sequence to avoid context misses in the conversation. Do we use a messageId or ordering of some sort for this? Or maybe use the ID Cassandra generated by the initial entry of the message into Cassandra ?
    2) I have some concern with you preferring Cassandra over Redis for the last seen service. Redis being distributed and highly scalable, along with proper sharding can be appropriate for this use case IMO. We used it extensively for our gaming application for both read/write serving millions of I/O requests per minute.

    • @abisheksoni3354
      @abisheksoni3354 2 роки тому +1

      By using consumer group and partition in topic ,in kafka , a sequence can be maintain .

    • @prerakchoksi2379
      @prerakchoksi2379 8 місяців тому

      @@abisheksoni3354 can you explain this a bit

  • @shubhamsrivastava5400
    @shubhamsrivastava5400 3 роки тому +2

    Great video. Some of the issue like 64k limit is already pointed out in other comments. In the last you talked about decreasing the lag in kafka by adding more consumer. I guess you must be talking about adding more consumers in a consumer group but unfortunately it won't help once the count exceeds no of partitions. Excess consumers would sit idle in this case.

  • @Gerald-iz7mv
    @Gerald-iz7mv Рік тому

    i only see kafka queue. don you need you multiple kafka queues for multiple groups, and/or p2p chats?

  • @vivek5562
    @vivek5562 4 роки тому +1

    Liked the video. How are Web Socket Handers communicating with each another? Also, how is websocket handler communicating with the Websocket manager?

  • @prakashupadhyay9529
    @prakashupadhyay9529 11 днів тому

    This is by far the best explanation of WhatsApp messaging system design!

  • @rahulsharma5030
    @rahulsharma5030 3 роки тому +1

    when user connects to load balancer, then how can load balancer forwards TCP request to websocket because it has to be between direct client and server?Can there be loadbalancer in between?

  • @himanshubhandari7222
    @himanshubhandari7222 8 місяців тому

    Great video, just a question how WSH 1 will communicate with WSH2

  • @amitk476
    @amitk476 3 роки тому +2

    Excellent analysis, In depth detail. This is what I was looking for.

  • @vennyroxz
    @vennyroxz 4 роки тому +1

    thank you for the detailed explanation, so much better than any whatsapp design video i saw. The summary link helps a lot to revise on the design! Great work!

  • @ayushmalik1440
    @ayushmalik1440 7 днів тому

    mic toh dhang ka lele bhai, system design baad me krlena

  • @HARISHUDHAYAKUMAR-i9h
    @HARISHUDHAYAKUMAR-i9h Місяць тому

    Very well explained. Thank you for the video.

  • @priyavenkatesan1804
    @priyavenkatesan1804 2 роки тому +1

    Hi Karl, Nice explanation. Can you please clarify how the communication between the WS Handlers happen? What protocol does WS Handler1 use to talk to WS Handler 2? Thanks!

    • @uditagrawal6603
      @uditagrawal6603 2 роки тому

      I think there a distributed messaging queue like Kafka might help as that will ensure atleast once delivery also will keep the websocket handlers from getting bombarded.

  • @maninouri7331
    @maninouri7331 4 роки тому +1

    The best content I have come across from any all the content producers. All the components are explained with necessary technical details which interviewers drill down to and ask questions about. Thank you! Just one comment: Investment in a high-quality microphone would elevate your videos to a whole new level which are already unparalleled. Please keep making them.

  • @Gr3mlinz
    @Gr3mlinz 3 роки тому +1

    Great videos, thank you. Subtitles will be much appreciated !

  • @abhinavsinghal1530
    @abhinavsinghal1530 Рік тому

    DOUBT : It seems like whatsapp stores all the messages in our mobile device's storage.
    When I turn off the internet, I can still view everything. So, I have 3 questions:
    1. Is it reliable to store on mobile storage ?
    2. How does it sync the messages from mobile storage and the actual DB ?
    3. WhatsApp uses ~15 GB data on the phone. Is that a correct estimate for the data requirement for 1 user in an app like WhatsApp ?

  • @poojabennabhaktula4883
    @poojabennabhaktula4883 3 місяці тому

    Really sad why you didn't receive same number of likes as views:) thank you for teaching such good content for free. I wish I could press the like button 100 times. Great efforts!!

  • @spicy2112
    @spicy2112 11 місяців тому

    Can some answer my doubts?
    1) How would the packet flow be if user1 sends a message to user 2?
    2) Will all web socket handlers be connected in a mesh?
    3) Will web socket handler 1 push the message to message service and web socket handler 2 take it from the message service?
    4) what protocol would be maintained between web socket handler and web socket manager? Is REST enough?
    5) The cache maintained by web socket handlers. Are they in-memory cache or are they distributed?

  • @KnowledgeGuide859
    @KnowledgeGuide859 9 місяців тому

    How the two websocket handlers communicate with each other ?

  • @protyaybanerjee5051
    @protyaybanerjee5051 Рік тому

    How does the state in Redis for Websocket Manager is updated once a connection is lost or one of the websocket handler goes down ?

    • @protyaybanerjee5051
      @protyaybanerjee5051 Рік тому

      Adding some thoughts here - Each time a user is connected to one of the geographically nearest web-socket server1, that information can be streamed to a Kafka topic. The consumer can then update the Redis instance which the websocket manager is interacting with.
      Now, the question remains, when do we remove the user from the redis indicating the "offline" status ? This can be done by a PING frame that the websocket server sends, every X minute, to see if the user is connected or not.
      If the user is not connected, we can then stream that event to a Kafka topic to handle the use-case!

  • @OffbeatTravelVK
    @OffbeatTravelVK 2 роки тому

    You are a God man! Have seen all of your videos, its been so so helpful for learning technical design for TPM roles! Thank you so much Bhai!

  • @travelgolive1642
    @travelgolive1642 2 роки тому

    Nice video .have two question .
    1 when is the messages getting deleted from Cassandra ?
    2 when socket handler 1 request socket handler 2 to a send message
    Does socket handler 1 sends message to socket handler 2 or socket handler 2 pulls from Cassandra

  • @vineetbhargava4141
    @vineetbhargava4141 3 роки тому

    Around 3:30 I think you are confused between ports and sockets. Theoritically a port can make billions of connection. And there are 65k ports. Please correct me if I'm wrong.

  • @ImConfusedVoteForErdogan
    @ImConfusedVoteForErdogan 3 роки тому

    you well explained what is going on background thank you so much. But I could not understand that what about offline group members ? We can check message service to fech all undelivered messages in the first time that connected to wsh-x. But we do not keep any status indicator for group messages. So when user who is member of a group, if not connected to wsh then miss all messages which sent before.

  • @goutamkundu6392
    @goutamkundu6392 5 місяців тому

    How do you handle group receipts here?

  • @natkhatnimbu1355
    @natkhatnimbu1355 2 роки тому

    For asset operation where will we store receipt for asset in message service against some asset id? Also what will happed if u1 gets to know machine1 for u2 from websocket manager but just right then u2 connection resets and connected to machine2?

  • @prerakchoksi2379
    @prerakchoksi2379 8 місяців тому

    How would I maintain status for group?

  • @im2crazyin
    @im2crazyin Рік тому

    Big fan of you sandeep. One quick q - if the target is offline why store the messages locally on sender. Why not store in cassandra and have it delivered when the user is online again

  • @soniamathew250
    @soniamathew250 2 роки тому

    Can you do a software model for swiggy or zomato?

  • @manoranjandas484
    @manoranjandas484 2 роки тому

    Thanks for this video. Very scrip and informative . Have one doubt Host supports 6500 ports not connections. Number of connection does not depend on number ports. Simply a single port can handle more than one connection . Please clarify.

  • @akannan
    @akannan 2 роки тому

    very good content but your presentation could be better , instead of keeping the same tone you should emphasize / pause / highlight what is important to engage the audeince all the best

  • @abhishekkumar696
    @abhishekkumar696 3 роки тому

    I have one question, so when u1 is sending message m1 to u2, then web socket thandler1 is connecting with message service to store the message m1, would it be correct to shift this work from web socket handler to web socket manager which then connects with message service, thus web socket handler1 role will only be to receive and send messages for a device.

  • @hksubs
    @hksubs 2 роки тому

    Great. I agree with Ayesha, that SanDeep's seem most complete. ex, he goes into race conditions example , and the websock handlers ... that i don't see in other videos.

  • @hayunnir
    @hayunnir 2 роки тому

    Great Video! Thank you! Keep making videos like this one!
    I have one question though - which kind of strategy will the load balancer will use to maintain the web sockets? Is it IP based caching?

  • @rabindrapatra7151
    @rabindrapatra7151 2 роки тому

    cant the message_service fanout the group messages? anyway we can scale it. why we need another service for group_message?

  • @architguleria989
    @architguleria989 2 роки тому

    It would be great if you could explain tha database for cassendra etc like what to choose as key (partition and cluster) etc.

  • @pallavibansal84
    @pallavibansal84 4 роки тому +6

    Great content. Thanks for the hard work ..
    Could you please help answer a few questions
    1) In the non functional requirements, you don't mention consistency. Shouldn't we talk about what consistency means for this system, and if it should be maintained
    2) Why use MySql for storing User and Group Data? Why not noSql, it's easy to scale as compared to sql dbs as there could be millions of users
    3) How is the message order taken care of in case of failures?
    Ex:
    timestamp1: U1 sends U2 message M1
    timestamp2: U1 sends U2 message M2
    Delivery of M1 fails during first attempt, but succeeds on successive retries
    M2 succeeds on first try ..
    as a result, M2 is sent before M1

    • @ajaykumarbollam2106
      @ajaykumarbollam2106 4 роки тому

      I also have the same query, did you get answer for this?

    • @codeKarle
      @codeKarle  3 роки тому +12

      Consistency should be maintained at a reasonable level. We cannot make an inconsistent system here.
      The reason it's not too big a problem here is because there are these two possibilities:
      1. in case the users are Live and engaging in a continuous chat, or just online, the message flows through the Weksocket Managers/handlers and we do not bother about what happens on the DB front.
      2. The second scenario is when one of the users is offline. This is the scenario where consistency matters. But it's not that it takes minutes for the DB to get consistent. It'll get consistent within a second(maybe a few seconds on a worst case of extreme traffic), and since the user is offline, we would have the message replicated by the time they come online.
      One edge case is that there is race condition between them coming online and the message being sent. In order to take care of that, I suggested to fetch messages for the user after a few seconds of them coming online to handle this scenario as well.
      MySQL would be able to scale to a million of rows, that's not a concern. But more importantly, the data for these services is structured, which makes a good case for MySQL. We could use a NoSQL though, just that I don't see any amazing benefit of using a NoSQL here. I would suggest to look at this video for this: ua-cam.com/video/cODCpXtPHbQ/v-deo.html
      For the retry in case of message delivery, I think it is okay if they are shown out of order if we show it on the UI to both the parties, alternatively, we can build a sender side message ordering using some incrementing ids to handle this scenario.

  • @systemdesign6185
    @systemdesign6185 3 роки тому

    What if instead of keeping socket open, we establish TCP connection only when user requests for new messages?

  • @HimanshuSingh92
    @HimanshuSingh92 3 роки тому

    Thanks for explaining it such a nice manner.
    I have a question though - In this design, all web socket handlers talk to each other. Are these connections also web socket connections?
    When there are tens of thousands of servers, isn't this a problem? Is there any other alternative?

  • @pramodb6958
    @pramodb6958 3 роки тому

    Awesome and detailed explanation... if you could make a system design for Locker service like Amazon provides would be great.

  • @omerocak4710
    @omerocak4710 4 роки тому

    great video and really good details. Thank you. couple questions, 1- what are some over the counter 3rd party solutions or standards that can be used as a web socket handler and a web socket manager? I could not find any online. Maybe zookeeper for web socket manager. So every enterprise needs to build its own solution customer web socket handler or manager? 2- What is the protocol that can be used in between web socket handlers and between web socket handlers and web socket managers?

  • @kumarsauravsinha190
    @kumarsauravsinha190 3 роки тому

    How the chat servers of whatsapp communicate to each other given that serverA has recieved a message from some user that needs to be sent to some other user on serverB.
    How serverA will pass this message to serverB given the scale.

  • @bhatanand
    @bhatanand 2 роки тому

    Thanks a lot buddy for your detailed videos. These videos have helped me immensely. Sincere gratitude buddy🙏

  • @gourabpanda
    @gourabpanda 3 роки тому

    If the lag increases in Kafka, we need to add more number of Broker(not consumer) right?

  • @leetcodesolutions2035
    @leetcodesolutions2035 3 роки тому

    This is great. Request you to make videos on the individual components such as load balancers, databases, web sockets, caching etc. That would help many of us know the details of these things and designing systems will be much easier then

  • @rabindrapatra7151
    @rabindrapatra7151 2 роки тому

    does the websocket connection stay open when user go offline?

    • @Gerald-iz7mv
      @Gerald-iz7mv Рік тому

      if user is offline - how can you keep the connection open? ;)

  • @codewithamir21
    @codewithamir21 Рік тому

    This is for the first time i landed here and found it so fascinating out of all the system design content... Thank you so much for being here for us ❤️❤️

  • @premkumarbhaskal
    @premkumarbhaskal Рік тому

    As someone already pointed out, Cassandra won't work here. How will it answer the query "give me all undelivered messages for a user x"? It has to be some combination of Kafka plus MySQL like table. Similar to IRIS used in Facebook messenger

    • @rjarora
      @rjarora 3 місяці тому

      Why won't Cassandra work, if you choose userid as the sharding key?

  • @pratikjain4704
    @pratikjain4704 3 роки тому

    How to handle if the group size can be 50k?
    Reply your approach.