Backend Development 20 min read

Design and Practice of Billion‑User IM Long‑Connection Service at 58.com

The article summarizes the second 58.com instant‑messaging technology salon, detailing the architecture, high‑performance long‑connection design, multi‑thread socket models, read‑write diffusion storage strategies for single‑ and group‑chat, message synchronization mechanisms, and the IM SDK framework for audio‑video communication.

58 Tech
58 Tech
58 Tech
Design and Practice of Billion‑User IM Long‑Connection Service at 58.com

On December 1, 58.com and Tencent Cloud co‑hosted the second instant‑messaging (IM) technology salon in Wangjing Science Park, featuring over 160 engineers from Alibaba, Tencent, Meituan and other companies. The event showcased several technical talks on IM service design, message storage, multi‑device synchronization, and audio‑video communication.

Long‑Connection Service Design – The talk by Xu Gang described the billion‑user IM service (named "MicroChat") that supports Android, iOS, web and PC clients. Requirements include high performance, high concurrency, multi‑platform compatibility and stable connections. Design goals focus on maximizing connections per machine, efficient CPU utilization, and optimal memory allocation.

Thread Model and Socket Listening – Three socket listening models were examined: single‑thread listener, multi‑thread listener with accept competition, and an optimized full‑thread model. The final design combines per‑core thread count, fd%thread distribution, and Linux SO_REUSEPORT port reuse to achieve load balancing and eliminate the thundering‑herd problem.

Message Storage Architecture – For single‑chat, a read‑diffusion scheme stores messages per conversation with globally increasing IDs, while a per‑user session list tracks the latest message ID. For group chat, a dedicated group‑session record stores the latest message ID to avoid write‑diffusion across all members. Mechanisms for ordering, asynchronous updates, and session list merging were also presented.

Message Synchronization Mechanism – The system pushes messages to online users and synchronizes offline messages by first syncing the session list. Clients send their existing session information; the server returns only missing sessions and messages. Message lists are linked via previous‑message IDs, enabling clients to detect gaps and request missing messages, with dynamic chain reconstruction to handle concurrency.

IM SDK Framework and Audio‑Video Integration – Zhang Hui and Zhang Zhixin introduced the IM SDK (MicroChat SDK) architecture, a three‑layer design (presentation, business logic, data access). The audio‑video solution (WRTC) provides SDK modules for media capture, encoding, signaling, and room management, supporting one‑to‑one, multi‑party calls, and interactive live streaming.

The article also includes numerous diagrams and photos from the event, and provides links to the full presentations for deeper study.

distributed systemsbackend architecturescalabilityIMAudio-VideoLong ConnectionMessage Storage
58 Tech
Written by

58 Tech

Official tech channel of 58, a platform for tech innovation, sharing, and communication.

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.