![How to Design WhatsApp or Facebook Messenger? [Solved]](https://miro.medium.com/v2/resize:fit:656/0*-vEcyEQvncwDlQFX.png)
Hello guys, if you are preparing for system design interview but struggling to solve system design problem like how to design WhatsApp, YouTube, Instagram, Twitter in a limited amount of time then you have come to the right place.
In the past, I have shared the best System design courses, books, System Design Websites, System Design Cheat Sheet, Mock interview platform, Newsletter, YouTube channels, Blogs, Roadmap, as well 25 Software Design questions and today, I am going to do something special.
Today, we will discuss a popular System design problem, how to design a messaging app like WhatsApp, telegram, or Facebook Messenger, or any chat application like Yahoo Messenger which I used to love when I first started using internet 25 years back.
In 5 to 6 minutes, you will learn what kind of database you can use, how you can store messages, what API you can provide, and how to design the whole system so that you can handle it when it comes to interviews.
By the way, if you are preparing for System design interviews and want to learn System Design in depth then you can also checkout sites like ByteByteGo, Design Guru, Exponent, Codemia.io, Educative, Codemia.io, Bugfree.ai, and Udemy which have many great System design courses and a System design interview template like this which you can use to answer any System Design question.

If you need more choices, you can also see this list of best System Design courses, books, and websites.
How to design WhatsApp or Facebook Messenger in System Design interview?
In interview, you have very limited time so its important that you follow a process like requirement gathering, coming up with essential features, high level design, and low level design to leave a lasting impression on interviewers.
Let’s start with requirements gathering:
1. Requirements
The requirements are simple:
- A user can send a chat message to another user
- Users are spread across the globe
It’s important to not choose complicated requirements like group messaging, live calls, group calls, sending images, creating groups etc at the start.
Choose the feature you can implement in limited amount of time
2. Data Storage
After specifying requirement, the next thing you should come up is with the data model. You can also choose between SQL and NoSQL at this point. The main database tables are shown in the diagram. The friends and groups tables are used as join tables between users.
A NoSQL database such as Cassandra is a potential solution to store chat messages.
But I’ll use MySQL to store account metadata and chat messages because:
- It offers strong tooling support
- The relational data model is a solid discipline
AWS S3 Object storage can be used to store media files shared in the chat.
Memcached or Redis can be used to improve data access efficiency by storing group chat messages and the presence status of people.
The Set data type in Redis can be used to track the online presence status of users.

3. API
After building data model then next logical thing is to come up with the API. The messaging app API is categorized into web API and real-time API.
The web API provides HTTP endpoints for users to log in and perform actions such as changing account details.
And the real-time API should provide WebSockets for bi-directional communication. It can relay chat messages and online presence status.
The API should be paginated for scalability. For example, the user only needs to get a limited number of messages.
A popular technique for API pagination is offset pagination. The idea is to send the number of results per page and the page number in the request parameters.
If you want to see the code for API, you can also checkout the editorial solution of Facebook Messenger Problem on Codemia.io which is very similar to this problem.
4. High-Level Design
A client-server architecture can be used to build the messaging app. Here is a simple design you can use to build WhatsApp, Facebook Messenger or any other Messaging app:

A monolith written in Java can be used to build the chat server.
The gateway server should be a stateless in-memory service. The messages get pushed to the client over WebSockets.
Consistent hashing can be used to route the user connection to the relevant gateway server.
Vitess can be used to partition MySQL because it automates the burden of scaling out.
The replication factor of the chat data store must be set to 3 for durability.
A service registry should be installed for services to discover each other and communicate.
A job queue using Redis Streams or Kafka can be used to defer non-critical actions like creating a message search index.
An edge proxy can be used for SSL termination.
Protobuf or Thrift can be used for high-performance data serialization.
A random unique token can be added to chat messages to prevent them from being displayed twice.
A CDN can be used to store the media assets that are shared in chat messages.
5. Design Deep Dive
A snapshot of the data on the server can be sent to the client for data synchronization between the client and the server.
The client can connect to the nearest data center using GeoDNS.
The data can be replicated asynchronously between data centers. This will reduce complexity and prevent data consistency issues.
![How to Design WhatsApp or Facebook Messenger? [Solved]](https://miro.medium.com/v2/resize:fit:656/0*-vEcyEQvncwDlQFX.png)
Best System Design Interviews Resources
And, here are curated list of best system design books, online courses, and practice websites which you can check to better prepare for System design interviews. Most of these courses also answer questions I have shared here.
- ByteByteGo: A live book and course by Alex Xu for System design interview preparation. It contains all the content of System Design Interview book volume 1 and 2 and will be updated with volume 3 which is coming soon.
- Exponent: A specialized site for interview prep especially for FAANG companies like Amazon and Google, They also have a great system design course and many other material which can help you crack FAAN interviews.
- DesignGurus Grokking System Design Course: An interactive learning platform with hands-on exercises and real-world scenarios to strengthen your system design skills.
- Codemia.io — This is a new, Leetcode style, AI powered platform for practicing system design problems but also gives editorial solution of popular System design problems like designing Twitter or Pastebin etc.
- “System Design Interview” by Alex Xu: This book provides an in-depth exploration of system design concepts, strategies, and interview preparation tips.
- “Designing Data-Intensive Applications” by Martin Kleppmann: A comprehensive guide that covers the principles and practices for designing scalable and reliable systems.
- SystemDesign.one Newsletter by Neo Kim, if you are looking for a weekly newsletter on system design then consider subscribing to this newsletter. And receive simplified system design case studies straight to your inbox. It cover the fundamentals and deep dives in my newsletter.
- “System Design Primer” on GitHub: A curated list of resources, including articles, books, and videos, to help you prepare for system design interviews.
- Educative’s System Design Course: An interactive learning platform with hands-on exercises and real-world scenarios to strengthen your system design skills.
- High Scalability Blog: A blog that features articles and case studies on the architecture of high-traffic websites and scalable systems.
- YouTube Channels: Check out channels like “Gaurav Sen” and “Tech Dummies” for insightful videos on system design concepts and interview preparation.
- Bugfree.ai: This is a popular platform for technical interview preparation. The System Design tag on this website includes a variety of questions to practice.

image_credit — ByteByteGo
Always remember to combine theoretical knowledge with practical application by working on real-world projects and participating in mock interviews. Continuous practice and learning will undoubtedly enhance your proficiency in system design interviews.
That’s all about how to design WhatsApp, Facebook Messenger or any other messaging app in System Design Interview. The main challenge is time, hence you must be prepared and follow an approach like the one I have shared in this solution.
This will not only save time but also help you to mention all key points to interviewer like requirement gathering, designing decision, high level design, low level design and your choices.
Other System Design Articles and Resources you may like
- How to design Twitter or X in System Design Interview?
- Top 5 Places to learn System design and Software design
- Is DesignGuru’s System Design Course worth it
- 16 best Resources to Prepare for System Design Interview
- 100+ System Design Interview Questions and Problems
- Is Exponent’s System Design Course worth it?
- 16 Best System Design Interview Resources for Developers
- Is System Design Interview RoadMap by DesignGuru worth it?
- 10 Reasons to Learn System Design for Software Engineers?
- 6 Best System Design and API Design Interactive Courses
- Top 5 System Design YouTube Channels for Engineers
- 10 Best Places to Learn System Design Online
- How to Prepare for System Design Interview?
- Is ByteByteGo really worth the hype?
- 10 Software Design Courses for Developers
- My Favorite Software Design Courses for Beginners
- Is Designing Data intensive application book worth reading?
Thanks for reading this article so far. If you like this engineering blogs then please share with your friends and colleagues. If you have any questions feel free to ask in comments.
P. S. — By the way, DesignGuru.io also have many other Grokking courses to prepare for essential coding interview topics like OOP Design, System Design, Dynamic Programming etc and you can get access to all of their courses for a big discount by joining their All course bundle. You can also use code GURU to get 30% discount.
No comments:
Post a Comment