Design and Architecture of Bilibili Comment System
This article presents a comprehensive overview of Bilibili's comment system, detailing its background, core functional modules, layered architecture, storage and caching strategies, availability considerations, and hot‑comment design, illustrating how the platform achieves scalability, performance, and reliability for massive user interactions.
The article begins with an introduction to the concept of comments and their importance on Bilibili, noting the evolution of the comment system from simple text to a componentized, platform‑wide service.
01 Background outlines the motivation for redesigning the comment infrastructure to handle growing traffic and complexity.
02 Basic Functional Modules lists core capabilities such as publishing, reading, deleting, interaction (like, dislike, report), management (pin, feature, admin operations), rich‑text display, tagging, decorations, and hot‑comment management.
03 Architecture Design is divided into several sub‑components:
reply‑interface : the entry layer serving both client comment widgets and downstream services, providing view‑model APIs and handling security, flow control, and BFF responsibilities.
reply‑admin : an admin service for complex query, search, and audit operations, built on Elasticsearch with a unified data‑retrieval layer.
reply‑service : the core comment service offering atomic operations (list, delete, etc.) with multi‑level caching, Bloom filters, and hotspot detection.
reply‑job : an asynchronous processing layer handling cache‑aside updates, binlog consumption, and coordination with reply‑service to avoid cache stampedes.
04 Storage Design describes the relational schema (comment table, comment‑area table, content table) and the classification of fields (relationship, counters, status, meta). It also provides example SQL queries for fetching comment lists.
05 Availability Design discusses write and read hotspots, including batch writes, memory aggregation, thread‑pool offloading, and hotspot detection using sliding‑window LFU algorithms.
06 Security Design covers data security (consistency, compliance, priority handling) and public‑opinion safety (error handling, user experience, and mitigation of misleading feedback).
07 Hot‑Comment Design defines hot comments, explains ranking factors (likes, replies, relevance, decay, length, user level), outlines challenges such as large sorted‑set keys, real‑time rate calculations, and the need for a flexible strategy layer that combines rule‑based and AI‑driven scoring.
The article concludes with a vision for continuous optimization of hot‑comment algorithms, balancing user experience, commercial value, and system robustness.
Architect
Professional architect sharing high‑quality architecture insights. Topics include high‑availability, high‑performance, high‑stability architectures, big data, machine learning, Java, system and distributed architecture, AI, and practical large‑scale architecture case studies. Open to ideas‑driven architects who enjoy sharing and learning.
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.