Migrating Facebook to MySQL 8.0
Facebook moved its MySQL fleet from a heavily customized 5.6 branch straight to 8.0, skipping 5.7. Over a couple of years the team evaluated more than 2,300 patches and ported about 1,500. Each replica set was moved independently by adding 8.0 secondaries via mysqldump, promoting them and then removing the 5.6 instances, with config-driven automation and per-replica-set rollback. Problems found along the way included utf8mb4_0900 collation mismatches, new reserved keywords like groups and rank, InnoDB deadlocks fixed by lowering isolation after standardizing on row-based replication, ACL cache and binlog index mutex contention, and higher memory use that required trimming performance_schema and InnoDB structures.
Related posts
- Upgrading GitHub.com to MySQL 8.0
GitHub Engineering mediumAdeptGitHub upgraded 1200+ MySQL hosts (300+ TB, 5.5M QPS, 50+ clusters, including Vitess) from 5.7 to 8.0 over more than a year without breaking SLOs. The rollout went in stages: rolling replica upgrades per data center, then a replication topology with parallel 5.7 and 8.0 chains, then an Orchestrator graceful failover to an 8.0 primary, and finally cleanup after a 24-hour validation. Keeping rollback possible required backward replication from 8.0 to 5.7, which meant pinning utf8/utf8_unicode_ci collation and working around 8.0 role statements. Other problems included a commit-order replication hang fixed in 8.0.28, Vitess VTgate version advertising, and large WHERE IN queries that crashed MySQL in production despite passing CI.
- Upgrading MySQL at Shopify
Shopify Engineering hardMasterShopify moved hundreds of horizontally sharded Percona Server shards, thousands of VMs in all, from 5.7.21 to 5.7.32, mainly to get writeset-based replication parallelism across replication topologies up to four hops deep. Rollback testing turned up a downgrade bug: metadata-only ALTER TABLE statements, such as the AUTO_INCREMENT reset in Shopify's startup script, triggered full table rebuilds. The cause was mismatched HA_PACK_KEY flags on InnoDB indexes, which two earlier upstream fixes in 5.7.23 and 5.7.27 had not fully resolved, and the team patched it in their internal fork. In parallel they extended Mason, their self-healing VM service, into a declarative per-shard topology reconciler that provisions upgraded replicas, with a priority lane for healing, queue throttling, feature flags and a dry-run mode.
- Partitioning GitHub’s relational databases to handle scale
GitHub Engineering mediumAdeptGitHub split its monolithic `mysql1` MySQL cluster by first virtually partitioning tables into schema domains (declared in YAML) and enforcing boundaries with query and transaction linters, then physically moving domains to new clusters via Vitess vertical sharding or a custom ProxySQL/GTID-based write-cutover script. Cross-domain joins were eliminated with techniques like preload, Rails' new `disable_joins` option and application-side joins, validated with Scientist experiments. The write-cutover moved 130 of the busiest tables in tens of milliseconds with only a handful of failed writes. Query volume grew from 950k to 1.2M queries/s while average per-host load halved, reducing database-related incidents.
- Beyond synthetic testing: Capturing and replaying real database workloads at Airbnb
Airbnb Engineering mediumAdeptAirbnb replaced fragmented per-language client-side query logging with a client-agnostic capture point in ProxySQL, so real production MySQL traffic can be replayed offline. A Log Mover sidecar ships ProxySQL query logs to object storage. A Log Processor splits them per cluster, reassembles transactions, buckets them into five-minute windows and rewrites INSERTs to pin last_insert_id. A queue-driven fleet of replay workers then uses shared start times to reproduce the original concurrency and pacing, at 1x or accelerated speeds. Replay-and-compare runs during the MySQL 5.7→8.0 upgrade caught a 0.03s→2.6s sort regression, duplicate queries the query cache had been hiding, and non-deterministic ORDER BY/LIMIT results. Accelerated replays locate capacity ceilings, for example commit latency rising from 6 ms to 34 ms at 80% more write traffic.
- Shard Balancing: Moving Shops Confidently with Zero-Downtime at Terabyte-scale
Shopify Engineering mediumAdeptShopify rebalances its MySQL shards by moving individual shops between pods online, with downtime confined to a brief cutover. Placement is decided by simulating proposed moves against historical utilization data, which in one case narrowed the spread between least- and most-used shards from about 4x to about 2x. The move itself uses Ghostferry, which batch-copies rows filtered by shop_id using SELECT...FOR UPDATE while tailing the row-based binlog to replay concurrent writes. Once replication lag is near real time, a Redis-backed multi-reader-single-writer lock halts writes for the shop so remaining binlog events can drain, after which the routing table is updated, the lock released, the move verified and stale data pruned from the source shard.