Migrating a database from InnoDB to MyRocks

Visit the post for more.

Yoshinori Matsunobu
10 min readadvanced
--
View Original

Overview

The article discusses Facebook's migration of its main database (UDB) from InnoDB to MyRocks, a MySQL database engine designed for improved space and write efficiency. The migration successfully halved storage usage while maintaining performance, and the article outlines the preparation, execution, and lessons learned during this process.

What You'll Learn

1

How to migrate a database from InnoDB to MyRocks without service interruption

2

Why MyRocks is more space-efficient than compressed InnoDB

3

How to implement data consistency verification during database migration

Prerequisites & Requirements

  • Understanding of MySQL and database migration concepts
  • Familiarity with MySQL administration tools(optional)

Key Questions Answered

What are the advantages of migrating to MyRocks from InnoDB?
Migrating to MyRocks offers significant advantages, such as halving storage usage compared to compressed InnoDB without significantly increasing CPU and I/O utilization. MyRocks is optimized for space savings and write efficiency, making it a suitable choice for handling large datasets.
How did Facebook ensure data consistency during the migration?
Facebook implemented a comprehensive data consistency verification process that included comparing row counts and checksums between primary and secondary keys, as well as across different instances of MyRocks and InnoDB. This verification ran continuously during and after the migration to ensure data integrity.
What steps were taken to migrate the database without downtime?
The migration involved deploying MyRocks as a secondary instance, performing a dump and load from InnoDB, and verifying consistency before promoting MyRocks to primary. This approach allowed for seamless migration while maintaining service availability.

Key Statistics & Figures

Storage usage reduction
50%
The migration from compressed InnoDB to MyRocks successfully cut storage usage in half.

Technologies & Tools

Database
Myrocks
Used as the new MySQL database engine to improve space and write efficiency.
Database
Innodb
The previous database engine from which UDB was migrated.

Key Actionable Insights

1
Plan your database migration carefully to minimize service disruption.
By deploying MyRocks as a secondary instance and ensuring replication, Facebook was able to migrate without downtime, which is crucial for user-facing services.
2
Implement robust data consistency checks during migration.
Facebook's use of checksums and row count comparisons helped maintain data integrity, which is essential when transitioning between database engines.
3
Consider the hardware implications of your migration timeline.
Choosing hardware that aligns with your migration schedule can prevent unnecessary costs and resource strain, as seen in Facebook's approach to reducing storage usage.

Common Pitfalls

1
Underestimating the complexity of database migrations can lead to significant downtime.
Many organizations fail to account for the intricacies involved in ensuring data consistency and maintaining service availability, which can result in operational challenges during the transition.

Related Concepts

Database Migration Strategies
Data Consistency Verification Techniques
Mysql Database Engines