Whatsapp System Design: Chat Messaging Systems for Interviews



The Whatsapp system architecture is a common system design interview question. This interview question asks us to select a set of features like sending chat messages, read receipts, group messaging and last seen visibility.

The chat system must be scalable and have other non functional requirements like message ordering, retrial, idempotency, load balancing and image sharing.

“Grokking the System Design Interview” Course:
LOW LEVEL DESIGN: http://educative.io/gaurav-OOD
Use the coupon code “GS-OOD-10” for a 10% discount. It’s valid globally for the first 500 users.

HIGH LEVEL DESIGN: https://www.educative.io/collection/5668639101419520/5649050225344512?affiliate_id=4793322061168640

Check out the other system design videos on the channel here:

References:
https://spectrum.ieee.org/tech-talk/computing/software/how-facebooks-software-engineers-prepare-messenger-for-new-years-eve
http://highscalability.com/blog/2014/2/26/the-whatsapp-architecture-facebook-bought-for-19-billion.html
http://highscalability.com/blog/2014/3/31/how-whatsapp-grew-to-nearly-500-million-users-11000-cores-an.html

2:35 Tinder video – https://youtu.be/tndzLznxq40
3:20 System Design Playlist – https://www.youtube.com/playlist?list=PLMCXHnjXnTnvo6alSjVkgxV-VH6EPyvoX
15:00 Load balancer – https://youtu.be/K0Ta65OqQkY
21:00 Consistent Hashing – https://youtu.be/zaRkONvyGr8
21:55 Message Queues – https://youtu.be/oUJbuFMyBDk
23:05 Messaging idempotency and ordering – https://youtu.be/WzBzYX1aSrU

#SystemDesign #DesignWhatsapp #gkcs

Become a channel member!
https://www.youtube.com/channel/UCRPMAqdtSgd0Ipeef7iFsKw/join

You can follow me on:
Facebook: https://facebook.com/gkcs0/
Quora: https://www.quora.com/profile/Gaurav-Sen-6
GitHub: https://github.com/gkcs
LinkedIn: https://www.linkedin.com/in/gaurav-sen-56b6a941/

Related Posts
Web Application Architecture – Load Balancing and Caching

Watch Part 3 of Web Application Architecture here: https://youtu.be/fW4DrKBO98w High Availability is the thing you would require when your app Read more

System Design Interview Question: DESIGN A PARKING LOT – asked at Google, Facebook

In-depth system discussion of a popular coding interview question, chapters: 0:32 Problem statement 0:55 Finding a solution 2:43 Questions to Read more

UBER System design | OLA system design | uber architecture | amazon interview question

Systems design: What is the system design of the Uber App? Systems design: What is the architecture for the OLA? Read more

System Design: Messenger service like Whatsapp or WeChat – Interview Question

This is a system design interview question asked at companies like Amazon, Facebook, Google, Microsoft and many startups: How to Read more

37 thoughts on “Whatsapp System Design: Chat Messaging Systems for Interviews”

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

    Reply
  2. Thank you for the great video. Quick question. Why did we use Web socket for chat functionality in WhatsApp whereas we used XMPP in Tinder for the same?

    Reply
  3. Great video!, but I think that you should speak a little bit slower because for most of us (Latin people) Indian accent is a little bit difficult to understand.

    Reply
  4. Hi Gaurav, thanks for your awesome videos. I am a software developer and I like to think about various famous platforms design and chat application was the most interesting system of them all. I read about various protocols for real time messaging. Which is the best among XMPP, websockets and Mqtt. I have done a lot of work in mqtt so I know this is not for chatting as it does not have message queuing but still can it be used? Also, if i want to use xmpp then how can use it in pythons or node. Thanks in advance.

    Reply
  5. 1. How would mobile push notifications be handled? The endpoints to send push notifications are controlled by Apple/Android, so I don't think WebSockets can be used. I think we should have a separate microservice that sends requests to these endpoints upon receiving message if user does not currently have a connection (app is closed).
    2. I would like more detail for each database table – SQL or NoSQL? Specific DB engine? Schema (data types and indexes)?

    Reply
  6. Hi Gaurav, I have a question about how Whatsapp calls works. This is the thing: An european embassy, is giving dates for citizenship process in my country throught whatsapp´s videocalls in a hour time lapse a day. The demand is overwhelming and almost no one can get a call. I was wondering how Whatsapp server deliver a call to a mobile. I mean, I have to let the app ringing or should I hang and retry over and over?. There is a way to get a priority for my call?

    Reply
  7. Nice explanation but I have some queries.. 1. Gateway means API Gateway or something else ? 2. Is this system cost effective. ? 3. How do we maintain session in Session service. Chat service works in stateless environment ? 4. Can you share complete UML of this design ?

    Reply
  8. I am not able to understand . As part of the micro services. Which could use in whatsapp chart and how's the database powering up app's architecture?

    Reply
  9. Nice video! Could you possibly elaborate on how consistent hashing comes into play with the groups service? I understood the concept when you explained it as part of load balancing, but don't see the connection here. Are you just saying you use load balancing for requests to the groups service?

    Reply
  10. Long polling is actually not polling for messages once a minute, but quite opposite. And it's a realtime technology.

    Reply
  11. Hi Gaurav, I have a question. I find the session service and the group service are essentially a message broker that decides where to route the message to. Why not simply use a off-the-shelf message borker like Redis, RabbitMQ? For example, each chat is a topic, regardless group chat or one-to-one chat. Being in a chat means subscribing to the topic representing the chat.

    Reply
  12. I have a question. What if the recipient of the message isn't online? How would the 'session' service route the message? It seems like this architecture doesn't allow for message persistence and only works if the recipient is actually online. Am I missing something?

    Reply
  13. 10:19 what if now the sender (A) has disconnected from gateway 1 and got connected to another gateway maybe because he was offline. The read receipt would never reach him ever. Because the db at session knows that A was connected to Gateway 1 but actually it's not. It's got some other gateway this time.

    Reply

Leave a Comment