A database sharding extension for ActiveRecord that enables horizontal partitioning of MySQL databases in Ruby on Rails applications.
ActiveRecord::Turntable is a Ruby gem that adds database sharding capabilities to ActiveRecord, the ORM used in Ruby on Rails. It enables horizontal partitioning of MySQL databases, allowing applications to distribute data across multiple database instances to handle increased load and larger datasets. The plugin integrates seamlessly with Rails migrations, associations, and queries while providing configurable sharding algorithms and sequencers for unique ID generation.
Ruby on Rails developers building applications that require scalable database architectures, particularly those dealing with high-volume data or needing to distribute user data across multiple MySQL instances.
Developers choose ActiveRecord::Turntable because it provides a native, ActiveRecord-compatible sharding solution without requiring extensive application rewrites. Its transparent integration with Rails features like migrations and associations, along with support for multiple sharding algorithms and sequencers, makes it a practical choice for scaling Rails applications.
ActiveRecord Sharding Plugin
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Works transparently with ActiveRecord migrations, associations, and transactions, minimizing code changes as highlighted in the philosophy section for minimal intrusion.
Supports multiple algorithms like range, modulo, and hash slot, allowing customizable data distribution based on key patterns, as shown in the configuration examples.
Provides sequencers like MySQL, Barrage, and Katsubushi to generate unique primary keys across shards, detailed in the sequencer section with setup instructions.
Configurable to raise exceptions for queries that unintentionally target all shards, helping developers avoid inefficient full-shard scans.
Explicitly states support for MySQL only in the README, making it unsuitable for projects using other databases like PostgreSQL.
Admits in the Limitations section that queries with ORDER BY, GROUP BY, and LIMIT clauses cannot be distributed, restricting complex analytical operations.
Warns that has_many :through and habtm relationships may return unexpected results, requiring workarounds like foreign_shard_key options.