Mobile Development 22 min read

Design and Implementation of Baidu Android IM SDK and Public IM System

Baidu built a unified Android IM SDK and public instant‑messaging system that consolidates login, message routing, synchronization, notifications, and group chat into reusable client and server components, using a hybrid push‑pull model to deliver real‑time, secure communication while dramatically lowering development and maintenance costs across its product portfolio.

Baidu Geek Talk
Baidu Geek Talk
Baidu Geek Talk
Design and Implementation of Baidu Android IM SDK and Public IM System

In the mobile Internet era, the rapid growth of social media, mobile payment, and online shopping has created a strong demand for instant messaging (IM) capabilities. Integrating an IM SDK into an app can dramatically reduce development cost and accelerate the construction of a reliable IM system.

Background : Baidu’s various apps (Baidu App, Wenxin Yiyan, Tieba, Haokan Video, etc.) each built their own IM solutions, leading to high development and maintenance costs as well as duplicated functionality. A shared public IM system was therefore required so that each product line could simply integrate the common service.

IM System Overview : An IM system provides real‑time message exchange, user status management, conversation storage and retrieval, group chat, file transfer, voice/video calls, and other extended features.

Baidu Public IM System Architecture : The system consists of a client side (IM SDK, long‑connection SDK, IM plug‑in, group chat component) and a server side (authentication, message routing, conversation sync, notification, user & setting management). The client accesses the IM SDK and long‑connection SDK, while the server exposes public APIs for business services.

Component Responsibilities :

Business server: handles business‑specific logic and invokes public IM server APIs for message sending/receiving.

IM server: provides real‑time login, message delivery, conversation sync, notification, and user/setting management.

Long‑connection SDK: manages data protocol, encryption, access control, compression, connection creation, maintenance, and error handling.

IM SDK: implements login, message & conversation management, unread count, user & setting management.

IM plug‑in: builds chat UI on top of the long‑connection SDK and IM SDK.

Group chat component: packages group chat UI and logic for direct integration.

Core Processes :

3.2.1 Login Management : Initializes environment, monitors network/account/connection status, performs automatic reconnection and re‑login when conditions recover.

3.2.2 Data Synchronization : After login, the client pulls offline single‑chat and group‑chat conversations, messages, and member data via the long‑connection SDK. Optimizations include version‑code based incremental sync and a message pull queue to reduce QPS.

3.2.3 Notification Management : Server pushes notifications for new messages, read status, deletions, top‑pin changes, etc. Clients receive the notification, then pull the actual data to keep UI consistent across multiple devices.

3.2.4 Message Send/Receive : Two approaches were evaluated – client pull vs. server push. A hybrid push‑pull model was adopted: the server pushes a lightweight notification, the client then pulls the full message to ensure reliability and reduce bandwidth.

Failure handling includes retry mechanisms for both upstream (message send) and downstream (message receipt) paths, as well as reconnection logic for the long‑connection channel.

Summary : The public IM system provides a high‑cohesion, extensible set of components (long‑connection SDK, IM SDK, chat plug‑in, group component) and supports multiple deployment containers (mid‑platform NA, HN, public web). It delivers real‑time, reliable, and secure IM services, dramatically reducing development effort and cost for Baidu’s product lines while ensuring a consistent user experience across devices.

Mobile DevelopmentSystem Architecturereliabilityreal-time communicationAndroid SDKInstant Messaging
Baidu Geek Talk
Written by

Baidu Geek Talk

Follow us to discover more Baidu tech insights.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.