How We Upgraded to PHP 7: Challenges, Benchmarks, and Ops Insights
This article recounts the Huajiao team's migration from PHP 5 to PHP 7, detailing the motivations, upgrade hurdles, extensive performance benchmarks, gray‑release strategy, and operational steps that together delivered up to 30% CPU savings and significant cost reductions.
Background
Before the PHP 7 upgrade, Huajiao’s backend was written entirely in PHP 5.*. During high‑traffic events such as the live stream of Olympic champion Zhang Jike, the system faced massive load spikes, CPU exhaustion, and long request queues, forcing the team to rely on horizontal scaling.
Re‑writing in another language would have taken too long, so the team evaluated PHP 7, whose official performance claims promised a milestone improvement.
Challenges and Benefits
Challenges: Frequent minor version releases (almost monthly in 2016) raised stability concerns. Potential bugs in high‑concurrency or special scenarios were unproven. Numerous dependent extensions could complicate RPM management. Large‑scale production upgrades risked operational difficulty. Being the first product line to run PHP 7 added risk. Benefits: Official benchmarks indicated substantial performance gains, better supporting high‑concurrency workloads. Higher efficiency translated into lower server resource consumption and cost. The new technology boosted team enthusiasm and sense of achievement.
Performance Benchmarks
Bird’s official test showed a 2.77× QPS increase for WordPress on PHP 7 versus PHP 5.6.
Latency dropped from 2.991 s to 1.186 s, a 60% reduction.
PHP 5.3 consumes more system resources than PHP 7, though the gap narrows with low load. Under concurrency, PHP 7’s resource usage is roughly half that of PHP 5.3. Both versions experience occasional timeout errors due to network bottlenecks. PHP 7’s TPS is 16‑22% higher than PHP 5.3.
Framework‑level tests showed PHP 7 using far fewer resources; at 1,000 concurrent users the system approached its limit but still handled most requests.
Pure Redis calls: PHP 7 is over three times faster than PHP 5.3. Mixed Redis + MySQL calls: PHP 7 is more than twice as fast.
Upgrade Process
The team performed a gray‑release by deploying a new PHP 7 cluster and routing a small subset of users (by region) to it via DNS. After monitoring for 1‑2 weeks and confirming stability, traffic was gradually shifted to the new environment.
Post‑Upgrade Performance Impact
CPU usage improved by nearly 30% after the November 4‑6 upgrade. Assuming a server cost of ¥10,000, a 10‑node cluster saves ¥30,000; a 100‑node cluster saves ¥300,000; and a 10,000‑node deployment could save ¥3 million.
Result: Significant resource and cost savings were realized, confirming the benchmark expectations.
Operational Details
The PHP 7 RPM package used was addops-php-7.0.10-1.el6.x86_64 with a comprehensive set of compile options (prefix, FPM, opcache, GD, MySQL, PostgreSQL, etc.).
Configuration and package deployment were managed through the HULK platform’s Puppet cluster, allowing rapid, uniform updates across all nodes.
Self‑service deployment reduced the operational timeline from days to minutes, enabling the team to support large‑scale live events throughout 2016.
Conclusion
When adopting new technology, first assess the tangible benefits for the team; proceed if the gains are clear. Future focus includes strengthening CI/CD pipelines, and the team welcomes shared practices and solutions.
360 Zhihui Cloud Developer
360 Zhihui Cloud is an enterprise open service platform that aims to "aggregate data value and empower an intelligent future," leveraging 360's extensive product and technology resources to deliver platform services to customers.
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.