How a Frontend Team Supercharged TikTok E‑Commerce IM with Rust

This article details how the TikTok e‑commerce frontend team tackled high‑concurrency and multi‑instance challenges in their Electron‑based IM client by incrementally redesigning the architecture, introducing a Rust‑based SDK, validating performance through POCs, and ultimately achieving significant stability and latency improvements.

ELab Team
ELab Team
ELab Team
How a Frontend Team Supercharged TikTok E‑Commerce IM with Rust

IM x Rust

Overview

The article introduces the Feige frontend team’s effort to improve the Feige IM client’s handling capacity by combining Rust with their existing React+Electron stack, moving from concept validation through path decomposition to full implementation and performance verification.

Background

Feige is a chat tool for TikTok e‑commerce, linking pre‑sale, sale, and post‑sale channels. The desktop IM faces challenges such as conversation stability, smooth operation, and cold‑start speed. After reaching >98% user satisfaction, two hard problems emerged: high‑concurrency reception and multi‑instance support.

Why Rust?

The IM SDK requires high stability, heavy asynchronous usage, and strict memory and thread safety. C++ was deemed risky for the team, while Rust’s safety‑focused language features and strong compiler reduce bugs, and the Feishu ecosystem provides useful Rust libraries, making it a suitable choice.

Comparison of Rust and C++

Difficulty: Hard for both.

Memory safety: Rust compiler guarantees; C++ relies on manual checks.

Async support: Rust offers native async/await; C++ has complex async futures and coroutines.

Thread safety: Built‑in in Rust; manual in C++.

Developer burden: Lower for Rust.

Library maturity: Semi‑mature for Rust, mature for C++.

Historical Architecture

The original architecture shared a WebView between the IM SDK and business JS code, causing CPU and I/O contention under high load, leading to message delays and UI lag. Multi‑instance support required multiple WebViews, resulting in linear memory growth.

New Architecture and Expected Benefits

Rust runs as an independent process handling all IM SDK computation, greatly reducing JS thread pressure.

The Rust SDK removes browser I/O limits.

Eliminates dependence on WebView survival, enabling more concurrent accounts.

Proof of Concept

Three models—single‑process single‑thread, multi‑process, and multi‑thread—were built as MVP demos and stress‑tested. Results showed Rust outperforms JS, especially under heavy CPU load (up to 3× faster), and the independent Rust process offered the best stability with minimal performance loss.

Path Decomposition

The long‑term project was broken into phases to manage risk and deliver incremental value.

Phase 1: Strengthen Basic IM Capabilities

Established a Rust foundation, built business containers, cross‑process call wrappers, logging, async execution environment, and cross‑platform compilation.

Phase 2: Implement Full IM SDK in Rust

Designed multi‑instance SDK, defined JS‑to‑Rust protocols, implemented core functionality, performed extensive regression and performance testing, and created fallback mechanisms for crashes or network errors.

Phase 3: Upgrade SDK Form Factor

Worked on multi‑window support, increased concurrent accounts to 25, refined message notification flow, and accelerated local message rendering.

Challenges and Experience

Programming Language & IM Knowledge

Team members embraced continuous learning, leveraged Rust’s safety features, and built a supportive learning environment.

Maintaining Confidence in Long‑Term Projects

Leadership support and shared values.

Focus on long‑term benefits and delayed gratification.

Break work into short, verifiable stages.

Strengthen personal expertise to proactively solve problems.

Efficient Collaboration

With limited native developers, the team designed parallel development routes, prioritized protocol and interface design, assigned tasks based on expertise, and maintained close communication during integration.

Gray‑Release Practices

Health checks that switch to the old solution on anomalies.

Comprehensive business and technical monitoring (crash rate, unresponsive rate, online chain length, message success rate, request success rate, lag rate).

User‑experience tracking via feedback groups and direct merchant contact.

Controlled rollout: whitelist testing, incremental exposure, real‑time feedback monitoring.

Reducing IPC Communication Cost

Adopt protobuf for compact, fast serialization.

Batch updates with debounce and deduplication.

Cache data on the Rust side to avoid frequent JS queries.

Result Collection

Extreme‑scenario metrics were captured with custom busy‑and‑lag indicators to surface improvements not visible in aggregate data.

Rust SDK Issue Governance

Early instability required extensive logging.

Close contact with real users accelerated verification.

Built convenient log retrieval and analysis tools.

Benefits

Stress Test

Before optimization: severe lag, slow inbound lines, and unusable experience under high load. After optimization: smooth, stable operation.

Data Improvements

End‑to‑end message latency reduced by 40%.

Message success rate improved from three‑9 to four‑9.

IM page lag rate decreased by 15% overall.

In high‑concurrency reception, lag reduced by 50%.

Since deployment, no major lag complaints have been reported.

RustElectronCross-Processim-sdk
ELab Team
Written by

ELab Team

Sharing fresh technical insights

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.