Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Database Sharding with ActiveRecord

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on. →

Database Sharding with ActiveRecord

Database Sharding is a highly scalable approach for improving the throughput of large database-centric business applications. It is a type of database partitioning that separates very large databases into smaller, faster, easier managed parts called data shards​.

Avatar for Karen Ventura

Karen Ventura

January 30, 2019

More Decks by Karen Ventura

Other Decks in Programming

Transcript

  1. Database Sharding is a highly scalable approach for improving the

    throughput of large database-centric business applications. It is a type of database partitioning that separates very large databases into smaller, faster, easier managed parts called data shards What is Database Sharding?
  2. “Involves creating tables with fewer columns and using additional tables

    to store the remaining columns. Normalization also involves this splitting of columns across tables, but vertical partitioning goes beyond that and partitions columns even when already normalized.” Vertical Partition
  3. Horizontal Partition “Involves putting different rows into different tables. For

    example, customers with ZIP codes less than 50000 are stored in CustomersEast, while customers with ZIP codes greater than or equal to 50000 are stored in CustomersWest. The two partition tables are then CustomersEast and CustomersWest, while a view with a union might be created over both of them to provide a complete view of all customers.”
  4. Database sharding partitions the problematic table(s) in the same way,

    but it does this across potentially multiple instances of the schema. The obvious advantage would be that search load for the large partitioned table can now be split across multiple servers (logical or physical), not just multiple indexes on the same logical server. The difference
  5. Reasons to Implement DS • The growth in database transactions

    and large volumes of data.
 • If you need to move data along databases
 • Applications that have a multi-tenancy approach and want to horizontal scalability.

  6. Octopus is a better way to do Database Sharding in

    ActiveRecord. Sharding allows multiple databases in the same rails application. The API is designed to be as simple as possible. Octopus focuses on the end user, giving the power of multiple databases but with reliable code and flexibility. Octopus is compatible with Rails 4 and Rails 5. Octupus Gem
  7. • Sharding (with multiple shards, and grouped shards).
 • Replication

    (Master/slave support, with multiple slaves).
 • Moving data between shards with migrations.
 Octupus support