Learn High Level Designing for Messaging Apps like Whatsapp | GeeksforGeeks

GeeksforGeeks · Beginner ·🏗️ Systems Design & Architecture ·3y ago

Key Takeaways

Designs a high-level system architecture for a messaging app like WhatsApp

Full Transcript

foreign [Music] [Music] hello everyone hey uh all right let's go so hey everyone how are you today uh am I audible now or is there still a problem with the comments uh can you notify me in the comments and we can accordingly proceed with all right looks good to go so hey everyone I'm Abhishek I am one of uh the folks at Weeks who likes conducting some system design courses uh and today we are here to talk about chat applications uh to be specific we will be talking about WhatsApp to start with uh and I will see if I can extend it to a few other chat applications if time permits uh all right so a very quick uh check if you can help me with uh a simple yes or no how many of you have attempted see a few uh chat application the system designs in the past or have had a certain amount of you know fear or in uh or comfort someone with it comes to reacting with them uh just a quick simple High hello good work in the meanwhile I'll just put up my screen on share and we can start from there okay so today we are here to focus primarily on problem statement which is design WhatsApp so what we'll do uh good good to know the few of you have had interactions with it in past in some interview or some practice sessions so for uh today we will continue working on uh very simple framework we'll first list down the functional and the non-functional requirements we will then uh list down the certain amount of capacity estimations have what will be the requirements that will be required for uh building the overall systems and uh for a certain number of folks so I have seen a few comments coming like I have no idea about hld or how overall the system design question Works in what we would do is I will anyways after completing the system design we'll walk through a very high level system architecture as well as a certain amount of uh API designs and how we would store uh data here uh no uh for questions around where I work or what if I'm an employee of Geeks for geeks no I'm not an employee of Geeks or Geeks I.E uh interact and partner with them for a couple of my courses on say WhatsApp or some other topics here and there uh but officially I'm uh I work at Google and I am Keen with the other product companies such as Flipkart and Walmart in the past that's a very brief history about me feel free to hit me up over LinkedIn if you have any follow-up questions and I'll be very happy to interact with okay uh all right so with all of that being discussed let's go ahead and list down a certain set of functional and non-functional requirements what I mean by functional requirements by the way because I understand that uh some of you may have have been having this as a first interaction uh is what are the core things that you want your system to be doing okay and we will be listing it down over here uh so when we talk about pure system design of like functional requirements right uh if I'm talking about design WhatsApp first and foremost feature will be sending and receiving messages uh sending and receiving messages uh if possible I would want to extend it to a group but I want to limit it to one-on-one messages as of today uh and group if time permits let's say engage it a little bit so that we can uh WhatsApp also we know that has availability of showing send ticks delivered takes and red receipts so we'd call it that we I would want to showcase you how we can do that and also we would want to share multimedia files what I mean by multimedia files are things like images videos uh documents maybe Etc all right so these are some of the top most functional requirements that I would want to stay on top of before we go ahead and list it uh and that's what we'll be focusing on in terms of non-functional requirements now that we are there uh what are the things that we would want to do so non-functional requirements this means in the non-technical stuff things like what would be the load on the system how many people would be interacting with it uh do you want your system to be available throughout the day or like these quality matters over this okay so what we would do is we would Target high consistency the reason why I'm saying consistency even though WhatsApp is supposed to be highly available system is uh is my screen blurred to the rest of you as well or should I let me just see if I can zoom it up a little bit uh is this Zoom fine or do you I'll just take a pause over here to ensure that the zoom level is fine foreign thank you so much for letting me know about this so the reason why we are talking about high consistency is it's very important to understand what is uh the order of the messages in which it was sent across imagine how much of an inconvenience will be if you're sending the messages and it's going in incorrect order uh the entire conversation experience will be dampened uh also we use WhatsApp on multiple devices at times and uh sometimes uh it would not be a good experience if you are able to see a different order of messages uh on different devices and we would want to not have that problem overall so consistency matters primarily because the sequence in which the messages are sent across definitely matters a lot uh the other thing is there has to be low latency we all want our messages to be sent across as quickly as possible and howsoever we quickly we can relate there is matters High availability is also important uh but we are we know cap theorem which states that we can you will have to pick up uh in between consistency and availability cons knowing that particle intolerance will be obviously required for an application as huge as what surface so whenever there's a conflict in between what to prioritize I would always prioritize consistency over availability but I definitely don't want WhatsApp servers going down I mean none of us would like that right so that's pretty much all about it uh I would continue with say capacity estimation which is what I said we will be doing to start with what we mean by capacity estimation is I'll be making a few random guesses around uh how many messages we sent per day what's the size of a message etc etc and how much storage space I'll need uh so let me take a very quick stab at it um WhatsApp currently has uh when I say last checked it has roughly 2 billion users which is oh my God quite a lot of users and let's say we send across 50 messages throughout so I'd say we have 100 billion messages being sent per page it's a lot of messages right not 100 billion messages uh per day uh into let's say each message is roughly 100 bytes uh normally if I'm in an interview I would ask these uh validate these facts with an interviewer uh but since I'm on my own today so I'll just randomly make a few guesses here and there and continue on top of it so uh it's roughly 10 terabytes of data per day it sounds like a lot but considering WhatsApp has too many active users it's a fair enough number uh WhatsApp has a data attention policy that if you don't receive any message in 30 days I would go ahead and delete that message basically assuming that the user no longer uses WhatsApp so I'm roughly looking at 30 terabytes of data per month uh which is what we will be going ahead with to start our overall calculations okay uh and I think this much is overall fine to for me to take a pause uh this is how I would even approach even if I was doing an actual interview or explaining the component to someone I want to define the scope of the problem uh what are the features that I intend to build around the constraints which is listed in the non-functional requirements which I'll try to achieve and a rough very quick calculation around what is the appropriate database size or file storage size that I would be requesting from the necessary Hardware infrastructure teams for me to go ahead and build this application fair enough uh I'll take a quick 30 second pause or five SEC 10 seconds pause over here and then I'll walk you through a very high level core uh design and we can follow it up with a API schema in general any doubts any questions before we go ahead no right okay I'll keep monitoring the chat in Midwife but let me uh quickly walk you through some of the core features again so what do you want is [Music] all right so let's say there are two users let's see there's user one and we have a user too okay now they both want to send messages to me each they both want to send messages to each other now how would that normally happen we'll have a chat server somewhere which is whatsapp's chat server this is how we will start with and the moment user one wants to send a message to user two it will send a message or to chat server the chat server will then send a message uh two user 2 which will be received and acknowledged and in the meanwhile I'd want to store it in some database so that I don't lose out on me messages fair enough uh that's how normal regular flow would look like now this is fairly simple right this is without any problems and complications any scale anything being brought into let's spend a minute uh to try and understand how we would go ahead and actually implement this with all the read receipts delivered and Status which we are talking about so going sequentially we'll have user one which sends a message let's say a very simple message saying um happy New Year message would be something like happy New Year all right it sends a message to the chat server uh the chat servers would then send a tick back to user one um let me make it dotted because I wanted to keep deleting it uh so the more as soon as the moment uh the message reaches the chat server the chat sends back an acknowledgment uh message do it which would indicate that the message is marked with a single tick icon at the receipt senders and saying that the message has been sent uh once the user 2 comes online it fetches the message from the chat server and then sends an acknowledgment back to the chats uh server saying hey I received this message all right so let me make this charted and it again sends a received act message as soon uh as the message address is sent uh this is also updated to user one via uh push notification let's just say the chat server sends another request thing delivered act it's still not talking about read and when the user actually comes online it'll send one more acknowledgment this time it will end up becoming the received at message uh to notify that he I actually received the message okay this is doing some frenzy things uh so this will be like red acknowledgment and the moment the chat server receives the red acknowledgment it will also go ahead and communicate the same to the user run the key your message is now red and so this is red apple right so this is uh like a multi-tier architecture that people go through and interact with uh uh and that's how they normally go ahead with uh the tool that I'm using is is Whimsical let me just type it out over here so that you can refer to it later on but it's Wednesday because I like the user interface of this tool and it's easier to draw on this uh I think okay so this is how I would maintain the send read and delivered receipts uh and how I would send messages across in a simple world uh I wanted to cover this so that we don't get distracted around the code basic feed functionality once we start bringing in the scale and the other components around this okay uh I know WhatsApp has end-to-end encryption to start with and I would not want to store messages in this so what I would do is I'll keep it as a temporary database something which would support a lot of read and delete operations uh fast delete and lookup operations um and I'll tell the database that WhatsApp users later on let me just hold on to it here so the only time when I would want to store messages onto a database is if say user 2 is offline because there's no guarantee that the user 2 will always be online and you don't want to store messages in a chat server where the probability of losing it is very high considering that a server can crash at any point of time overall okay so with now all of this being discussed uh as soon as the message is delivered I would delete the message from the database till then I would keep it here so in order to simplify what I want to delete and what I don't want to delete like I would send every message to the temporary database and then as soon as I receive the received act message from the chat server basically from user to onto the chat server I would go ahead and delete my messages from the temporary database to ensure that we are adhering to the end-to-end encryption protocol uh okay all right so so far so good if this is done then I'd walk into the additional scale component of my design of how I would do it things at scale okay in terms of anybody who is asking me which is the tool that I'm currently using the tool is Whimsical uh feel free to Google about it or I've also put up a link of it on the portal again thank you for pointing this out okay good so now that we are done with the core basic functionality let's jump into how we would do things at scale uh before I do that let me actually discuss about a certain set of apis that I would want to write uh and discuss that also so that we can get done with it and then we can focus on the code so in terms of the apis right um and I'll try to keep it simple again for my personal uh satisfaction so in terms of apis what we can do is uh let's look at the things that we want to I would want to have a messages API which would be a post called sorry which would be a post call and what it will do is it will call a send message at the back uh we should have things like sender ID receiver ID who is the one going to receive the message the type of the message if it is text message I'll enter the text over here if not if it is a media file I would basically go ahead and do this okay um so this also gets me a message ID and I can actually receive a message ID as a response this method ID is what I would be using to exchange all this act messages that I have drawn on this screen here okay so with this being done the next thing which I would want to test API which I want to have is how do I fetch a message so I'll have a endpoint called as get message which now becomes a get protocol obviously it would end up calling a get message service with a user ID the user ID in this case will be the person who is receiving the message so it will actually be like a current user ID and what we will do is it would hit the chat server it will fetch all the unread messages from it and dump into your phone okay the same thing goes for media objects uh we'll have talked about two so when I'm uploading I'll make a post call or two of uh the post score will call this method called as the upload media let's call it this or to simplify it let's just call this upload file yeah and what I would need here is things like file and file type and I would return a file underscore ID I may even want to have say a sender ID but then uh I'll have it already over here so I would not want to duplicate this twice while uploading I don't want to check which it is it's technically a send message feature itself with a file attachment to it while downloading the same version okay so will again have hit get media slash media post this time as a get object uh endpoint and I'll hit the download file let me make this proper for a user ID followed by files followed by your file ID okay the user ID is primarily because I should I want to store somewhere who the user is and because this time I'm not doing a get message again has a user ID but I do definitely want to have the file I already did and I'll get the file object from here okay so without diving too much into detail this is how my API design would eventually look like and take a very quick look at the time we are 20 minutes into the system all right so so far so good okay with all of this being discussed okay we have still not brought in any scale component into the picture this is all happening in between two users with one single chat server which we know is not gonna be correct implementation and how we go ahead with it so let's focus our energy on how we would send messages here and here there are two options if you go by this uh let's look at the number of dots that I had to establish for me to get this object this uh line and all the acknowledgments that we have been discussing uh considering we are sending across 100 million billion uh requests and I have one two three four five six seven seven calls being made I am looking at a humongously uh large number of API calls that are being made and we can obviously agree that this scope of optimizing it so a single Direction mostly signifies a TCP connection right TCP is from a client to a server and that's how we fetch now while sending the message I can still use TCP no harm because I'm sending messages one at a time but while receiving the message if I want to consistently keep a low latency architecture I would have to send a get message TCP call every now and then and when I mean every now and then I may want to send it say every 10 milliseconds or every 50 milliseconds or so to me or maybe every minute uh which is also too late for an instantaneous chat message if you are saying chatting frantically with your closest right uh so the number of API calls that will be made will be too high if you go ahead and with a TCP connection uh what we can do is we can make the TCP call weight by a fundamental called as long polling uh I'll just okay so what long polling does is let me try explaining it over here in a parallel diagram I'll delete this later on okay so user is here sent a message to the chat server waits for the response to come true waits for the response to come through and if it comes through then well enough if it's not it does the exact same thing again and again till the time it receives a message uh too much of a tearsome problem to solve and too much of a headache uh it waits so long pulling it waits for a certain amount of time let's say I want to wait uh for 20 seconds before terminating this connection over here okay or basically the receive connection over here that is still uh too much of a resource phase change if say you're not chatting or your user is not even online and considering the total number of users that we have the extent will be huge right so what other thing can I do apart from trying to do long polling we have a component called as websocket uh what websocket does is it allows the server also to instantiate a connection with uh the end user so unlike a TCP connection which is unidirectional goes mostly from client to server uh websocket connection is bi-directional and we can use that model to for the servers to be able to push notifications to do it so how would the world look like if I'm going ahead with that so what I will do is I will move this diagram down and I'll use the space here to go ahead and draw my drawings but so Adina I'm gonna do the same uh user one and user 2 implementation so I have user one and I would have users two over here both of them will interact with a chat server uh but this time what I will do is I'll have a websocket chat server server and because I know I'm looking at a lot of people using Whatsapp I'll have a scaling distribution I'll have multiple servers which are trying to take the load as soon as you have more than one server involved in your overall design uh that advocates for a need for see a load balancer being brought into the picture well the load balancer will do is the load balancer will distribute the load evenly in between the two uh Earth two plus servers that we have and we'll take it up from there okay so that's how this would look like let me let me just screen let me put a little bit so this is how it would look like okay now the chat server will need to know where to send the message for example user1 wants to send a message to user two okay and I agree that this will be bi-directional so let me make this bi-directional because it's now a websocket connection all right so what would the chat server want to behave like user one sends a message which needs to be instantaneously related to user two because I have more than one server here there is absolutely no guarantee as to which place I would need to send my uh message too we don't know it right we don't know where the address is okay so in order for me to determine what uh will be the address the websocket chat server talks to a component called as a websocket manager depending so we'll have a websocket manager over here now the websocket manager again because there are too many servers and we will have uh to basically distribute the load here I'll bring in one more load balancer over here uh primarily to just distribute the load every user side versus this the reason why I'm using two dedicated load balancers is primarily because I want to ensure that uh I scaled this which is directly interacting with the users a lot more compared to how I scale the second half of my problem which is just talking to a websocket manager now the websocket manager maintains all the metadata with respect to which client is connected to which websockets that server and Etc uh and because this information does not need to be persistent we can always create it in this what I will do is I'll use a cache I'll use a reddish cache for this or managing foreign connections all right so this is what the purpose of this reddish cache will be okay uh so now we know the websocket manager will return the address of user 2 and the message will be exchanged back and forth uh so so far so good I am now able to send a message and I'm able to receive a message uh without high latency because I'm using web sockets and I'm able to get it done instantaneously cool so what happens next uh what if I'm C continuously chatting with my friend uh what would happen I sent a message and then two seconds later I sent another message and two seconds later again I send another message would I want I would not want to go back to the websocket manager every single time right primarily because I know I just had that address and I would not want to lose that address instantaneously or make unnecessary costs the websocket manager so what I would do here is I'd maintain a cash uh internally at the server level itself uh for the address which is received the timestamp at which I received leave the address and the number of open connections that I'm having at my own layer so that I don't need to reach out to the websocket manager so let me let me just bring it onto the code to check server Dash it will technically be inside the server but just to be verbose they want to explicitly write it down over here but there was a move all of this down a little bit fix this Arrow okay and I will also scale it the same level I have this so This basically just talks to this internally because they are within the same server there's no open connection here like a remote connection going on here all right so the question that now pops up is what happens if for some reason the connection in between see the chat server and the user 2 would get disconnected right uh we don't want that to happen uh but it will happen we can't avoid it uh but because I've cached the address which means that I'll now be looking at an incorrect address and the person has already moved from house a to house B uh and creates a new connection the moment the new connection is created or the connection is terminated the websocket manager will go ahead and notify the websocket chat servers that hey this address no longer exists and what we'll do is we'll invalidate the cache here saying that hey let us drop this particular person's address because that person does not live there anymore okay so that's how I would handle my sending messages my functional requirement Point number one in here of sending messages across point a and point B currently uh obviously because I'm sending messages uh and I want to ensure that there are consistency requirements here what I would do is I'll back it up with a dedicated exposed service called as the message service the message service just fairly simple task nothing out of the ordinary uh what it does is it stores the data into the database the same database which we had referred earlier down here that I don't want to lose my messages uh because this database does not have to be persistent so what we I know WhatsApp uses is a database called as Amnesia the reason why uh they use Amnesia is it supports very good Delete ability very good writability and has a very fast lookup because I'll have like a multiple billions and billions of messages reaching here I'd want to look it up by the user ID or the message ID or the sender ID and I would want to delete it Vice transcender or receiver IDs receive status okay I also want to ensure that I do not leave a the sequence of the messages broken so it reuse a Kafka as my internal messaging queue and I'd want to continue with building on top of it the reason why I would do this is because we agree that I would stick to my high consistency requirement which is mentioned over here and Kafka allows me a first in First Step proceeding sequence order so that I know that the map I'll always retain the messages in the order in which I have initially received with or without the user being connected or disconnected at the receiver's end or the sender's end whichever message reaches the server first will be what will be relayed to the user at the end of the day okay uh the flowchart would look something like this so the message reaches the message service I pass that message to the database as soon as the user 2 receives it and sends a received app I go back to the database and delete the messages from the data page I also want to ensure that I have absolute end-to-end her encryption enabled uh which is what uh WhatsApp promises us so I'll also go to the log files and delete the data from the log files and ensure that I'm not maintaining any copy of the data at the backend uh and continue with it okay so so far with me we have covered the messaging part of our process completely uh a quick time check from my end we had approximately 33 minutes into the system uh we have to go through sharing the multimedia messages and uh we'll focus in the next few minutes over there and if possible I'll also talk about group messaging after this Okay so what next we need to do handling of the message service so once the user creates a particular message right uh with a file type attached to it so let's say this is the media service properties for the typing mistake okay so the load balancer would pass in a q over okay give me arrows right good so when the user wants to send a message uh it will be a file type object I would want to store it into a particular file storage let's call it block storage the standard term of it it could be S3 it could be anything else it depends on which cloud provider you're interacting with uh so as soon as I receive the media file I will hit the post upload file method to call invoke the media service I'll install the file type here I would also need a to store the metadata of the file which had stored in the Amnesia database as a part of the basic service and we know we all keep receiving um certain messages which go viral be it in the form of images or videos if it's around New Years there's too much of happy New Year messages floating around uh I would not want uh the user to receive a huge delay on receiving messages so I'll use something called a CDN it stands for Content delivery Network what it does is if you want to download a famous media file uh it brings that file closer to your location in a server which is very close to your location so that you don't have to go back and fetch it from a very high far off distance right and that's how we would want to go ahead with uh using this service in general Okay so we continue doing this and we continue going about uh and beyond our standard server location to bring the files as close to the user's location as possible for them to be able to download it in real time uh what I would do here is I don't want to duplicate the number of files that I have been storing because storage is very costly we were looking at 300 TB per month uh worth of storage which is a lot and this is only for 100 bytes of messages being sent across uh I'm sure a media file will not be 100 bytes it will be much much more than that depends on what type of file you're sending across uh we can try putting up a limit let's say we put up a limit of say 50 mb as the maximum load says we are still looking at much more than 300 DB per month of this so we definitely want to ensure that we don't copy and paste uh the same file because it's being uploaded to multiple users what way we can do it is we can hash our code uh basically we can hash the files which are being uploaded keep the hash in a lookup table and every time a new file being is being uploaded we first convert the hash of it check it into the lookup table and see if it exists there if it exists good enough I will not upload it I'll just return the file ID to the sender and the file ID you already have because I've had I have it uploaded with me since the very beginning of time right so that way both my upload seems to become faster because I already have them and also because uh I'm saving space I'm saving a lot of money for my company right um and the CDN helps me deliver and return it quickly nothing the question that now I think I missed out on and I would want to debate is where are my users in this entirety database so I'll use a user service which kind of interacts and fetches all of this again the load balancer will do the talking for me uh with the user service and what we do here is the user service can just uh interact with a simple database let's just say I'd use the MySQL DB which basically has the metadata for all the users what I mean by metadata is things like phone number which is the primary key in case of a in case of WhatsApp uh and what we can do here is uh phone number the name the year the image icon which is the profile picture that we have is what we would want to update okay so we will be using the users table and because this information does not change every now and then I would want to keep it with me okay so so far so good we are doing pretty good on time I think I'll be able to cover a couple of more features things like trip messages and things like how to show the last scene timestamp or uh if you talk about Facebook Messenger in this particular case or any other messenger in this particular case this show the user is online or offline I'll see if I can go ahead and cover that as well as an extension to this particular design uh and I'm hoping you're finding this design simple I know I'm adding components after components but I'm trying uh to keep it simple at my end okay so let's go ahead and focus on how group user Behavior would look like right uh if I have to think about it I would create I'll move this further down uh to create more space and let's say we are looking at groups so if I'm looking at groups I would want a group service again I I love creating Services okay like Financial Services good thing to do the group service what it does is let's because it's talking to users I'll just make it uh talk to the MySQL DB itself uh without okay [Music] this is like a super bad all right this is better okay so what it will do is it will talk to the you group service it would also want to talk to uh this and what I would store in my groups is something like a little bit of a text over here so you can have something like group a uh and you'll have user one user two over here right uh so user one user two maybe a user free also if you feel perhaps because it's two groups so you'll have three users you'll have a group each group will have its own ID let's call this as um group ID so each group will have a group of ID a list of users desktop user IDs and uh that's it now a group can be treated as equivalent to a Kafka topic which you can go ahead and subscribe to so what we will do is when we are trying to relay messages in a group format we'll use the famous publisher subscriber or the pub sub model of sending messages let me just type it out here uh to ensure that we are able to explain the components to the end users correctly the sender of the message whosoever the person is Will publish a message into the Kafka messaging queue with a group ID attached to it uh and Kafka because Kafka likes maintaining uh the metadata for all the topics slash groups that it has uh it would then send out a message which is the message which is sent by say user one two user two three four five blah blah blah right that hey I received this message you are supposed to receive it and what we will do is instead of sending the message directly we'll use the message service so that we are able to do the received delivered component of it as soon as the message is delivered to all the participants we'll call it as teleport on the user screen otherwise it's always like signed and you can click individually and show it so the group service will not have any new components being added to the table we'll use leveraging components I'll talk to Kafka let me see if I can draw additional lines over here uh for my sake of doing things I really want to shrink this out okay this looks ugly but unfortunately this is what it is so we'll talk the Kafka on this front uh for sending the messages across and Kafka would eventually end up relaying the messages elsewhere all right so with this we are done with how a group message would eventually look like uh the same thing if you want to go and talk about showing the last seeing message right so the last scene message uh can be tracked no sorry uh-huh the last scene status update it can be tracked with a simple metadata storage so we know the websocket manager is always maintaining the live connections and this we can use the websocket manager to publish data into a different cache system uh let's for all this what do I call it let's call this of last scene cash the reason why I'm calling it last scene slash online is because I want to keep it generic enough for anyone who wants to understand it okay uh and the websocket manager every time it creates a new connection and terminates this can go ahead and update it okay that hey this was the time in last saw a person and then you can uh basically sending the response back is a simple uh status update and the user can just fetch uh depending on which user ID screen you are on by passing the user ID message to this so it would be something like a get message the only thing is in this thing the message is you're trying to receive is at what time did the user update his last scene status okay so with this being said we are pretty much done with whatever I would like to highlight we are good 43 minutes into the system uh if you have any questions feel free to post it into the comments and I would be happy to pick it up uh and discuss more around it in the meanwhile let's just quickly take a very a quick look at my design and see if I accidentally missed out on something while we were discussing and debating about this okay so do let me know I'll keep an eye on the comments while we discuss okay why do we do this so just to reiterate that list of topics that we have been discussing uh we spoke about this here so we spoke about things such as uh below latency we can keep minimizing our latency as and when we talk about this uh a simple way is by geographically Distributing our websocket servers and the relevant cache that is associated with those things uh around the globe in even format so that when user one tries to connect to a particular server the server is not located very far off from them uh we can also use reddish cache uh at multiple Services levels to ensure that we have enough uh latency requirements around this and we're obviously using cdns for our uh file service right that we are downloading files from the closest possible servers the consistency part again is important I'm just going sequentially through my non-functional requirements because it's the most easy one to miss uh while designing systems and Abhishek Jan I just saw your comment if you have anything please shoot okay so if you're talking about high consistency uh we definitely want to use a fee for messaging queue with a strict ordering enabled restrict ordering is a feature that comes with a configuration parameters and a lot of our messaging queues uh or we can use a sequence third type of an argument is this for Android development so we didn't talk about the front-end part of it this is more around how the messages will be uh handled at the back end perspective you can always expose it as a front-end uh or a backend application depends on how you want to look at it and expose this okay so this was the question which came up is this for a front-end development and uh sorry Android developers you are more than welcome to write an Android SDK app on top of this and build it on top of that uh backend layer we did not bring in any front-end layer into the discussion it's more about what are the apis that I'm exposing and how do you invoke it I hope that answers your question so anyways continuing from there uh when the user is offline that's the place where in uh we'll have the maximum amount of risk of the messaging sequence being halted uh because again uh it takes time for a user to come online send messages across the user can be offline because it's genuinely offline or he's you know area where there is no service and there's nothing stopping the user from sending a message uh while he's offline but then the sequence has to be maintained in the order at which the server receives the messages and they are then sent and relayed to the recipients across okay uh we can always make the system highly scalable uh by adding in more website uh chat servers and websocket managers uh we can even replicate them across multiple data centers and geographies to ensure that we have enough fault tolerance built into the system okay as soon as a user is disconnected due to a certain fault in the websocket layer the session is recreated using a load balancer but the recreated session can exist in a different server okay and does the websocket manager becomes extremely critical into resolving all the dependencies around it okay uh in terms of how I want to replicate I would prefer using a primary uh like a leader follower application model uh because it allows me to optimize for rights and at the same time keep reading messages here uh there are multiple different ways in which we can uh relay messages I would want to basically ensure that I write to maybe one leader and a few followers or maybe multiple leader and few followers on top of it Okay so that's that's pretty much all I have for today uh any other questions any trade-offs that you found difficult to understand or you found it hard for me to explain feel free to reach out to me over LinkedIn and I'll be very happy to go ahead and discuss it okay I will pause here because I know it takes time to write so I'll maybe take a pause for another uh two to five minutes and then I'll end the session foreign let me see if I can drop it here [Music] any other questions apart from this foreign [Music] thank you everyone thank you so much for your time and for uh dialing in I appreciate the help and uh best wishes uh okay I have one more question let me see if I can quickly bring it up uh this is new for me so how can you learn more about high level design uh you can learn a lot about high level design from multiple sources Geeks or Geeks itself has a system design for a layer and you can always refer to it let me see if I can quickly share the linked for the same so B for these things uh and just to reiterate so most of the system design interviews that we keep talking about uh they are primarily for senior software engineering roles at product companies as basically any company in general um and you're more than welcome to have so for example geek for geeks has this there are other good resources also uh like dropping the system interviews and other places which you can refer to but personally like weeks or weeks for both coding and uh non-coding work uh basically system design and other types of Articles to read it um so Rahul asks a question he can we have or can we have only one load balancer here yes we surely can have one load balancer the prime reason for having two was because I wanted to scale the chat server with a different configuration at my internal API services with a different uh scale parameter also I don't want to expose the external load balancer to the rest of the world I want to ensure that level of security and abstraction is minted so that people cannot play a foul play here and I want to keep a second one internal which is directly interacting with all of my internal uh microservices which you have built okay so that's pretty much it um any other questions before we tap up Aditya do you have a question which is so that you had a message um [Music] foreign how can we learn about hld for free uh there are too many options uh available for learning anything for free in this current world you just uh have to tune into a couple of resources uh if you like creating books designing data intensive applications is a really good resource uh however it's a fairly costly book is what I would assume uh if I talk about uh online sources Geeks for geeks uh and other portals are really good you can also tune into a certain set of YouTubers unfortunately I'm not one of them uh and you can always reach out to a set of famous YouTubers who talk about coding or system design in general then you can interact with them okay that would help you also in learning about this and a lot of people love writing blogs and few other things and how they want to go ahead with it okay uh okay this last question what's the future of trig native app development I'm so not the right person to ask about this uh because I specialize in back-end development and uh this that being said I know about a lot of good companies and products which use react native and I'm I hope it's a good thing but again I've never worked on it so I'm not the best person to talk about this uh okay you want me to talk a little bit more about web sockets okay sure so see websockets right is a connection protocol just like TCP or something else uh there what websockets is uniquely designed for is for chat applications okay uh or wherever you have consistent streaming uh a server up until prior to websockets was invented a server did not have the option of invoking a connection with the client so on only once a person a client in this particular case is the user unless and until the user opens up the application and sends a ping to the chat server they will not be able to access it and resolve uh messages from the server okay which was a huge limitation right think about three websocket world how many useless API calls we are making just hoping that I would receive a message okay it's more like uh okay so I'll take an example from my childhood uh I had I used to love ice creams right in the Summers and at four o'clock I knew that the ice cream would vendor would pass through my gate so I used to keep running back and forth hoping that I would be able to catch the ice cream vendor it would have been so much simpler if you knew where I lived and it would have just come knocking on my house uh saying hey the ice cream is here so that's the same type of reaction that web sockets provide websocket allows the server to send messages to this every time you wake up in the morning today and you see you have messages in the form of uh app notifications uh waiting from so many apps on your phones it happens through uh our component which is uh the websocket in lectures or the app picks up every day morning and sends it across uh however the app has been designed uh it's more like a pull-based versus a push-based model that helps us okay uh the other question is uh what is the architecture which is used over here um so I didn't use any explicit architecture which is here I split my apis into multiple Services the websocket message Service Media service user service and group Service uh that's pretty much all about this I was consistently trying to keep the design simple and uh I followed a framework the framework that they normally like following is I want to design my core applications with say a very few users one to ten users wherein I first focus on getting the functionality right and then I start diving deeper into the non-functional requirements of how I bring in things at scale and how I would make my business uh grow according to the number of users who are subscribed to it all right so that's there the other question which I have which is not related to this session but it's still here is what is Firebase um I didn't use it in the session so I'll just do a very quick high level walkthrough about it it's more about uh how do I put it uh I basically have used Fast Firebase to get my apps up and running very quickly uh with a basic managed uh infrastructure uh it's provided by multiple Cloud providers that we can exist well uh feel free to go and take a look at it I mean because this is not a topic for today's uh discussion is BYL not be able to dive deeper into it but I just wanted to do a quick scheme about this all right we are pretty much about to be on time anything else that we need to go foreign really glad and happy to interact with all of you and I hope you found this helpful uh and thank you so much uh I'll tell me read the session now thank you

