Messenger API Design Decisions

Understand some of the primary technical considerations that will direct the design of the Messenger API.

Introduction

The design of Messenger API will involve many services that each play a role in sending, receiving, and storing user messages. In this lesson, we’ll go over Messenger's high-level design and the workflow for handling requests of different functional requirements. Next, we’ll consider some technical aspects that affect our design decisions—for example, API architectural styles, communication protocols, and data formats.

Design overview

The following illustration shows the components and services involved in Messenger API. Incoming requests go through three main services:

  1. Asset service: This service handles media and documents sent via chat messages.

  2. User data services: This service manages user profile data and the relevant metadata.

  3. Real-time services: These services are responsible for two-way user communication, such as chat.

Apart from these services, there are also some components that facilitate these services, such as Zookeeper and messaging queue. The detailed responsibilities of each of these services and components are listed in the table below:

Press + to interact
The working architecture of Messenger's services
The working architecture of Messenger's services

The following table discusses the purpose of each component in the Messenger system:

Components and Services Details

Component or Service

Details

User data service

  • User relevant data is accessed or stored via this service in the relevant database

Asset service

  • Responsible for storing/retrieving media files in the blob storage

Messages service

  • Facilitates retrieval of messages on new/alternative devices


Messaging queue

  • Serves as buffer space for temporarily holding users’ messages
  • Enables asynchronous communication between chat service and persistence storage
  • Decouples services aiding system scalability

Zookeeper

  • A service discovery that keeps a check on the health of various servers

WebSocket manager

  • Keeps mapping of active/online users and the ports assigned to them

Chat server

  • Facilitates message delivery between sender and receiver

Presence server

  • Responsible for managing users' online status

API gateway

  • Authenticates and authorizes a user request
  • Performs request throttling and caches responses to frequently made API calls. For example, data related to specific conversations or user profiles can be cached to reduce the load on the backend servers.

Workflow

Let's discuss the workflow of the Messenger service in detail. First, the login process is initiated via the API gateway, where the request is authenticated and authorized based on the data fetched via the user data service. In the next step, when a sender intends to ...

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.