Bilibili Engineering Open-Sources Next-Gen Real-Time Danmaku Engine with Zero-Latency Edge WebSockets and WebGPU Silhouette Occlusion
Bilibili's infrastructure engineering team has open-sourced the next-generation core of its planetary-scale Danmaku (bullet chat) broadcast platform, providing developers worldwide with the tools to implement high-throughput real-time streaming commentary.
The open-source release encompasses the Go-based Comet connection gateway, which leverages native Linux epoll event loops to support over 1,000,000 active concurrent WebSocket and TCP connections per 64-core bare-metal host. The gateway implements a two-tier fan-out topology decoupled from business logic via Kafka streaming partitions and Redis Cluster Pub/Sub channels.
In addition to server-side infrastructure, the release includes Bilibili's client-side rendering pipeline: a kinematic 2D spatial collision avoidance algorithm that calculates flight trajectories across video tracks to eliminate overlapping text, and a WebAssembly/WebGPU AI segmentation engine (Smart Danmaku) that extracts real-time 8-bit alpha masks of human subjects, rendering bullet comments behind on-screen creators.
By replacing standard stringified JSON with compressed binary Protocol Buffer packets, the architecture slashes per-message network overhead by 93%, demonstrating how high-concurrency platforms can scale interactive streaming sustainably.
Bilibili Danmaku Architecture: Real-Time WebSocket Message Fan-Out, Spatial Collision Avoidance & Client-Side Wasm Person Masking (2026)
Want to examine the code implementation, system diagrams, latency benchmarks, and operational trade-offs? Read our comprehensive peer-reviewed engineering guide.