Guides

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/

37 Comments

  • Hemant Jain

    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)?

  • Kinjal Mistry

    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?

  • Darwin Betancur

    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.

  • Torab Shaikh

    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.

  • InfClouds

    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)?

  • Sebastian Bazzano

    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?

  • Atul Srivastava

    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 ?

  • Rajkishor Mahanada

    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?

  • jedk94

    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?

  • shashankcool

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

  • Дмитрий Ямпольский

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

  • Shuai Peng

    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.

  • Ralph Fischer

    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?

  • Muktadir Khan

    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.

Leave a Reply

Your email address will not be published. Required fields are marked *