Original Description

What is High Level Design? A high-level design (HLD) is a broad overview of the architecture of a system or solution. It provides a broad understanding of the system, its components, and how they will interact. A high-level design is an important step in the design process for any project, as it helps to define the overall architecture of the system and identify any major risks or issues that need to be addressed. Join Abhishek Kumar, in this live session to learn more about High Level Design. Learn how we design a messaging app like Whatsapp and understand the advantages of HLD. Don't miss out this opportunity! ------------------------------------------------------------------------------------------------------------------ Want to Learn more about System Design? Check out our Courses: System Design - Live: https://practice.geeksforgeeks.org/courses/system-design-live?utm_source=youtube&utm_medium=courseteam_main_desc&utm_campaign=resolution_days_graphs ------------------------------------------------------------------------------------------------------------------ Follow On Our Other Social Media Handles: 📱 Twitter: https://twitter.com/geeksforgeeks 📝 LinkedIn: https://www.linkedin.com/company/geeksforgeeks 🌐 Facebook: https://www.facebook.com/geeksforgeeks.org 📷 Instagram: https://www.instagram.com/geeks_for_geeks 👽 Reddit: https://www.reddit.com/user/geeksforgeeks 💬 Telegram: https://t.me/s/geeksforgeeks_official Also, Subscribe if you haven't already! :) #HighLevelDEsign #systemdesign #gfg #geeksforGeeks
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from GeeksforGeeks · GeeksforGeeks · 0 of 60

