Designing an instant messaging service

zhuting
1 min readMay 15, 2022

A text-based instant messaging service allows users to chat with their friends from both phones and website. For example, whatsApp / Slack /Facebook Messenger.

Requirements and Goal of the System

  • Support one-on-one conversation, a real-time chatting experience with minimum latency
  • Keep track of the online/offline statuses of its users
  • Support the persistent storage of chat history
  • High consistence, users should see the same chat history on all their devices
  • Others: group chats, push notifications, media uploads, read receipts…

High Level Design

At a high level, we will need a chat server that will be the central piece orchestrating all the communications between users.

When a user wants to send a message to another user, they will connect to chat server and send message to the server; the server then pass that message to the other user and also stores it in the database.

Draw with Miro

Let’s talk about these scenarios one by one.

Message Handling

There are two options to get a message from the server:

Pull model: Users periodically ask the server if there are any new messages for them

Push model: Users can keep a connection with the server and can depend on the server to notify them whenever there are new messages

--

--