3 ms·
I’ve manually implemented this approach before and I would be a little scared of doing it automatically. When you do it manually you are very aware of queries
by Negitivefrags 5y ago
I’ve manually implemented this approach before and I would be a little scared of doing it automatically.
When you do it manually you are very aware of queries that need to go to multiple shards and really do whatever it takes to avoid them.
We sharded by account id and all an individual users data would be on that shard.
Basically the only queries that need to transcend the shard are when you need to enumerate accounts by some non-ID value like an email address. You have to ask all the shards in that case.
Things like creating an account are tricky if you want to make sure that each has a unique email address. You need to use two-phase commit across all the databases to do it reliably.