SlideShare a Scribd company logo
DATABASE SHARDING
IN RAILS APPLICATIONS
RUBY MEDITATION #23
September 2018
Work: @Talkable
Ruby: since 2012
Rails: since v3.2
Open Source: about 0 contributions
@justmacc
@vitalikdanchenko
ABOUT ME
ABOUT ME
Hobby: Running
Marathon Finisher: 4 times
Marathon PB: 3:05:10
ABOUT ME
A LITTLE BIT ABOUT SCALING
DATABASE SHARDING
A LOT OF DIAGRAMS
ALMOST NO CODE
AGENDA
CAN RAILS SCALE?
CAN RAILS SCALE?
— @busterarm at Hacker News
"TWITTER SCALE" WASN'T
SO MUCH A RUBY/RAILS
PROBLEM AS IT WAS AN
RDBMS
”
“
https://news.ycombinator.com/item?id=17217210
CAN RAILS SCALE?
SCALING
SCALABILITY VS PERFORMANCE
SCALING
SCALING
Rails Application
WEB WORKERS
DATABASE
SCALING
Rails Application
WEB WORKERS
BACKGROUND
JOBS
DATABASE
SCALING
Rails Application
WEB WORKERS
BACKGROUND JOBS
DATABASE
SCALING
Rails Application
WEB WORKERS
BACKGROUND JOBS
DATABASE
SCALING
Rails Application
WEB WORKERS
BACKGROUND JOBS DATABASE
SCALING
Rails Application
WEB WORKERS
DATABASE
BACKGROUND JOBS
SCALING
Rails Application
WEB
WORKERS
DATABASE
WEB
WORKERS
WEB
WORKERS
WEB
WORKERS
JOBS JOBS
JOBS JOBS
SCALING
SCALING
DATABASE
DATABASE SCALING
DATABASE
MASTER
DATABASE
SLAVE
DATABASE SCALING
DATABASE
MASTER
DATABASE
SLAVE
DATABASE
SLAVE
DATABASE
SLAVE
DATABASE SCALING
DATABASE
PARTIAL DATA
DATABASE
PARTIAL DATA
DATABASE
PARTIAL DATA
DATABASE SHARDING
FUNCTIONAL EXPRESSIONAL METADATA
Separate
Modules
id % N
year
country
row -> shard
DATABASE SHARDING
THEORETICAL PART
PRACTICAL PART
DATABASE SHARDING IN RAILS
MULTIPLE DATABASES MODEL
1 class ShardedBase < ActiveRecord::Base
2 establish_connection SHARD_DB_CONFIG
3 self.abstract_class = true
4 end
5
6 class Post < ShardedBase
7 end
8
9 class Comment < ShardedBase
10 end
DATABASE SHARDING IN RAILS
GEMS
• thiagopradi/octopus
• hsgubert/rails-sharding
• zendesk/active_record_shards
1 ActiveRecord::Base.on_shard(:number_two) do
2 Post.find_by(author: author)
3 end
DATABASE SHARDING IN TALKABLE
STEP BY STEP
DATABASE SHARDING IN TALKABLE
STEP BY STEP
1. How to shard?
DATABASE SHARDING IN TALKABLE
STEP BY STEP
1. How to shard?
BY CUSTOMER
DATABASE SHARDING IN TALKABLE
STEP BY STEP
1. How to shard? — expressional + metadata
DATABASE SHARDING IN TALKABLE
STEP BY STEP
1. How to shard? — expressional + metadata
2. Which tables have to be sharded?
DATABASE SHARDING IN TALKABLE
STEP BY STEP
1. How to shard? — expressional + metadata
2. Which tables have to be sharded?
THE LARGEST
DATABASE SHARDING IN TALKABLE
STEP BY STEP
1 class Visitor < ShardedRecord
2 has_many :purchases
3 end
4
5 class Purchase < ShardedRecord
6 belongs_to :person
7 has_one :referral
8 end
9
10 class Referral < ShardedRecord
11 has_many :rewards
12 end
13
14 class Reward < ShardedRecord
15 belongs_to :incentive
16 end
DATABASE SHARDING IN TALKABLE
STEP BY STEP
DATABASE
NOT SHARDED
CONFIG DATA
DATABASE
SHARD #1
REFERRAL DATA
DATABASE
SHARD #2
REFERRAL DATA
DATABASE SHARDING IN TALKABLE
STEP BY STEP
1. How to shard? — expressional + metadata
2. Which tables have to be sharded? — config vs referral
3. Get rid of joins
1 module ShardingJoinFinder
2 TABLE_REFERENCE = /(^|s+)(join|from)s+`?([a-z_]+)`?/i
3
4 def execute(query, name = nil)
5 ensure_sharding_match(query)
6 super(query, name)
7 end
8
9 def select_all(query, *args)
10 ensure_sharding_match(query)
11 super
12 end
13
14 def ensure_sharding_match(query)
15 query.scan(TABLE_REFERENCE).map(&:last)
16 sharded, unsharded = klasses.partition(&:is_sharded?)
17 raise Error if sharded.any? && unsharded.any?
18 end
19 end
20
21 ActiveRecord::ConnectionAdapters::Mysql2Adapter.prepend(ShardingJ
22 ActiveRecord::Relation.prepend(ShardingJoinFinder)
DATABASE SHARDING IN TALKABLE
STEP BY STEP
1. How to shard? — expressional + metadata
2. Which tables have to be sharded? — config vs referral
3. Get rid of joins — joins detector
DATABASE SHARDING IN TALKABLE
STEP BY STEP
1. How to shard? — expressional + metadata
2. Which tables have to be sharded? — config vs referral
3. Get rid of joins — joins detector
4. Introduce connection management
DATABASE SHARDING IN TALKABLE
STEP BY STEP
1. How to shard? — expressional + metadata
2. Which tables have to be sharded? — config vs referral
3. Get rid of joins — joins detector
4. Introduce connection management — gem
DATABASE SHARDING IN TALKABLE
STEP BY STEP
1. How to shard? — expressional + metadata
2. Which tables have to be sharded? — config vs referral
3. Get rid of joins — joins detector
4. Introduce connection management — gem
5. Add utility helpers
1 class DatabaseUtils
2 class SlaveError < StandardError; end
3
4 class << self
5 def use_shard(shard, &block); end
6 def current_shard; end
7 def uses_slave?; end
8 def config_for(slave: uses_slave?, shard: current_shard); end
9 def connection(slave: uses_slave?, shard: current_shard); end
10 def sharded_tables; end
11 def on_all_shards(&block); end
12 def processlist; end
13 def slave_lag_for(connection); end
14 end
15 end
1 Rails.application.console do
2 def shard(shard)
3 shard = shard.database_shard if shard.respond_to?(:database_shard)
4 DatabaseUtils.use_shard!(shard)
5 end
6 end
DATABASE SHARDING IN TALKABLE
STEP BY STEP
1. How to shard? — expressional + metadata
2. Which tables have to be sharded? — config vs referral
3. Get rid of joins — joins detector
4. Introduce connection management — gem
5. Add utility helpers — depends on individual needs
DATABASE SHARDING IN TALKABLE
STEP BY STEP
1. How to shard? — expressional + metadata
2. Which tables have to be sharded? — config vs referral
3. Get rid of joins — joins detector
4. Introduce connection management — gem
5. Add utility helpers — depends on individual needs
6. Migrate
1 production:
2 host: 'master.production.com'
3 database: 'primary'
4 slave:
5 host: 'slave.production.com'
6 database: 'primary'
7
8 shards:
9 1:
10 host: 'master.production.com'
11 database: 'shard_1'
12 slave:
13 host: 'slave.production.com'
14 database: 'shard_1'
15 2:
16 host: 'shard_2.production.com'
17 database: 'shard_2'
18 slave:
19 host: 'slave.shard_2.production.com'
20 database: 'shard_2'
1 production:
2 host: 'master.production.com'
3 database: 'primary'
4 slave:
5 host: 'slave.production.com'
6 database: 'primary'
7
8 shards:
9 1:
10 host: 'shard1.production.com'
11 database: 'shard_1'
12 slave:
13 host: 'slave.shard_1.production.com'
14 database: 'shard_1'
15 2:
16 host: 'shard_2.production.com'
17 database: 'shard_2'
18 slave:
19 host: 'slave.shard_2.production.com'
20 database: 'shard_2'
DATABASE SHARDING IN TALKABLE
STEP BY STEP
1. How to shard? — expressional + metadata
2. Which tables have to be sharded? — config vs referral
3. Get rid of joins — joins detector
4. Introduce connection management — gem
5. Add utility helpers — depends on individual needs
6. Migrate — profit!!!
MySQL PostgreSQL
Vites Citus
Jetpants ???
ScaleBase
DATABASE SHARDING SOLUTIONS
PROS CONS
Easier to Manage Not Easy to Implement
Smaller and Faster Lost Abilities
Reduces Costs
DATABASE SHARDING
CONCLUSION
DATABASE SHARDING
CONCLUSION
• Do not shard your data until you really need it
• Choose a sharding model that fits your context (project)
• Each additional shard increases the chance of a random
crash
When: 08:00 am
Where: 46°28'44.5"N 30°45'41.0"E
How far: doesn’t matter
How fast: doesn’t matter
SUNDAY MORNING RUN
Q&A

More Related Content

Similar to Database Sharding in Rails Applications – Vitalik Danchenko | Ruby Meditation #23

M|18 How MariaDB Server Scales with Spider
M|18 How MariaDB Server Scales with SpiderM|18 How MariaDB Server Scales with Spider
M|18 How MariaDB Server Scales with Spider
MariaDB plc
 
Quick Guide to Refresh Spark skills
Quick Guide to Refresh Spark skillsQuick Guide to Refresh Spark skills
Quick Guide to Refresh Spark skills
Ravindra kumar
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRuby
Nick Sieger
 
Spark streaming
Spark streamingSpark streaming
Spark streaming
Noam Shaish
 
Mini-Training: Redis
Mini-Training: RedisMini-Training: Redis
Mini-Training: Redis
Betclic Everest Group Tech Team
 
Workshop 17: EmberJS parte II
Workshop 17: EmberJS parte IIWorkshop 17: EmberJS parte II
Workshop 17: EmberJS parte II
Visual Engineering
 
Sinatra and JSONQuery Web Service
Sinatra and JSONQuery Web ServiceSinatra and JSONQuery Web Service
Sinatra and JSONQuery Web Service
vvatikiotis
 
Introduction To Ruby On Rails
Introduction To Ruby On RailsIntroduction To Ruby On Rails
Introduction To Ruby On Rails
Steve Keener
 
Leveraging a distributed architecture to your advantage
Leveraging a distributed architecture to your advantageLeveraging a distributed architecture to your advantage
Leveraging a distributed architecture to your advantage
Michelangelo van Dam
 
Rails MVC by Sergiy Koshovyi
Rails MVC by Sergiy KoshovyiRails MVC by Sergiy Koshovyi
Rails MVC by Sergiy Koshovyi
Pivorak MeetUp
 
Developing node-mdb: a Node.js - based clone of SimpleDB
Developing node-mdb: a Node.js - based clone of SimpleDBDeveloping node-mdb: a Node.js - based clone of SimpleDB
Developing node-mdb: a Node.js - based clone of SimpleDB
Rob Tweed
 
Buildingplatforms
BuildingplatformsBuildingplatforms
Buildingplatforms
codebits
 
Hive dirty/beautiful hacks in TD
Hive dirty/beautiful hacks in TDHive dirty/beautiful hacks in TD
Hive dirty/beautiful hacks in TD
SATOSHI TAGOMORI
 
Introduction to cloudforecast
Introduction to cloudforecastIntroduction to cloudforecast
Introduction to cloudforecast
Masahiro Nagano
 
(BDT203) From Zero to NoSQL Hero: Amazon DynamoDB Tutorial | AWS re:Invent 2014
(BDT203) From Zero to NoSQL Hero: Amazon DynamoDB Tutorial | AWS re:Invent 2014(BDT203) From Zero to NoSQL Hero: Amazon DynamoDB Tutorial | AWS re:Invent 2014
(BDT203) From Zero to NoSQL Hero: Amazon DynamoDB Tutorial | AWS re:Invent 2014
Amazon Web Services
 
Tech Talk Series, Part 2: Why is sharding not smart to do in MySQL?
Tech Talk Series, Part 2: Why is sharding not smart to do in MySQL?Tech Talk Series, Part 2: Why is sharding not smart to do in MySQL?
Tech Talk Series, Part 2: Why is sharding not smart to do in MySQL?
Clustrix
 
Speedy TDD with Rails
Speedy TDD with RailsSpeedy TDD with Rails
Speedy TDD with Rails
PatchSpace Ltd
 
PHP and Rich Internet Applications
PHP and Rich Internet ApplicationsPHP and Rich Internet Applications
PHP and Rich Internet Applications
elliando dias
 
Replacing ActiveRecord With DataMapper
Replacing ActiveRecord With DataMapperReplacing ActiveRecord With DataMapper
Replacing ActiveRecord With DataMapper
Peter Degen-Portnoy
 
Supa fast Ruby + Rails
Supa fast Ruby + RailsSupa fast Ruby + Rails
Supa fast Ruby + Rails
Jean-Baptiste Feldis
 

Similar to Database Sharding in Rails Applications – Vitalik Danchenko | Ruby Meditation #23 (20)

M|18 How MariaDB Server Scales with Spider
M|18 How MariaDB Server Scales with SpiderM|18 How MariaDB Server Scales with Spider
M|18 How MariaDB Server Scales with Spider
 
Quick Guide to Refresh Spark skills
Quick Guide to Refresh Spark skillsQuick Guide to Refresh Spark skills
Quick Guide to Refresh Spark skills
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRuby
 
Spark streaming
Spark streamingSpark streaming
Spark streaming
 
Mini-Training: Redis
Mini-Training: RedisMini-Training: Redis
Mini-Training: Redis
 
Workshop 17: EmberJS parte II
Workshop 17: EmberJS parte IIWorkshop 17: EmberJS parte II
Workshop 17: EmberJS parte II
 
Sinatra and JSONQuery Web Service
Sinatra and JSONQuery Web ServiceSinatra and JSONQuery Web Service
Sinatra and JSONQuery Web Service
 
Introduction To Ruby On Rails
Introduction To Ruby On RailsIntroduction To Ruby On Rails
Introduction To Ruby On Rails
 
Leveraging a distributed architecture to your advantage
Leveraging a distributed architecture to your advantageLeveraging a distributed architecture to your advantage
Leveraging a distributed architecture to your advantage
 
Rails MVC by Sergiy Koshovyi
Rails MVC by Sergiy KoshovyiRails MVC by Sergiy Koshovyi
Rails MVC by Sergiy Koshovyi
 
Developing node-mdb: a Node.js - based clone of SimpleDB
Developing node-mdb: a Node.js - based clone of SimpleDBDeveloping node-mdb: a Node.js - based clone of SimpleDB
Developing node-mdb: a Node.js - based clone of SimpleDB
 
Buildingplatforms
BuildingplatformsBuildingplatforms
Buildingplatforms
 
Hive dirty/beautiful hacks in TD
Hive dirty/beautiful hacks in TDHive dirty/beautiful hacks in TD
Hive dirty/beautiful hacks in TD
 
Introduction to cloudforecast
Introduction to cloudforecastIntroduction to cloudforecast
Introduction to cloudforecast
 
(BDT203) From Zero to NoSQL Hero: Amazon DynamoDB Tutorial | AWS re:Invent 2014
(BDT203) From Zero to NoSQL Hero: Amazon DynamoDB Tutorial | AWS re:Invent 2014(BDT203) From Zero to NoSQL Hero: Amazon DynamoDB Tutorial | AWS re:Invent 2014
(BDT203) From Zero to NoSQL Hero: Amazon DynamoDB Tutorial | AWS re:Invent 2014
 
Tech Talk Series, Part 2: Why is sharding not smart to do in MySQL?
Tech Talk Series, Part 2: Why is sharding not smart to do in MySQL?Tech Talk Series, Part 2: Why is sharding not smart to do in MySQL?
Tech Talk Series, Part 2: Why is sharding not smart to do in MySQL?
 
Speedy TDD with Rails
Speedy TDD with RailsSpeedy TDD with Rails
Speedy TDD with Rails
 
PHP and Rich Internet Applications
PHP and Rich Internet ApplicationsPHP and Rich Internet Applications
PHP and Rich Internet Applications
 
Replacing ActiveRecord With DataMapper
Replacing ActiveRecord With DataMapperReplacing ActiveRecord With DataMapper
Replacing ActiveRecord With DataMapper
 
Supa fast Ruby + Rails
Supa fast Ruby + RailsSupa fast Ruby + Rails
Supa fast Ruby + Rails
 

More from Ruby Meditation

Is this Legacy or Revenant Code? - Sergey Sergyenko | Ruby Meditation 30
Is this Legacy or Revenant Code? - Sergey Sergyenko  | Ruby Meditation 30Is this Legacy or Revenant Code? - Sergey Sergyenko  | Ruby Meditation 30
Is this Legacy or Revenant Code? - Sergey Sergyenko | Ruby Meditation 30
Ruby Meditation
 
Life with GraphQL API: good practices and unresolved issues - Roman Dubrovsky...
Life with GraphQL API: good practices and unresolved issues - Roman Dubrovsky...Life with GraphQL API: good practices and unresolved issues - Roman Dubrovsky...
Life with GraphQL API: good practices and unresolved issues - Roman Dubrovsky...
Ruby Meditation
 
Where is your license, dude? - Viacheslav Miroshnychenko | Ruby Meditation 29
Where is your license, dude? - Viacheslav Miroshnychenko | Ruby Meditation 29Where is your license, dude? - Viacheslav Miroshnychenko | Ruby Meditation 29
Where is your license, dude? - Viacheslav Miroshnychenko | Ruby Meditation 29
Ruby Meditation
 
Dry-validation update. Dry-validation vs Dry-schema 1.0 - Aleksandra Stolyar ...
Dry-validation update. Dry-validation vs Dry-schema 1.0 - Aleksandra Stolyar ...Dry-validation update. Dry-validation vs Dry-schema 1.0 - Aleksandra Stolyar ...
Dry-validation update. Dry-validation vs Dry-schema 1.0 - Aleksandra Stolyar ...
Ruby Meditation
 
How to cook Rabbit on Production - Bohdan Parshentsev | Ruby Meditation 28
How to cook Rabbit on Production - Bohdan Parshentsev | Ruby Meditation 28 How to cook Rabbit on Production - Bohdan Parshentsev | Ruby Meditation 28
How to cook Rabbit on Production - Bohdan Parshentsev | Ruby Meditation 28
Ruby Meditation
 
How to cook Rabbit on Production - Serhiy Nazarov | Ruby Meditation 28
How to cook Rabbit on Production - Serhiy Nazarov | Ruby Meditation 28How to cook Rabbit on Production - Serhiy Nazarov | Ruby Meditation 28
How to cook Rabbit on Production - Serhiy Nazarov | Ruby Meditation 28
Ruby Meditation
 
Reinventing the wheel - why do it and how to feel good about it - Julik Tarkh...
Reinventing the wheel - why do it and how to feel good about it - Julik Tarkh...Reinventing the wheel - why do it and how to feel good about it - Julik Tarkh...
Reinventing the wheel - why do it and how to feel good about it - Julik Tarkh...
Ruby Meditation
 
Performance Optimization 101 for Ruby developers - Nihad Abbasov (ENG) | Ruby...
Performance Optimization 101 for Ruby developers - Nihad Abbasov (ENG) | Ruby...Performance Optimization 101 for Ruby developers - Nihad Abbasov (ENG) | Ruby...
Performance Optimization 101 for Ruby developers - Nihad Abbasov (ENG) | Ruby...
Ruby Meditation
 
Use cases for Serverless Technologies - Ruslan Tolstov (RUS) | Ruby Meditatio...
Use cases for Serverless Technologies - Ruslan Tolstov (RUS) | Ruby Meditatio...Use cases for Serverless Technologies - Ruslan Tolstov (RUS) | Ruby Meditatio...
Use cases for Serverless Technologies - Ruslan Tolstov (RUS) | Ruby Meditatio...
Ruby Meditation
 
The Trailblazer Ride from the If Jungle into a Civilised Railway Station - Or...
The Trailblazer Ride from the If Jungle into a Civilised Railway Station - Or...The Trailblazer Ride from the If Jungle into a Civilised Railway Station - Or...
The Trailblazer Ride from the If Jungle into a Civilised Railway Station - Or...
Ruby Meditation
 
What/How to do with GraphQL? - Valentyn Ostakh (ENG) | Ruby Meditation 27
What/How to do with GraphQL? - Valentyn Ostakh (ENG) | Ruby Meditation 27What/How to do with GraphQL? - Valentyn Ostakh (ENG) | Ruby Meditation 27
What/How to do with GraphQL? - Valentyn Ostakh (ENG) | Ruby Meditation 27
Ruby Meditation
 
New features in Rails 6 - Nihad Abbasov (RUS) | Ruby Meditation 26
New features in Rails 6 -  Nihad Abbasov (RUS) | Ruby Meditation 26New features in Rails 6 -  Nihad Abbasov (RUS) | Ruby Meditation 26
New features in Rails 6 - Nihad Abbasov (RUS) | Ruby Meditation 26
Ruby Meditation
 
Security Scanning Overview - Tetiana Chupryna (RUS) | Ruby Meditation 26
Security Scanning Overview - Tetiana Chupryna (RUS) | Ruby Meditation 26Security Scanning Overview - Tetiana Chupryna (RUS) | Ruby Meditation 26
Security Scanning Overview - Tetiana Chupryna (RUS) | Ruby Meditation 26
Ruby Meditation
 
Teach your application eloquence. Logs, metrics, traces - Dmytro Shapovalov (...
Teach your application eloquence. Logs, metrics, traces - Dmytro Shapovalov (...Teach your application eloquence. Logs, metrics, traces - Dmytro Shapovalov (...
Teach your application eloquence. Logs, metrics, traces - Dmytro Shapovalov (...
Ruby Meditation
 
Best practices. Exploring - Ike Kurghinyan (RUS) | Ruby Meditation 26
Best practices. Exploring - Ike Kurghinyan (RUS) | Ruby Meditation 26Best practices. Exploring - Ike Kurghinyan (RUS) | Ruby Meditation 26
Best practices. Exploring - Ike Kurghinyan (RUS) | Ruby Meditation 26
Ruby Meditation
 
Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25
Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25
Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25
Ruby Meditation
 
Concurrency in production. Real life example - Dmytro Herasymuk | Ruby Medita...
Concurrency in production. Real life example - Dmytro Herasymuk | Ruby Medita...Concurrency in production. Real life example - Dmytro Herasymuk | Ruby Medita...
Concurrency in production. Real life example - Dmytro Herasymuk | Ruby Medita...
Ruby Meditation
 
Data encryption for Ruby web applications - Dmytro Shapovalov (RUS) | Ruby Me...
Data encryption for Ruby web applications - Dmytro Shapovalov (RUS) | Ruby Me...Data encryption for Ruby web applications - Dmytro Shapovalov (RUS) | Ruby Me...
Data encryption for Ruby web applications - Dmytro Shapovalov (RUS) | Ruby Me...
Ruby Meditation
 
Rails App performance at the limit - Bogdan Gusiev
Rails App performance at the limit - Bogdan GusievRails App performance at the limit - Bogdan Gusiev
Rails App performance at the limit - Bogdan Gusiev
Ruby Meditation
 
GDPR. Next Y2K in 2018? - Anton Tkachov | Ruby Meditation #23
GDPR. Next Y2K in 2018? - Anton Tkachov | Ruby Meditation #23GDPR. Next Y2K in 2018? - Anton Tkachov | Ruby Meditation #23
GDPR. Next Y2K in 2018? - Anton Tkachov | Ruby Meditation #23
Ruby Meditation
 

More from Ruby Meditation (20)

Is this Legacy or Revenant Code? - Sergey Sergyenko | Ruby Meditation 30
Is this Legacy or Revenant Code? - Sergey Sergyenko  | Ruby Meditation 30Is this Legacy or Revenant Code? - Sergey Sergyenko  | Ruby Meditation 30
Is this Legacy or Revenant Code? - Sergey Sergyenko | Ruby Meditation 30
 
Life with GraphQL API: good practices and unresolved issues - Roman Dubrovsky...
Life with GraphQL API: good practices and unresolved issues - Roman Dubrovsky...Life with GraphQL API: good practices and unresolved issues - Roman Dubrovsky...
Life with GraphQL API: good practices and unresolved issues - Roman Dubrovsky...
 
Where is your license, dude? - Viacheslav Miroshnychenko | Ruby Meditation 29
Where is your license, dude? - Viacheslav Miroshnychenko | Ruby Meditation 29Where is your license, dude? - Viacheslav Miroshnychenko | Ruby Meditation 29
Where is your license, dude? - Viacheslav Miroshnychenko | Ruby Meditation 29
 
Dry-validation update. Dry-validation vs Dry-schema 1.0 - Aleksandra Stolyar ...
Dry-validation update. Dry-validation vs Dry-schema 1.0 - Aleksandra Stolyar ...Dry-validation update. Dry-validation vs Dry-schema 1.0 - Aleksandra Stolyar ...
Dry-validation update. Dry-validation vs Dry-schema 1.0 - Aleksandra Stolyar ...
 
How to cook Rabbit on Production - Bohdan Parshentsev | Ruby Meditation 28
How to cook Rabbit on Production - Bohdan Parshentsev | Ruby Meditation 28 How to cook Rabbit on Production - Bohdan Parshentsev | Ruby Meditation 28
How to cook Rabbit on Production - Bohdan Parshentsev | Ruby Meditation 28
 
How to cook Rabbit on Production - Serhiy Nazarov | Ruby Meditation 28
How to cook Rabbit on Production - Serhiy Nazarov | Ruby Meditation 28How to cook Rabbit on Production - Serhiy Nazarov | Ruby Meditation 28
How to cook Rabbit on Production - Serhiy Nazarov | Ruby Meditation 28
 
Reinventing the wheel - why do it and how to feel good about it - Julik Tarkh...
Reinventing the wheel - why do it and how to feel good about it - Julik Tarkh...Reinventing the wheel - why do it and how to feel good about it - Julik Tarkh...
Reinventing the wheel - why do it and how to feel good about it - Julik Tarkh...
 
Performance Optimization 101 for Ruby developers - Nihad Abbasov (ENG) | Ruby...
Performance Optimization 101 for Ruby developers - Nihad Abbasov (ENG) | Ruby...Performance Optimization 101 for Ruby developers - Nihad Abbasov (ENG) | Ruby...
Performance Optimization 101 for Ruby developers - Nihad Abbasov (ENG) | Ruby...
 
Use cases for Serverless Technologies - Ruslan Tolstov (RUS) | Ruby Meditatio...
Use cases for Serverless Technologies - Ruslan Tolstov (RUS) | Ruby Meditatio...Use cases for Serverless Technologies - Ruslan Tolstov (RUS) | Ruby Meditatio...
Use cases for Serverless Technologies - Ruslan Tolstov (RUS) | Ruby Meditatio...
 
The Trailblazer Ride from the If Jungle into a Civilised Railway Station - Or...
The Trailblazer Ride from the If Jungle into a Civilised Railway Station - Or...The Trailblazer Ride from the If Jungle into a Civilised Railway Station - Or...
The Trailblazer Ride from the If Jungle into a Civilised Railway Station - Or...
 
What/How to do with GraphQL? - Valentyn Ostakh (ENG) | Ruby Meditation 27
What/How to do with GraphQL? - Valentyn Ostakh (ENG) | Ruby Meditation 27What/How to do with GraphQL? - Valentyn Ostakh (ENG) | Ruby Meditation 27
What/How to do with GraphQL? - Valentyn Ostakh (ENG) | Ruby Meditation 27
 
New features in Rails 6 - Nihad Abbasov (RUS) | Ruby Meditation 26
New features in Rails 6 -  Nihad Abbasov (RUS) | Ruby Meditation 26New features in Rails 6 -  Nihad Abbasov (RUS) | Ruby Meditation 26
New features in Rails 6 - Nihad Abbasov (RUS) | Ruby Meditation 26
 
Security Scanning Overview - Tetiana Chupryna (RUS) | Ruby Meditation 26
Security Scanning Overview - Tetiana Chupryna (RUS) | Ruby Meditation 26Security Scanning Overview - Tetiana Chupryna (RUS) | Ruby Meditation 26
Security Scanning Overview - Tetiana Chupryna (RUS) | Ruby Meditation 26
 
Teach your application eloquence. Logs, metrics, traces - Dmytro Shapovalov (...
Teach your application eloquence. Logs, metrics, traces - Dmytro Shapovalov (...Teach your application eloquence. Logs, metrics, traces - Dmytro Shapovalov (...
Teach your application eloquence. Logs, metrics, traces - Dmytro Shapovalov (...
 
Best practices. Exploring - Ike Kurghinyan (RUS) | Ruby Meditation 26
Best practices. Exploring - Ike Kurghinyan (RUS) | Ruby Meditation 26Best practices. Exploring - Ike Kurghinyan (RUS) | Ruby Meditation 26
Best practices. Exploring - Ike Kurghinyan (RUS) | Ruby Meditation 26
 
Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25
Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25
Road to A/B testing - Alexey Vasiliev (ENG) | Ruby Meditation 25
 
Concurrency in production. Real life example - Dmytro Herasymuk | Ruby Medita...
Concurrency in production. Real life example - Dmytro Herasymuk | Ruby Medita...Concurrency in production. Real life example - Dmytro Herasymuk | Ruby Medita...
Concurrency in production. Real life example - Dmytro Herasymuk | Ruby Medita...
 
Data encryption for Ruby web applications - Dmytro Shapovalov (RUS) | Ruby Me...
Data encryption for Ruby web applications - Dmytro Shapovalov (RUS) | Ruby Me...Data encryption for Ruby web applications - Dmytro Shapovalov (RUS) | Ruby Me...
Data encryption for Ruby web applications - Dmytro Shapovalov (RUS) | Ruby Me...
 
Rails App performance at the limit - Bogdan Gusiev
Rails App performance at the limit - Bogdan GusievRails App performance at the limit - Bogdan Gusiev
Rails App performance at the limit - Bogdan Gusiev
 
GDPR. Next Y2K in 2018? - Anton Tkachov | Ruby Meditation #23
GDPR. Next Y2K in 2018? - Anton Tkachov | Ruby Meditation #23GDPR. Next Y2K in 2018? - Anton Tkachov | Ruby Meditation #23
GDPR. Next Y2K in 2018? - Anton Tkachov | Ruby Meditation #23
 

Recently uploaded

Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
TIPNGVN2
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
Pixlogix Infotech
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 

Recently uploaded (20)

Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 

Database Sharding in Rails Applications – Vitalik Danchenko | Ruby Meditation #23

  • 1. DATABASE SHARDING IN RAILS APPLICATIONS RUBY MEDITATION #23 September 2018
  • 2. Work: @Talkable Ruby: since 2012 Rails: since v3.2 Open Source: about 0 contributions @justmacc @vitalikdanchenko ABOUT ME
  • 4. Hobby: Running Marathon Finisher: 4 times Marathon PB: 3:05:10 ABOUT ME
  • 5. A LITTLE BIT ABOUT SCALING DATABASE SHARDING A LOT OF DIAGRAMS ALMOST NO CODE AGENDA
  • 8. — @busterarm at Hacker News "TWITTER SCALE" WASN'T SO MUCH A RUBY/RAILS PROBLEM AS IT WAS AN RDBMS ” “ https://news.ycombinator.com/item?id=17217210 CAN RAILS SCALE?
  • 24. FUNCTIONAL EXPRESSIONAL METADATA Separate Modules id % N year country row -> shard DATABASE SHARDING
  • 26. DATABASE SHARDING IN RAILS MULTIPLE DATABASES MODEL 1 class ShardedBase < ActiveRecord::Base 2 establish_connection SHARD_DB_CONFIG 3 self.abstract_class = true 4 end 5 6 class Post < ShardedBase 7 end 8 9 class Comment < ShardedBase 10 end
  • 27. DATABASE SHARDING IN RAILS GEMS • thiagopradi/octopus • hsgubert/rails-sharding • zendesk/active_record_shards 1 ActiveRecord::Base.on_shard(:number_two) do 2 Post.find_by(author: author) 3 end
  • 28. DATABASE SHARDING IN TALKABLE STEP BY STEP
  • 29. DATABASE SHARDING IN TALKABLE STEP BY STEP 1. How to shard?
  • 30. DATABASE SHARDING IN TALKABLE STEP BY STEP 1. How to shard? BY CUSTOMER
  • 31. DATABASE SHARDING IN TALKABLE STEP BY STEP 1. How to shard? — expressional + metadata
  • 32. DATABASE SHARDING IN TALKABLE STEP BY STEP 1. How to shard? — expressional + metadata 2. Which tables have to be sharded?
  • 33. DATABASE SHARDING IN TALKABLE STEP BY STEP 1. How to shard? — expressional + metadata 2. Which tables have to be sharded? THE LARGEST
  • 34. DATABASE SHARDING IN TALKABLE STEP BY STEP 1 class Visitor < ShardedRecord 2 has_many :purchases 3 end 4 5 class Purchase < ShardedRecord 6 belongs_to :person 7 has_one :referral 8 end 9 10 class Referral < ShardedRecord 11 has_many :rewards 12 end 13 14 class Reward < ShardedRecord 15 belongs_to :incentive 16 end
  • 35. DATABASE SHARDING IN TALKABLE STEP BY STEP DATABASE NOT SHARDED CONFIG DATA DATABASE SHARD #1 REFERRAL DATA DATABASE SHARD #2 REFERRAL DATA
  • 36. DATABASE SHARDING IN TALKABLE STEP BY STEP 1. How to shard? — expressional + metadata 2. Which tables have to be sharded? — config vs referral 3. Get rid of joins
  • 37. 1 module ShardingJoinFinder 2 TABLE_REFERENCE = /(^|s+)(join|from)s+`?([a-z_]+)`?/i 3 4 def execute(query, name = nil) 5 ensure_sharding_match(query) 6 super(query, name) 7 end 8 9 def select_all(query, *args) 10 ensure_sharding_match(query) 11 super 12 end 13 14 def ensure_sharding_match(query) 15 query.scan(TABLE_REFERENCE).map(&:last) 16 sharded, unsharded = klasses.partition(&:is_sharded?) 17 raise Error if sharded.any? && unsharded.any? 18 end 19 end 20 21 ActiveRecord::ConnectionAdapters::Mysql2Adapter.prepend(ShardingJ 22 ActiveRecord::Relation.prepend(ShardingJoinFinder)
  • 38. DATABASE SHARDING IN TALKABLE STEP BY STEP 1. How to shard? — expressional + metadata 2. Which tables have to be sharded? — config vs referral 3. Get rid of joins — joins detector
  • 39. DATABASE SHARDING IN TALKABLE STEP BY STEP 1. How to shard? — expressional + metadata 2. Which tables have to be sharded? — config vs referral 3. Get rid of joins — joins detector 4. Introduce connection management
  • 40. DATABASE SHARDING IN TALKABLE STEP BY STEP 1. How to shard? — expressional + metadata 2. Which tables have to be sharded? — config vs referral 3. Get rid of joins — joins detector 4. Introduce connection management — gem
  • 41. DATABASE SHARDING IN TALKABLE STEP BY STEP 1. How to shard? — expressional + metadata 2. Which tables have to be sharded? — config vs referral 3. Get rid of joins — joins detector 4. Introduce connection management — gem 5. Add utility helpers
  • 42. 1 class DatabaseUtils 2 class SlaveError < StandardError; end 3 4 class << self 5 def use_shard(shard, &block); end 6 def current_shard; end 7 def uses_slave?; end 8 def config_for(slave: uses_slave?, shard: current_shard); end 9 def connection(slave: uses_slave?, shard: current_shard); end 10 def sharded_tables; end 11 def on_all_shards(&block); end 12 def processlist; end 13 def slave_lag_for(connection); end 14 end 15 end 1 Rails.application.console do 2 def shard(shard) 3 shard = shard.database_shard if shard.respond_to?(:database_shard) 4 DatabaseUtils.use_shard!(shard) 5 end 6 end
  • 43. DATABASE SHARDING IN TALKABLE STEP BY STEP 1. How to shard? — expressional + metadata 2. Which tables have to be sharded? — config vs referral 3. Get rid of joins — joins detector 4. Introduce connection management — gem 5. Add utility helpers — depends on individual needs
  • 44. DATABASE SHARDING IN TALKABLE STEP BY STEP 1. How to shard? — expressional + metadata 2. Which tables have to be sharded? — config vs referral 3. Get rid of joins — joins detector 4. Introduce connection management — gem 5. Add utility helpers — depends on individual needs 6. Migrate
  • 45. 1 production: 2 host: 'master.production.com' 3 database: 'primary' 4 slave: 5 host: 'slave.production.com' 6 database: 'primary' 7 8 shards: 9 1: 10 host: 'master.production.com' 11 database: 'shard_1' 12 slave: 13 host: 'slave.production.com' 14 database: 'shard_1' 15 2: 16 host: 'shard_2.production.com' 17 database: 'shard_2' 18 slave: 19 host: 'slave.shard_2.production.com' 20 database: 'shard_2'
  • 46. 1 production: 2 host: 'master.production.com' 3 database: 'primary' 4 slave: 5 host: 'slave.production.com' 6 database: 'primary' 7 8 shards: 9 1: 10 host: 'shard1.production.com' 11 database: 'shard_1' 12 slave: 13 host: 'slave.shard_1.production.com' 14 database: 'shard_1' 15 2: 16 host: 'shard_2.production.com' 17 database: 'shard_2' 18 slave: 19 host: 'slave.shard_2.production.com' 20 database: 'shard_2'
  • 47. DATABASE SHARDING IN TALKABLE STEP BY STEP 1. How to shard? — expressional + metadata 2. Which tables have to be sharded? — config vs referral 3. Get rid of joins — joins detector 4. Introduce connection management — gem 5. Add utility helpers — depends on individual needs 6. Migrate — profit!!!
  • 48. MySQL PostgreSQL Vites Citus Jetpants ??? ScaleBase DATABASE SHARDING SOLUTIONS
  • 49. PROS CONS Easier to Manage Not Easy to Implement Smaller and Faster Lost Abilities Reduces Costs DATABASE SHARDING CONCLUSION
  • 50. DATABASE SHARDING CONCLUSION • Do not shard your data until you really need it • Choose a sharding model that fits your context (project) • Each additional shard increases the chance of a random crash
  • 51. When: 08:00 am Where: 46°28'44.5"N 30°45'41.0"E How far: doesn’t matter How fast: doesn’t matter SUNDAY MORNING RUN
  • 52. Q&A