Peak-Hour IM Customer Service Stability: An Engineering Plan for No Loss, No Duplication, No Reordering
Delivery customer service at dinner rush, instant-retail consultations at 8 PM during a big promotion—when traffic spikes hit, the first problems an IM service system exposes are usually message latency, duplicate push notifications, and out-of-sync session states. When users see replies that never arrive or the same message pop up twice, trust in the system evaporates within minutes.
This is the second article in an experience-sharing series on "AI customer service product and engineering practice," drawn from hands-on practice as an AI Product Manager focused on IM intelligent customer service at a local-life services platform. In this post I want to share how to design a solution covering the messaging pipeline, session state management, idempotency, and exception recovery when the IM system suffers message latency, duplicate pushes, and inconsistent session states during peak hours, and how to define core stability and experience metrics.
What makes this work valuable is that it drags product managers back to the engineering scene: the "intelligence" of smart customer service is built on the "reliability" of the messaging channel. A PM who does not understand the pipeline can only shout "add more machines" during an incident, unable to join the real decision-making.

Four Key Points in Stability Design
- Understand the technical pipeline of an IM system: the roles and bottlenecks of send/receive, storage, push, and sync.
- Grasp the three pillars of message reliability: no loss, no duplication, no reordering.
- Design fault tolerance with idempotency, retry, and degradation mechanisms, not just isolated point fixes.
- Define quantifiable stability and experience metrics, turning "stable" into an acceptance criterion.
Overall Approach
I would structure the work in six steps: problem localization → pipeline optimization → idempotency → state management → exception recovery → metrics.
Step 1: Localize Before Acting
When latency and duplicate pushes appear at peak, I would not rush to add machines. First, check full-link monitoring and use instrumentation to identify the bottleneck: access-layer throttling, message-queue backlog, storage hotspots, or push-channel congestion. Expanding capacity at the wrong layer wastes resources and fixes nothing.
Step 2: Optimize the Messaging Pipeline
- Unique message ID + per-session seq number: clients deduplicate and reorder by session seq—one mechanism solves both "no duplication" and "no reordering."
- Dual-channel push: online users get long-connection push with automatic fallback to client pull on failure; offline users rely on pull as the backstop, guaranteeing no loss.
- Tiered throttling: during peaks, throttle by business priority—user consultations and human-handoff requests rank above marketing pushes.
- Queue-based peak shaving: decouple write and delivery asynchronously so sudden spikes are absorbed by the queue instead of piercing the service.
Step 3: Idempotency
- The server consumes messages idempotently by message ID; duplicate deliveries are processed only once.
- The sender follows a "persist first, then deliver, clean up after ack" local-transaction pattern, avoiding "sent but not recorded."
- The API layer returns the same result for repeated requests, eliminating side effects like double deductions or double sends.
Step 4: Session State Management
State changes—online/offline, bot/human, read/unread—are synchronized through an event log + version number: clients do incremental sync by comparing versions; when inconsistency is detected, reconciliation repairs it with the server as the source of truth. State problems are consistency problems; they need a reconcilable mechanism, not luck.
Step 5: Exception Recovery
- Failed deliveries enter a retry queue with a max retry count; beyond the limit they move to compensation tasks.
- Provide a per-session message reconciliation API so clients automatically backfill missing messages after reconnecting.
- Maintain degradation switches: in extreme cases, disable non-core features to keep basic send/receive alive.
Core Metrics
- System stability: message arrival rate (target ≥99.99%), end-to-end P99 latency, duplicate rate, reorder rate, service availability (four nines).
- User experience: first-response time, session-state sync delay, post-reconnect message backfill time, complaint rate.
Any metric degradation should be quickly attributable to a specific pipeline segment through instrumentation—the point of metrics is not reporting but shortening incident localization time.
Practice in Weiyu
The IM foundation of Weiyu, the open-source AI customer service system (GitHub, website), is built around exactly this reliability philosophy: a Netty-based WebSocket/MQTT long-connection channel supports massive concurrent sessions, with message send/receive and session state managed by core modules; Redis caching and message queues provide asynchronous peak shaving; multi-channel access (web, mobile, desktop) shares the same reliability guarantees. Service-specific links—first response, session assignment, human handoff—have dedicated state management that connects with the session statistics module, making it easy to monitor service quality during peak hours.
Takeaways
- The first action in a peak incident is full-link localization, not capacity expansion.
- Unique ID + seq is the minimal complete solution for "no duplication, no reordering"; push + pull dual channels guarantee "no loss."
- Idempotency must span three places: server consumption, sender transactions, and the API layer.
- Session state relies on event log + version + reconciliation; recovery relies on tiered retries and degradation switches.
- Metrics must be layered: system-side arrival rate and latency, user-side first response and state-sync delay—all quickly attributable.
