DEV Community

Cover image for System Design: WhatsApp

System Design: WhatsApp

Karan Pratap Singh on September 21, 2022

Let's design a Whatsapp like instant messaging service, similar to services like Whatsapp, Facebook Messenger, and WeChat. What is Whatsa...
Collapse
 
crayoncode profile image
crayoncode

Great article! Love how you estimated the traffic 😅

Collapse
 
othimar profile image
Pélé Oussoumanou

Impressive. I was skimming the article and those estimations caught my attention. I will read it later.

Collapse
 
andrewbaisden profile image
Andrew Baisden

Wow, so detailed good article.

Collapse
 
krishgokul profile image
Gokula Krishnan

Great work! Will try to go through all other topics too. May I know the tool used to make the diagrams please?

Collapse
 
karanpratapsingh profile image
Karan Pratap Singh

Thanks, I used excalidraw for diagrams

Collapse
 
dhanushnehru profile image
Dhanush N

Well written article.

I just made a personal WhatsApp kindoff, Just felt like mentioning it here

Collapse
 
juanvegadev profile image
Juan Vega

Nice article.

I think there is a typo on number of message estimations.

each user sends at least 10 messages to 4 different people every day.

It says 10 messages to 4 people which would be 40 message and then you use 20 messages for the calculation.

Collapse
 
emil profile image
Emil • Edited

As you are using microservices you should mention that you might not want to share a single database instance. The benefit of microservices is an independent deployment which might not work out in your setup.

But I like your explanations and thoughts

Collapse
 
alexr profile image
Alex (The Engineering Bolt) ⚡

Really good article with solid structure. Timing and structure are crucial for those type of interviews, I have also created System Design Template which is generic enough to be used for any interview but also FAANG companies.

Collapse
 
amin_memar profile image
Amin Memar

i think chats and chats_users can be deleted
i think private chat between 2 user is actually a group of 2 people
it could be separate by field called type
type 1 is group
type 2 is private chat
type 3 is channel
is that right?

Collapse
 
leexiuli profile image
Amy

estimation the tps maybe need to consider the peak of flow?

Collapse
 
chukwuemekaigbokwe profile image
Chukwuemeka Igbokwe

Fantastic job. Nice one

Collapse
 
s4kh profile image
Syerikjan Kh

50 million * 20 messages -> shouldn't this be 50 million * (4*10) = 2 billion/day?

Collapse
 
fk profile image
Fırat Küçük

Good article, tables should not contain messages. Whatsapp uses end to end encryption. Communications are handled without an intermediate server.

Collapse
 
lweiner profile image
Lukas Weiner

They are handled and stored in a database, but they are encrypted and decrypted on your phone. So that's why you can't load all message from the server as soon as you are changing your device. If you want to go deeper into the topic you can search for asymmetric cryptography. So yes the author is right with storing the message on the server, the only difference is that they are not stored as plain text, they are stored encrypted.

Collapse
 
fk profile image
Fırat Küçük • Edited

techuntold.com/where-whatsapp-mess...

The only time a message is stored on WhatsApp’s servers is if the recipient cannot receive it (maybe they’re offline or don’t have a WhatsApp account). In cases like those, the message(s) you sent are automatically deleted off of WhatsApp’s server in 30 days’ time.

So this probably has you wondering if WhatsApp doesn’t store your messages on its servers, then where are they stored? The answer is, your WhatsApp messages are stored locally on your phone in the form of encrypted backups.

Thread Thread
 
lweiner profile image
Lukas Weiner

Ah I didn't knew that, thanks for correcting me. Really interesting.

Collapse
 
lengsovandara profile image
Sovandara LENG

Great article! I love the way you raise the problem then propose the solution and what should we learn more.

Collapse
 
priyanka_khabiya_cb977dc0 profile image
Priyanka Khabiya

We are using messaging queue when user is offline, should same mechanism be used when ser is online