How WeChat and Momo Solve Mobile IM Challenges: Protocols, Power Saving, and Massive Scaling

The article analyzes the core technical challenges of mobile instant‑messaging services—battery consumption, limited traffic, unreliable networks—and explains how WeChat and Momo design hybrid short‑/long‑connection protocols, use protobuf, intelligent routing, load‑balancing, sharding and distributed algorithms to achieve high reliability and scalability.

ITFLY8 Architecture Home
ITFLY8 Architecture Home
ITFLY8 Architecture Home
How WeChat and Momo Solve Mobile IM Challenges: Protocols, Power Saving, and Massive Scaling

WeChat, Momo and similar instant‑messaging (IM) apps face three major constraints on mobile devices: limited battery, capped traffic (e.g., 30 MB/month for many users) and diverse network conditions.

Battery usage must be minimized, so engineers audit background processes and adjust heartbeat intervals. Traffic efficiency is crucial; a single packet should accomplish as much as possible.

Network reliability is the most critical factor. While XMPP works well on strong networks, it performs poorly on weak or intermittent connections, leading to high latency, large XML payloads and message loss.

WeChat abandoned XMPP in favor of a hybrid approach that combines short‑HTTP links (short.weixin.qq.com) for stateful protocol messages and long TCP connections (long.weixin.qq.com) for real‑time data. The short link runs on port 8080, uses a binary protobuf body, and supports interfaces such as user login, friend management, message sync, avatar retrieval, logout and behavior‑log reporting. The long link also runs on port 8080, providing binary TCP streams for sending/receiving text, voice, images and video files.

All requests are based on a persistent TCP connection; large media are transferred via two‑step uploads (thumbnail first, then full data) and downloads (thumbnail first, then full data).

Protocol design emphasizes efficiency (fast in weak networks), reliability (no message loss) and extensibility. The format draws inspiration from the Redis protocol and uses protobuf for cross‑language serialization, offering smaller payloads than JSON.

Momo’s early implementation also used XMPP but suffered from high traffic, unreliability across Wi‑Fi/2G/3G/4G, complex login flows and tight coupling between connection and logic layers. Their redesign introduced a private protocol with the same goals of efficiency, reliability and easy extension.

Key optimizations include:

Connection layer: simple asynchronous message forwarding, supporting up to 700 k concurrent connections per server; current load is 1.5 billion users, 5 hundred million monthly active users, 12 million+ connections.

Logic layer: session validation, message storage and asynchronous queues.

Adoption of a private protocol modeled after Redis, providing high performance in weak networks.

Separate lightweight long connections for real‑time data; media use separate TCP/HTTP connections.

Comprehensive monitoring app to track operational status.

Intelligent routing: dual‑protocol (TCP/HTTP) support, concurrent IP/port testing, automatic fallback from TCP to HTTP, preference for the nearest reachable IP, and periodic backend updates of IP lists.

Load‑balancing challenges such as single‑point bottlenecks and DNS latency are addressed by distributing traffic from the client side and using multiple IPs without relying on domain names.

WNS (Wireless Network Services) further tackles mobile‑specific issues: high latency, low bandwidth, high packet loss, multiple carriers, and complex network environments (2G/3G/4G/Wi‑Fi, CMWAP/CMNET). Performance metrics include development time (1.5 years), 99.9 % connection success rate, and a crash rate of 0.02 %.

WeChat’s backend architecture focuses on distributed consistency, replication, sharding, and automated failover. Data is stored with strong consistency, using techniques such as Paxos/quorum algorithms, consistent hashing, and automatic migration of shards. The system balances throughput, asynchrony, complexity, and libco usage, while providing automatic error repair and full‑memory storage options like Bitcask.

Overall, the design demonstrates how large‑scale IM services can achieve efficient, reliable, and extensible communication across heterogeneous mobile networks.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ProtobufWeChatProtocol DesignMomoIM architectureScalable Backend
ITFLY8 Architecture Home
Written by

ITFLY8 Architecture Home

ITFLY8 Architecture Home - focused on architecture knowledge sharing and exchange, covering project management and product design. Includes large-scale distributed website architecture (high performance, high availability, caching, message queues...), design patterns, architecture patterns, big data, project management (SCRUM, PMP, Prince2), product design, and more.

0 followers
Reader feedback

How this landed with the community

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.