The article discusses building a highly scalable distributed messaging system similar to WhatsApp, with requirements such as 1:1 chat, sending text and images, last seen, and read receipts. The system must have low latency, high availability, and no lag, making it a real-time system. The architecture consists of a chat server, clients, and a database, with a focus on message delivery models, including pull and push models. The push model uses WebSockets to enable real-time message transmission, and a WebSocket handler maintains open connections with active users. The system also includes a WebSocket manager and a message service to track connections and store messages. The article discusses various use cases, such as when both users are online or offline, and how messages are stored and retrieved from the database. The database schema is also discussed, including the use of NoSQL databases like AWS DynamoDB. The goal of the system is to deliver messages instantly while keeping the system efficient. The article concludes that a messaging system should be fast, reliable, and scalable, and that the push model with WebSockets enables real-time communication. The author has over a decade of experience in scalable, high-performance distributed systems and has worked on cloud-native architectures and database optimization.
dev.to
dev.to
