Airbnb developed a robust system to capture and replay real production database workloads. This system addresses critical challenges like capacity planning, de-risking database upgrades, and performance debugging by simulating production traffic in test environments. By leveraging ProxySQL as a client-agnostic capture point, the architecture ensures accurate transaction replay and result comparison across different database versions or configurations.
Read original on Airbnb EngineeringOperating databases at scale, particularly hundreds of MySQL-compatible clusters processing millions of queries per second, presents significant challenges. These include accurately sizing clusters for future growth, ensuring consistent behavior during version upgrades and migrations, and effectively reproducing production incidents for debugging. Traditional synthetic benchmarks often fall short in mirroring real-world traffic patterns, making capacity planning and compatibility testing difficult.
Airbnb's prior fragmented system, relying on client-side query logging, suffered from high maintenance burden, poor scalability in an SOA environment, and most critically, lacked sufficient transactional context for accurate replay. This necessitated a new, unified system with three primary goals:
The core of the system leverages ProxySQL, an open-source MySQL proxy already in their infrastructure, as a transparent, client-agnostic query capture point. This avoids application code changes. The system comprises three main components:
Key Design Decision: Query Rewriting
To handle auto-increment ID inconsistencies across different MySQL versions or compatible databases, the Log Processor rewrites `INSERT` statements to explicitly include the `last_insert_id` captured from production. For example, `INSERT INTO users (name) VALUES ('bob')` becomes `INSERT INTO users (id, name) VALUES (1, 'bob')`. While this sacrifices testing native auto-increment generation, it ensures subsequent queries relying on these IDs behave consistently during replay, significantly reducing false positives in compatibility tests.
The Replay Task Scheduler plays a vital role in preserving original workload concurrency. It assigns an "expected start time" to batches of tasks. Workers wait for this shared signal before replaying their respective five-minute log files simultaneously, accurately reproducing the original workload's pacing and concurrent execution patterns, rather than replaying files in isolation.