Adrianna Chang - Migrating Shopify’s Core Rails Monolith to Trilogy - Rails World 2023

Migrate Shopify's Core Rails monolith to Trilogy, a MySQL database client written in Rust, and simplify database setup.

Key takeaways
  • Shopify’s Rails monolith needed to be migrated to trilogy, a MySQL database client written in Rust.
  • The main reasons for the switch were to improve test coverage, simplify database setup, and reduce dependencies.
  • The team started by setting up the application to use trilogy and running tests against it.
  • They encountered several challenges, including differences in error classes and query flags.
  • After addressing these differences, they tested and deployed the trilogy adapter in phases.
  • The team saw significant improvements in request time, with a 22% speedup overall.
  • The main takeaways from the experience were:
    • Minimize dependencies: trilogy has no dependencies other than POSIX and OpenSSL.
    • Leverage open source: trilogy was open sourced by GitHub alongside its active record adapter.
    • Monitor and debug: troubleshooting was key to ensuring a smooth rollout.
    • Test thoroughly: the team ran tests against both MySQL 2 and trilogy to ensure parity.
    • Consider the community: the Rails community played a significant role in the adaptation.
    • Diversify: the team aimed to improve the Ruby and Rails communities’ diversity and inclusivity.
  • Members of the Rails Foundation, including Aaron Patterson and Eileen, were advocates for the trilogy adapter.
  • The adapter is designed to be flexible, performant, and easy to use.
  • The team used a CI pipeline to test and deploy the adapter in phases.
  • They also developed a resource adapter to intercept resource access and fail quickly in situations where a service is unresponsive.
  • Shopify and GitHub use trilogy in their production environments.
  • The team emphasizes the benefits of using trilogy, including improved test coverage, simplified database setup, and reduced dependencies.
  • Users are encouraged to try trilogy confidently in their Rails applications.