How Baidu’s Hulk Framework Accelerates Go Service Development
The Hulk framework, built on GDP2, provides a business‑oriented Go web development platform with out‑of‑the‑box components, standardized architecture, rich observability, and tooling that together improve code quality, development speed, and SRE efficiency for large‑scale short‑video services.
1. Background
Hulk is a Go service development framework created by the short‑video R&D team on top of GDP2 (Go Develop Platform). It is a business‑focused web framework offering many ready‑to‑use components to quickly build web services, and together with best‑practice development and operations, it forms a Go ecosystem suited to the business scenario.
1.1 Why Upgrade the Architecture?
The previous architecture suffered from low development efficiency due to a single codebase shared by many developers, high merge conflict frequency, and costly code maintenance. Release efficiency was limited because only one branch could be deployed at a time, leading to “riding‑the‑car” release patterns that increased risk. PHP’s runtime efficiency and resource cost became unacceptable at tens of millions of DAU, prompting a shift to a more efficient language and service model.
1.2 Why Not Use GDP2 Directly?
During the Go service upgrade, GDP2 had not yet been officially released, which was one of the reasons for building Hulk.
1.3 Hulk vs. GDP2 Capability Comparison
Hulk reuses many GDP2 capabilities (e.g., bns, net, codec) and adds second‑level wrappers for business‑specific needs such as http server, RAL, Redis, MySQL, scheduled tasks, and service governance. It also integrates industry‑proven infrastructure like Prometheus + Grafana, Sentry, and fault‑location systems.
2. Understanding Hulk
2.1 Design Philosophy
Hulk follows a layered architecture with four layers: basic components, common components, extended components, and application‑level logic. It emphasizes reusable, plug‑and‑play modules and seamless integration with surrounding infrastructure.
2.2 Framework Structure
Key layers include:
Basic Components : logging (compatible with PHP and ftrace formats), cloud‑native monitoring (Prometheus metrics for HTTP, Redis, RAL, etc.), configuration center (Apollo/iConf with versioning, hot‑release, gray‑release, permission control), event tracing (Sentry integration), and distributed lock (Redis‑based, using redsync).
Common Components : RAL wrapper with lazy loading and hooks (monitoring, circuit‑break, downgrade), service governance (Sentinel‑based flow control, rate limiting, circuit‑break, downgrade), coroutine pool (goroutine reuse, panic handling, WaitGroup support), event notification (integration with Ruliu for alerts).
Extended Components : Redis client with metrics, Sentry, and downgrade hooks; MySQL client with metrics and Sentry hooks; distributed lock implementation; scheduled tasks with optional distributed lock mode.
HTTP Server : provides many middleware (logger, timer, recover, flow control, timeout, etc.) and management interfaces (health check, governance, metrics, debugging).
2.3 Framework Ecosystem
The ecosystem includes standard directory conventions, a code generator for scaffolding, the hklib common library (50+ service clients), infrastructure services (Prometheus + Thanos, Sentry, Apollo, Pyroscope), a custom configuration center (iconf), and the Artemis service visualization and fault‑location system.
2.4 Framework Adoption
All short‑video Go services now run on Hulk, achieving measurable resource and performance gains compared to the previous PHP stack.
3. Framework Capabilities and Applications
3.1 Improving Code Quality
Hulk enhances code quality through standardized project layout, code generators, adherence to Baidu’s Go style guide, static analysis tools (go_fmt, goc), and integrated performance testing (nGrinder) and profiling (Pyroscope).
3.2 Accelerating Development Iteration
Rich reusable components (enhanced Redis/MySQL, open‑source tools like Sentry, Prometheus + Grafana, Apollo) and configurable middleware reduce the need for custom code and enable rapid feature delivery.
3.3 Enhancing SRE Efficiency
Real‑time event tracing (Sentry), alerting (Ruliu), multi‑dimensional monitoring (Prometheus and SIA), ftrace‑compatible logging, and the Artemis visualization platform provide fast problem detection, detailed diagnostics, and service call‑chain analysis.
3.4 Service Visualization and Intelligent Fault Localization
Artemis offers deployment topology views, near‑real‑time multi‑dimensional metrics, key log aggregation with context and stack traces, and call‑chain graphs that highlight latency and availability issues across services and downstream dependencies.
4. Conclusion
Although Hulk is a new Go web framework, it builds on internal and open‑source foundations, adapts them to Baidu’s business needs, and, together with the surrounding Go ecosystem, provides strong support across development, deployment, operation, and maintenance phases.
5. References
Framework documentation:
GDP2 information:
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
21CTO
21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.
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.
