Design and Implementation of Baidu's Janus General Gateway Service

The article explains why Baidu built the high‑performance Janus gateway, its architecture and deployment topology, the three routing modes, the three‑level rule system with variable and condition expressions, plugin extensibility, performance benchmarks, and how the design can be generalized to other use cases.

High Availability Architecture
High Availability Architecture
High Availability Architecture
Design and Implementation of Baidu's Janus General Gateway Service

Baidu's Janus is a multi‑million QPS general gateway that handles internal traffic for services such as Feed, comments, likes, and also external traffic for Baidu App, Zhidao, and other products. It complements the open‑source BFE by offering a more flexible, plug‑in‑based solution that can serve as a traffic, business, or hybrid gateway.

The service topology includes a flow diagram and deployment topology illustrated in the original article, showing how Janus sits between clients and downstream services.

Janus supports three routing modes: traffic gateway, business gateway, and hybrid gateway. Simple routing rules use domain matching and tree‑based URL routing, while complex rules are expressed with variable and condition expressions, allowing fine‑grained control such as splitting traffic by data center, app version, or query parameters.

Variable expressions use placeholders like ${idc}, ${time}, ${query}, and ${header}. They can be hierarchical, e.g., ${request.query.id}. Condition expressions combine these variables with logical operators and function calls, forming a minimal expression language that compiles to Go code.

Performance tests compare the compiled expression against native Go code, showing less than a 10% overhead (e.g., 34.52 ns/op vs. 31.63 ns/op for a random‑number check).

Plugin design follows the same principle: a generic plugin (e.g., disaster‑recovery or cache) is configured with a condition expression that determines when the plugin runs, and with a user‑defined key expression for cache identification, enabling both universality and per‑business customization.

The article concludes that Janus’s combination of simple routing, extensible variable/condition expressions, and plug‑in architecture provides a scalable solution for diverse traffic‑control needs and can be further generalized by integrating more Go standard‑library features.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Backendplugin architecturetraffic routinggatewaycondition expressionvariable expression
High Availability Architecture
Written by

High Availability Architecture

Official account for High Availability Architecture.

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.