← Previous Next →
1 How I got into Walmart | Shailesh Sharma
How I got into Walmart | Shailesh Sharma
GeeksforGeeks
2 Upgrade yourself In 29 Days | GeeksforGeeks
Upgrade yourself In 29 Days | GeeksforGeeks
GeeksforGeeks
3 Learn AWS Fundamentals For Free
Learn AWS Fundamentals For Free
GeeksforGeeks
4 Conversation With Young Achievers | Meet the winners of Bi-Wizard Coding Contest | GeeksforGeeks
Conversation With Young Achievers | Meet the winners of Bi-Wizard Coding Contest | GeeksforGeeks
GeeksforGeeks
5 Meet The Winners Of Bi-Wizard Coding Contests | GeeksforGeeks
Meet The Winners Of Bi-Wizard Coding Contests | GeeksforGeeks
GeeksforGeeks
6 Interview Prep Strategies | PayPal
Interview Prep Strategies | PayPal
GeeksforGeeks
7 OLX Interview Preparation Strategies | Hukam Singh
OLX Interview Preparation Strategies | Hukam Singh
GeeksforGeeks
8 Meet Some More Winners Of Bi-Wizard Coding Contests | GeeksforGeeks
Meet Some More Winners Of Bi-Wizard Coding Contests | GeeksforGeeks
GeeksforGeeks
9 Live Mock DSA
Live Mock DSA
GeeksforGeeks
10 Microsoft Azure For Absolute Beginners
Microsoft Azure For Absolute Beginners
GeeksforGeeks
11 Python for Data Science | Data Science Master Bootcamp | Arpit Jain
Python for Data Science | Data Science Master Bootcamp | Arpit Jain
GeeksforGeeks
12 Getting Started with Data Analysis | Data Science Master Bootcamp | Ashish Jangra
Getting Started with Data Analysis | Data Science Master Bootcamp | Ashish Jangra
GeeksforGeeks
13 How to prepare theory subjects for SDE interviews | Geeks Summer Carnival 2022
How to prepare theory subjects for SDE interviews | Geeks Summer Carnival 2022
GeeksforGeeks
14 Get Your Tickets To The Geeks Summer Carnival | GeeksforGeeks
Get Your Tickets To The Geeks Summer Carnival | GeeksforGeeks
GeeksforGeeks
15 TED Talk Data Analysis Project | Data Science Master Bootcamp | Ashish Jangra
TED Talk Data Analysis Project | Data Science Master Bootcamp | Ashish Jangra
GeeksforGeeks
16 How I Secured AIR 9 in GATE'22 |  Tushar
How I Secured AIR 9 in GATE'22 | Tushar
GeeksforGeeks
17 Learn Java Backend Development | Geeks Summer Carnival | GeeksforGeeks
Learn Java Backend Development | Geeks Summer Carnival | GeeksforGeeks
GeeksforGeeks
18 How to Recognize which Data Structure to use in a question | Geeks Summer Carnival | GeeksforGeeks
How to Recognize which Data Structure to use in a question | Geeks Summer Carnival | GeeksforGeeks
GeeksforGeeks
19 Learn Data Structures and Algorithms | GeeksforGeeks
Learn Data Structures and Algorithms | GeeksforGeeks
GeeksforGeeks
20 Interview experience at Flipkart | GeeksforGeeks
Interview experience at Flipkart | GeeksforGeeks
GeeksforGeeks
21 Lets Prepare for GATE'23 the Right Way | Sakshi Singhal | GeekSummerCarnival
Lets Prepare for GATE'23 the Right Way | Sakshi Singhal | GeekSummerCarnival
GeeksforGeeks
22 Highest Paying Jobs in 2022 | Ishan Sharma | Geeks Summer Carnival 2022 | GeeksforGeeks
Highest Paying Jobs in 2022 | Ishan Sharma | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
23 Geeks Summer Carnival 2022 | 5th April- 11th April | GeeksforGeeks
Geeks Summer Carnival 2022 | 5th April- 11th April | GeeksforGeeks
GeeksforGeeks
24 Preparing for SDE interviews | Soham Mukherjee | Geeks Summer Carnival 2022 | GeeksforGeeks
Preparing for SDE interviews | Soham Mukherjee | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
25 Full Stack Development with React & Node | Utkarsh Malik | Geeks Summer Carnival | GeeksforGeeks
Full Stack Development with React & Node | Utkarsh Malik | Geeks Summer Carnival | GeeksforGeeks
GeeksforGeeks
26 Introduction to Open Source and Roadmap to GSOC 2022 | Geeks Summer Carnival 2022 | GeeksforGeeks
Introduction to Open Source and Roadmap to GSOC 2022 | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
27 Web Scraping in Action | Geeks Summer Carnival 2022 | GeeksforGeeks
Web Scraping in Action | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
28 Getting Hired at BITCS via GfG Job Portal | Get Hired With GeeksforGeeks
Getting Hired at BITCS via GfG Job Portal | Get Hired With GeeksforGeeks
GeeksforGeeks
29 How to build a faster landing Page | Geeks Summer Carnival 2022 | GeeksforGeeks
How to build a faster landing Page | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
30 Geeks Summer Carnival | 5th To 11th April, 2022 | GeeksforGeeks
Geeks Summer Carnival | 5th To 11th April, 2022 | GeeksforGeeks
GeeksforGeeks
31 How to get ideas for Startup | Geeks Summer Carnival 2022 | GeeksforGeeks
How to get ideas for Startup | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
32 Journey from Tier 3 to JusPay | GeeksforGeeks
Journey from Tier 3 to JusPay | GeeksforGeeks
GeeksforGeeks
33 Geeks Summer Carnival 2022 | GeeksforGeeks
Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
34 Dispelling Myths and Pre conceptions of Programming Languages
Dispelling Myths and Pre conceptions of Programming Languages
GeeksforGeeks
35 Must Do System Design Questions
Must Do System Design Questions
GeeksforGeeks
36 Understanding Sorting Techniques in an hour | Keerti Purswani | Geeks Summer Carnival
Understanding Sorting Techniques in an hour | Keerti Purswani | Geeks Summer Carnival
GeeksforGeeks
37 Get Hired at NEC | Job-A-Thon 8
Get Hired at NEC | Job-A-Thon 8
GeeksforGeeks
38 Journey from Tier 3 college to Microsoft | GeeksforGeeks
Journey from Tier 3 college to Microsoft | GeeksforGeeks
GeeksforGeeks
39 Get Hired with GeeksforGeeks at SuperK | Job A Thon 8
Get Hired with GeeksforGeeks at SuperK | Job A Thon 8
GeeksforGeeks
40 GeeksforGeeks: Redesigned
GeeksforGeeks: Redesigned
GeeksforGeeks
41 From Tier 3 to cracking multiple interviews | GeeksforGeeks
From Tier 3 to cracking multiple interviews | GeeksforGeeks
GeeksforGeeks
42 Live Mock DSA
Live Mock DSA
GeeksforGeeks
43 Youtube Data Analysis | Ashish Jangra | GeeksforGeeks
Youtube Data Analysis | Ashish Jangra | GeeksforGeeks
GeeksforGeeks
44 DSA Self-Paced Course Preview | Sandeep Jain | GeeksforGeeks
DSA Self-Paced Course Preview | Sandeep Jain | GeeksforGeeks
GeeksforGeeks
45 GATE Live Classes | Prepare for GATE CS 2023 | GeeksforGeeks
GATE Live Classes | Prepare for GATE CS 2023 | GeeksforGeeks
GeeksforGeeks
46 Journey from JIIT to Adobe
Journey from JIIT to Adobe
GeeksforGeeks
47 Life Is Unfair Ft. Shonty badmash | LIVE Discord Session | A GeeksforGeeks Exclusive
Life Is Unfair Ft. Shonty badmash | LIVE Discord Session | A GeeksforGeeks Exclusive
GeeksforGeeks
48 Interview Experience at Google | Tech Dose
Interview Experience at Google | Tech Dose
GeeksforGeeks
49 Live Mock DSA
Live Mock DSA
GeeksforGeeks
50 Interview Experience @ Amazon | GeeksforGeeks
Interview Experience @ Amazon | GeeksforGeeks
GeeksforGeeks
51 My journey through the tech world from India to US | Vidushi | GeeksforGeeks
My journey through the tech world from India to US | Vidushi | GeeksforGeeks
GeeksforGeeks
52 Complete Interview Preparation Course | GeeksforGeeks
Complete Interview Preparation Course | GeeksforGeeks
GeeksforGeeks
53 Live Mock DSA
Live Mock DSA
GeeksforGeeks
54 Getting Hired at FiftyFive Technologies | Job-a-thon 9.0
Getting Hired at FiftyFive Technologies | Job-a-thon 9.0
GeeksforGeeks
55 GFG Karlo, Ho Jayega | GeeksforGeeks ft. Khaleel Ahmed
GFG Karlo, Ho Jayega | GeeksforGeeks ft. Khaleel Ahmed
GeeksforGeeks
56 How I got job offers from 2 big companies : Arcesium & Microsoft | GeeksforGeeks
How I got job offers from 2 big companies : Arcesium & Microsoft | GeeksforGeeks
GeeksforGeeks
57 LINUX for Beginners | GFG x Itversity
LINUX for Beginners | GFG x Itversity
GeeksforGeeks
58 My interview experience at Walmart | GeeksforGeeks
My interview experience at Walmart | GeeksforGeeks
GeeksforGeeks
59 Get Hired at Speckyfox
Get Hired at Speckyfox
GeeksforGeeks
60 Live Mock DSA
Live Mock DSA
GeeksforGeeks

Related Reads

📰
Designing for the Surge: The Real-World Cost of Separating Reads and Writes
Learn how separating reads and writes can impact system performance and cost in real-world scenarios, particularly in high-traffic applications
Dev.to · shubham shaw
📰
Building NovaOS: A 16-bit Operating System from Scratch (in Assembly and C)
Learn to build a 16-bit operating system from scratch using Assembly and C, a fundamental project for low-level programming enthusiasts
Dev.to · Daniel Developer
📰
Stop Writing 40-Method Repositories: The Specification Pattern in Symfony
Learn to avoid fat repositories in Symfony by applying the Specification Pattern to improve code organization and maintainability
Medium · Programming
📰
You Don’t Have a Performance Problem — You Have a Design Problem
Most performance issues stem from design flaws, not coding errors, and can be solved by reevaluating system architecture
Medium · Programming
Up next
API vs MCP Explained in Telugu | What’s the Difference? | Complete Beginner Guide
Withmesravani_
Watch →