How Badoo Saved $1M by Migrating Hundreds of Servers to PHP 7

Badoo migrated its massive PHP codebase to PHP 7 across hundreds of servers, overcoming engine bugs, HHVM limitations, and extension incompatibilities, while revamping testing infrastructure and deployment processes, ultimately achieving up to 40% faster response times, eight‑fold memory reduction, and roughly one million dollars in cost savings.

21CTO
21CTO
21CTO
How Badoo Saved $1M by Migrating Hundreds of Servers to PHP 7

We (Badoo) successfully migrated a multi‑hundred‑machine PHP application to PHP 7, becoming one of the first companies to switch at this scale. During the migration we discovered and helped fix several PHP 7 bytecode‑cache bugs, confirming that PHP 7 can now run stably in production with lower memory usage and significantly higher performance.

HHVM Trial

Before adopting PHP 7 we evaluated HHVM. After a few weeks of warm‑up, HHVM showed a three‑fold increase in speed and CPU usage, but it suffered from deployment difficulty, lack of runkit support, incomplete PHP 5.5 compatibility, and high maintenance cost, leading us to reject it.

Migration Plan

Modify PHP build/deployment infrastructure and adjust code for many extensions.

Change infrastructure and testing environment.

Refactor PHP application code.

Engine and Extension Changes

Key engine changes in PHP 7 include:

zval pointer replaced by zval on the stack.

char* replaced by zend_string, improving string handling.

Array API now uses zend_string keys and a more compact storage layout.

These changes reduce small memory allocations and yield about a 2% speed increase for the engine.

Testing Infrastructure

Our testing pipeline runs 60,000 tests daily, with around 6 × 10⁴ unit tests (≈50% coverage) executed in the cloud in 2–3 minutes. We also run integration, system, Selenium, and Calabash tests. To replace runkit we introduced SoftMocks , a pure‑PHP library that dynamically rewrites code at runtime, providing method overriding, function result overriding, constant modification, and class method addition.

Results

After migration, response times dropped by roughly 40%, memory usage fell by more than eight times, and CPU load decreased to under 50% on large clusters. The performance charts below illustrate response time distribution, CPU usage, memory consumption, and CPU load for the mobile backend cluster.

Response time distribution
Response time distribution
RUsage (CPU time)
RUsage (CPU time)
Memory usage
Memory usage
CPU load (mobile backend)
CPU load (mobile backend)

Overall, the migration saved roughly $1 million by reducing the number of servers needed (about 300 servers) and cutting hosting costs, while also improving user experience.

Original source: Badoo (translated by Open Source China)
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.

BackendmigrationperformancetestingOpsphp7
21CTO
Written by

21CTO

21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.

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.