Audio Stream Gateway Architecture: Design, Evolution, and High Availability
This article introduces the architecture, evolution, and high availability construction of the audio stream gateway, covering audio basics, system design, and practical applications in real-time audio processing.
This article introduces the architecture, evolution, and high availability construction of the audio stream gateway, covering audio basics, system design, and practical applications in real-time audio processing.
The article begins by explaining the importance of real-time audio technology in applications like voice/video calls and its use in scenarios such as live streaming review and broker training at Beike. It then covers audio fundamentals including sampling depth, sampling rate, and channels, with calculations showing that each frame processed by the gateway is 640 bytes.
The gateway architecture follows a Dispatcher-Worker pattern where the Dispatcher manages tasks and controls Workers through HTTP interfaces. Workers use real-time audio SDKs to enter rooms for streaming. The system uses Go's os/exec package to launch external processes with bidirectional pipes for communication. Key structures include the Cmd struct with Process member for process control.
For streaming, the system handles room entry/exit timing, role-based stream pulling/merging/relaying, and stateful service horizontal scaling. The pull stream process involves entering rooms, transmitting audio frames (accumulating 10 frames for efficiency), and implementing retransmission mechanisms for lost packets. Push stream operations use a 20ms interval ticker for sending audio packets.
The article discusses optimizations including heartbeat mechanisms to prevent audio gaps, memory pooling using sync.Pool to reduce allocation overhead, and high availability features like rate limiting with Sentinel, CPU-based capacity calculation, and status monitoring interfaces.
Five main application scenarios are presented: broker training, recording/transcoding, teleprompter functionality, live streaming review, and network voice broadcasting. The conclusion emphasizes how technology enhances human communication and service quality.
Beike Product & Technology
As Beike's official product and technology account, we are committed to building a platform for sharing Beike's product and technology insights, targeting internet/O2O developers and product professionals. We share high-quality original articles, tech salon events, and recruitment information weekly. Welcome to follow us.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.