Sharding
This is the second article of my Distributed Systems series. If you haven't read the previous one, here: Read Replication.
Sharding
What if things get too tough for the leader database (referring back to read replication)?
Writing and distributing t...
tigerabrodi.blog1 min read
Nice and concise article. I would like to add a few points:
Before sharding, we should definitely consider
vertical partitioning.Actually, it doesn't matter. We just need to generate a hash from the given key(s) to a range
[0,numberOfShards-1]. For example, you can have a table with a composite Primary Key as(employeeId (int), department (string)). Even in the above scenario, we can hash it to an integer and then take modulo withnumberOfShards.Important ⚠️: We need to think a bit about the
hash functionandnumberOfShardsvalue and ensure that data gets evenly spread.