system-architecture

WhatsApp Architecture: Unveiling the Software Development Architecture

Sandeep Reddy

May 1, 2024
WhatsApp Architecture: Unveiling the Software Development Architecture
Table of Contents

The image you provided depicts a simplified version of the WhatsApp architecture. Let’s break it down:

1. Mobile Users:
— Represents individual devices (smartphones) that people use to access WhatsApp.
— Each mobile device has a local SQLite DB where user data and messages are stored.

2. Communication Protocols:
— Devices connect using both the HTTP and XMPP (Extensible Messaging and Presence Protocol) protocols. HTTP is commonly used for web services, while XMPP is tailored for real-time chat applications.

3. YAWS Server:
— This is the server that handles web requests, specifically those made using HTTP.

4. Custom ejabberd Server Cluster:
— Represents the core server cluster of WhatsApp, which manages message routing and user presence. It is custom-built on the ejabberd framework, a robust XMPP server.

5. Media Data:
— This component handles multimedia messages, like photos, videos, and voice notes. The diagram suggests a flow where media is processed differently from text messages.

6. Media Store CDN:
— Content Delivery Network (CDN) for media storage. CDNs are distributed systems that deliver content based on the user’s geographic location to ensure fast and efficient access.

7. Databases:
— 
Mnesia DB Cluster: A distributed database management system that’s a part of the Erlang runtime system.
— 
MySQL/PostgreSQL: Relational database systems, which could be used for structured data storage.
— 
Riak: A distributed NoSQL database, suitable for high-velocity applications.

8. GCM/APNs:
— Refers to the push notification systems. GCM (Google Cloud Messaging) is now known as Firebase Cloud Messaging (FCM) and is used for Android devices. APNs (Apple Push Notification Service) is for iOS devices.

9. Offline Users:
— A component to represent users who are not currently online or active. The architecture likely ensures that messages meant for offline users are stored and delivered once they come online.

10. Write-only:
— This indicates certain data operations where data can be written to the storage but not read or modified. It ensures data integrity and security for specific operations.

From this diagram, you can glean that WhatsApp has a distributed architecture with a mix of relational and NoSQL databases, specialized servers for handling messaging, media storage solutions, and integrations with platform-specific push notification services. The separation of components ensures scalability and performance for a massive user base.

Here’s a textual representation of how you might structure it:

1. Top Layer (User Interfaces):
— Mobile Clients (Android, iOS, etc.)
— Web Client (WhatsApp Web)

2. Communication Layer:
— WebSockets (for real-time bidirectional communication with the web client)
— XMPP Protocol (or its modified version for mobile clients)

3. Application Servers:
— Erlang-based Servers (handling requests, routing messages)
— YAWS (handling web requests)

4. Security Layer:
— End-to-end Encryption (using the Signal Protocol)
— Rate Limiting Mechanisms

5. Data Management and Storage:
— SQLite (Local database on mobile clients)
— RocksDB (Server-side storage)
— Multimedia Files Storage (links to Google Drive and iCloud for backups)

6. Supporting Services:
— Notifications (using APNs for iOS and FCM for Android)
— Puppeteer (for web application testing)
— Traffic Management (Load balancers)

7. Infrastructure:
— FreeBSD (Operating system on servers)
— Geo-redundant Data Centers

Certainly! Let’s delve deeper into each aspect of WhatsApp’s architecture:

1. Client-Server Model:
— In this model, client devices (like smartphones) request services, and servers provide them. WhatsApp clients send messages to the server, which then routes the messages to the intended recipients. This structure enables centralized management and facilitates scalability.

2. Erlang:
— Developed by Ericsson, Erlang is a functional, concurrent programming language and runtime system. Its strength lies in building scalable and maintainable applications, making it perfect for a service like WhatsApp that needs high concurrency.

3. YAWS (Yet Another Web Server):
— YAWS outperforms many other web servers in terms of concurrent connections, making it apt for services that anticipate numerous simultaneous connections. YAWS also integrates seamlessly with Erlang-based applications.

4. FreeBSD:
— An advanced OS for modern server, desktop, and embedded platforms. WhatsApp chose FreeBSD for its performance and advanced networking features. It’s known for its reliability and robustness.

5. Ejabberd XMPP Server:
— This is a robust and scalable XMPP server. XMPP is a communication protocol for message-oriented middleware. While WhatsApp started with XMPP, they’ve made significant modifications for performance enhancements.

6. End-to-end Encryption:
— This ensures that only the sender and the intended recipient can read a message. Even if intercepted during transmission, the content remains encrypted and unreadable. The Signal Protocol achieves this through a combination of asymmetric and symmetric cryptography.

7. Multimedia Files Storage:
— WhatsApp’s decision to use cloud backups (like Google Drive and iCloud) was mainly for user convenience, allowing users to restore their messages and media when switching devices.

8. WebSockets:
— Unlike the traditional request-response model, WebSockets allow servers to push information to clients. This technology is instrumental for real-time applications like WhatsApp Web, ensuring that messages are delivered instantly.

9. Databases:
— 
SQLite: A C-language library that provides a lightweight disk-based database. It doesn’t require a separate server process. Ideal for mobile apps like WhatsApp.
— 
RocksDB: Developed by Facebook, it’s an embeddable persistent key-value store. It’s optimized for fast storage with a focus on SSDs and in-memory build-ups.

10. Puppeteer:
— Developed by Chrome’s team, Puppeteer is a node library offering a high-level API to control headless Chrome browsers. This aids in automating tasks within the browser, crucial for testing web applications.

11. Geo-redundancy:
— By having data centers in multiple locations, WhatsApp ensures that if one center faces issues, another can take over, guaranteeing uninterrupted service.

12. Traffic Management:
— With billions of messages daily, traffic management tools ensure efficient data routing, minimizing lags or downtimes.

13. Rate Limiting:
— By imposing limits on the number of requests from a user in a specific time frame, WhatsApp prevents system overloads and misuse.

14. Notifications:
— Services like APNs (for iOS) and FCM (for Android) are crucial for notifying users of new messages, especially when the app isn’t open.

15. Data Compression:
— Data compression reduces the amount of data sent over the network, ensuring quicker message deliveries and reduced data consumption for users.

While this goes into more depth, it’s important to note that the intricacies of WhatsApp’s architecture and its proprietary modifications aren’t fully disclosed to the public. This overview provides a foundational understanding based on the available information.

Related Posts

Schedule a meeting to take your business to the next level.

    Get a Quote