Technical Interview Questions

WeChat IM High-Concurrency Architecture Design

"How would you design a high-concurrency instant messaging system capable of handling billions of messages per day, similar to WeChat?"

Why Interviewers Ask This

Tencent operates WeChat, the largest IM platform in the world. This question tests your understanding of distributed systems, message queues, and real-time communication at massive scale — core competencies for any Tencent software engineer.

How to Answer

  1. 1

    Start by clarifying scale requirements: daily active users, peak QPS, message types (text, image, video), and delivery guarantees.

  2. 2

    Describe a layered architecture: access layer (long connections via TCP/WebSocket), logic layer (message routing, group chat fan-out), and storage layer (timeline-based message storage).

  3. 3

    Explain the message delivery model — write-diffusion vs. read-diffusion for group chats, and how to handle offline message sync using sequence IDs.

  4. 4

    Discuss reliability and consistency: message ACK mechanism, idempotent delivery, and how to handle network partitions and reconnections gracefully.

Sample Answer

I would design the system in three layers. The access layer maintains persistent TCP connections with clients using an Epoll-based server, supporting millions of concurrent connections per node behind a load balancer. The logic layer handles message routing: for one-on-one chats, messages are pushed directly to the recipient's connection server; for group chats, I'd use write-diffusion for small groups and read-diffusion for large groups to balance storage and latency. The storage layer uses a timeline model where each user has an ordered inbox, indexed by monotonically increasing sequence IDs so clients can sync missed messages efficiently. Messages are first written to a reliable message queue like Kafka for durability, then asynchronously persisted to a distributed KV store. For high availability, I'd deploy across multiple data centers with eventual consistency, using CRDTs for conflict resolution on concurrent edits. Monitoring would track end-to-end delivery latency, message loss rate, and connection stability.

Pro Tips

  • Reference WeChat's known architecture choices like the MMTLS protocol and Mars network library to show domain knowledge.

  • Quantify your design — mention specific numbers like 100 billion messages/day to demonstrate you understand the scale.

  • Discuss trade-offs explicitly, such as write-diffusion vs. read-diffusion and when each is appropriate.

Frequently Asked Questions

What is the difference between write-diffusion and read-diffusion in group messaging?

Write-diffusion copies the message to each member's inbox at send time, which is fast for reads but expensive for large groups. Read-diffusion stores one copy and fans out at read time, saving storage but adding read latency. WeChat uses write-diffusion for groups under 500 and read-diffusion for larger ones.

How does WeChat handle message ordering?

WeChat uses server-assigned sequence IDs per conversation. Each message gets a monotonically increasing ID, and clients use their last-seen sequence to pull missed messages. This ensures consistent ordering without relying on client timestamps.

Worried About Going Blank in Your Interview?

HireMe AI listens to your interview in real-time, detects questions, and generates instant answer suggestions — so you never freeze up again.

Try HireMe AI Free