How Baidu Wenku App Migrated Its Backend from PHP to Go: Lessons and Results

This article details Baidu Wenku App's backend migration from a PHP‑based stack to Go, covering the motivation, technical debt, technology selection, step‑by‑step migration strategy, quality assurance practices, performance improvements, and key takeaways for large‑scale service refactoring.

Baidu Geek Talk
Baidu Geek Talk
Baidu Geek Talk
How Baidu Wenku App Migrated Its Backend from PHP to Go: Lessons and Results

The Baidu Wenku App originally used PHP (PHP 5.6) with HHVM to serve its backend, but growing traffic pushed the system toward its limits, prompting a need for higher load capacity, better performance, and improved developer productivity.

Motivation

Increasing traffic and user‑experience demands (e.g., faster search rendering and new homepage features) made the legacy PHP stack unsustainable, while internal cost‑reduction goals encouraged a technology‑stack upgrade.

Technical Debt of the PHP Stack

Outdated language version with low execution efficiency and security risks.

Highly coupled business logic, many deprecated interfaces, and poor code readability.

Technology Selection

Two internal frameworks were evaluated:

PHP7 ODP3 framework (Phaster) : provides high‑performance HTTP/FastCGI services but remains tied to PHP.

Go GDP2 framework : offers strong concurrency support, rich ecosystem, and better resource utilization.

After comparing features, scalability, and ecosystem health, the team chose the Go‑based GDP2 framework.

Migration Planning and Execution

An agile, incremental approach was adopted to avoid a risky waterfall migration. Traffic analysis identified the top 50 interfaces that accounted for over 99% of traffic, establishing migration priority.

Step 1: Estimate workload by ranking interfaces by QPS.

Step 2: Define migration strategy—gradually shift traffic from PHP to Go, ensuring no functional regression.

Step 3: Maintain a mixed PHP+Go environment during transition, using gateway routing to direct traffic without changing client paths.

Gray‑release techniques (e.g., Nginx+Lua, ApiSix, BFE) were used for critical interfaces.

Go Infrastructure Setup

Scaffolding : Provide built‑in coroutine wrappers and project templates.

Build & Release : Automate compilation, environment‑variable handling, and binary packaging.

Deployment : Use hot‑restart modules for zero‑downtime binary replacement.

Traffic Routing : CS‑architecture requires gateway‑level rewrite to route requests to Go load balancers.

Monitoring : Structured logs, distributed tracing, and resource‑usage dashboards for observability.

Quality Assurance

Go services underwent functional testing, performance (stress) testing, and continuous monitoring for CPU/memory leaks. A comprehensive quality‑assurance matrix covered offline tests, online observability, and automated alerts.

Refactoring Outcomes

Key product improvements included a customized new homepage and an optimized search results page, yielding:

~30% average API latency reduction (TP90 reduced by 35%).

~50% reduction in the number of backend instances after traffic migration.

Cleaner codebase with eliminated bad smells, improved readability, and easier maintenance.

Performance gains were especially notable on Android (‑41% latency) and iOS (‑43% latency) for search results.

Conclusion & Lessons Learned

Maintain backward compatibility for existing clients during migration.

Break large projects into incremental goals and iterate quickly.

Communicate risks and rollback plans with product managers.

Continuously monitor service health after traffic shifts to catch anomalies early.

“Knowing without acting is ignorance; acting without knowing can lead to insight.”
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.

Performance OptimizationSystem ArchitectureMicroservicesBackend DevelopmentGoPHPTechnology Migration
Baidu Geek Talk
Written by

Baidu Geek Talk

Follow us to discover more Baidu tech insights.

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.