Scaling WhatsApp: How WhatsApp Handles Billions of Messages Daily

Whatsapp

WhatsApp, with over 2 billion users worldwide, processes an astronomical number of messages every day. Despite its simplicity, the engineering behind WhatsApp’s architecture is incredibly sophisticated, ensuring low latency, high availability, and end-to-end encryption. In this blog, we’ll dive deep into how WhatsApp scales to handle billions of messages while maintaining its performance and reliability.

1. WhatsApp’s Core Architecture

WhatsApp operates on a distributed system architecture, where multiple servers and data centers work together to handle massive traffic. Its core system comprises the following components:

  • Client Applications: WhatsApp has clients for iOS, Android, and Web, which communicate with backend servers.
  • Load Balancers: Distribute incoming requests efficiently to prevent overloading any single server.
  • Messaging Servers: Responsible for storing, routing, and delivering messages efficiently.
  • Database Systems: Store user data, message metadata, and encryption keys.
  • Media Storage Servers: Handle multimedia (images, videos, documents) separate from text messages.
  • Push Notification Service: Ensures real-time delivery of messages using Apple Push Notification Service (APNS) and Google Firebase Cloud Messaging (FCM).

Key Statistic

With an estimated 100 billion messages sent per day, that’s around 1.16 million messages per second being processed by WhatsApp’s infrastructure.

Given that each message has an average size of 1 KB, this translates to:

  • Per second: 1.16 million KB = 1.16 GB of data per second
  • Per hour: 1.16 GB × 3600 = 4.176 TB of data per hour
  • Per day: 4.176 TB × 24 = 100.2 TB of data per day

Storage

Assuming each message on average is 1KB, we will require about 2000 GB of database storage every day.

100 billion×1KB=∼2000 GB/day 

As per our requirements, we also know that around 5 percent of our daily messages (100 million) are media files. If we assume each file is 100 KB on average, we will require 10 TB of storage every day.

100 million×100 KB=10 TB/day

And for 10 years, we will require about 36 PB of storage.

10 TB×10 years×365 days=∼36 PB

Bandwidth

As our system is handling 10 TB of ingress every day, we will require a minimum bandwidth of around 120 MB per second.

10.2 TB/(24 hrs×3600 seconds)=∼120 MB/second


2. Efficient Message Routing & Delivery

2.1 Store-and-Forward Mechanism

WhatsApp does not store messages permanently; instead, it follows a store-and-forward model:

  • When a user sends a message, it reaches the WhatsApp messaging server.
  • The server holds the message temporarily until it is successfully delivered to the recipient.
  • Once delivered, the message is deleted from the server (except in multi-device mode).

This mechanism reduces the storage burden on WhatsApp’s backend and ensures efficient message routing.

2.2 Message Queues for High Availability

WhatsApp utilizes Erlang-based message queues to handle millions of concurrent messages. The benefits of using Erlang include:

  • Fault tolerance: If a message queue crashes, another node can take over seamlessly.
  • Concurrency: Erlang’s lightweight processes enable millions of simultaneous connections.
  • Scalability: New servers can be added dynamically without downtime.

Given 2 billion users and an average of 50 messages per user daily, WhatsApp handles 100 billion messages per day, requiring robust queuing mechanisms.

Considering an average message latency of 100 milliseconds (0.1s), the system processes:

  • Messages in transit at any moment: 1.16 million × 0.1 = 116,000 messages
  • Concurrent active connections: Assuming each user is active for 2 hours daily, there are 166 million concurrent connections.

2.3 Multi-Device Synchronization

With the introduction of multi-device support, messages are now stored temporarily across multiple devices and encrypted to maintain security. WhatsApp replicates messages across multiple servers until all intended devices have received them.

3. Scaling the Infrastructure

3.1 Distributed Databases

WhatsApp uses NoSQL databases like RocksDB and Apache Cassandra to manage metadata and store message state. These databases allow:

  • Horizontal scalability: Data is sharded across multiple servers.
  • High throughput: Read/write operations occur with low latency.
  • Replication: Ensures data consistency and fault tolerance.

With a peak of 1.16 million messages per second, database systems must handle an estimated 6.96 million read/write operations per second considering metadata, acknowledgments, and encryption data.

Each metadata entry is around 200 bytes. The estimated metadata storage requirement per day is:

  • Metadata per second: 1.16 million × 200 bytes = 232 MB/s
  • Per hour: 232 MB × 3600 = 835.2 GB per hour
  • Per day: 835.2 GB × 24 = 20 TB per day

3.2 Load Balancing & Traffic Distribution

To handle billions of users efficiently, WhatsApp employs:

  • Global load balancers that direct requests to the nearest data center.
  • Regional data centers to reduce latency and improve performance.
  • Autoscaling servers that dynamically adjust based on traffic spikes (e.g., New Year’s Eve surge).

3.3 Content Delivery Network (CDN) for Media

WhatsApp uses CDNs to cache and serve media files (images, videos, voice notes) closer to users, reducing latency and bandwidth costs.

Given that 20% of messages contain media with an average size of 500 KB, the estimated media traffic per day is:

  • Media messages per day: 20% of 100 billion = 20 billion messages
  • Total media data per day: 20 billion × 500 KB = 10 PB (Petabytes)

4. Ensuring Security & Privacy at Scale

4.1 End-to-End Encryption (E2EE)

WhatsApp secures messages using Signal Protocol, ensuring that only the sender and recipient can decrypt messages. Encryption happens:

  • On the sender’s device before transmission.
  • On the recipient’s device upon receipt.
  • No message content is stored on WhatsApp’s servers.

4.2 Secure Authentication & Spam Prevention

  • Uses HMAC-based one-time passwords (OTP) for user verification.
  • Employs machine learning models to detect and block spam, fake accounts, and abusive content.

5. Handling Peak Traffic & Failure Recovery

5.1 Handling Message Spikes

Events like New Year’s Eve and global emergencies cause traffic spikes. WhatsApp handles these by:

  • Auto-scaling its infrastructure on demand.
  • Prioritizing critical messages (text over media) during congestion.
  • Caching frequently accessed data to reduce database load.

On peak days, traffic can double or even triple, meaning WhatsApp could process 200-300 billion messages daily!

5.2 Disaster Recovery & Redundancy

WhatsApp maintains geo-redundant backups to ensure data availability. In case of failures:

  • Replication servers take over the workload.
  • Failover mechanisms ensure that user experience remains unaffected.
  • Automatic retries resend messages in case of temporary failures.

Conclusion

WhatsApp’s engineering is a prime example of how a simple-looking messaging app scales to serve billions of users. By leveraging distributed systems, Erlang-based messaging queues, encryption protocols, and auto-scaling infrastructure, WhatsApp ensures fast, reliable, and secure message delivery at an unprecedented scale.

Understanding WhatsApp’s architecture provides insights into designing highly scalable and fault-tolerant systems, making it a great case study for software engineers and architects alike.

Previous Article

Understanding Rate Limiters in System Design

Next Article

Caching 101: How Tech Giants Like Cloudflare and Meta Speed Up Your Apps

View Comments (4)

Leave a Comment

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