educative.io

Educative

Question on Sharding

I have a question on sharding, @Design_Gurus, @sys_design_grokker appreciate it if you can answer please?

you have mentioned the when we shard by Tweet ID

" 1. Our application (app) server will find all the people the user follows."

To do this application Server needs to send the query to Database, How would we do that? Since the Database is not sharded by UserID, don’t we have to hit all the shards now?

Good question. I think the tweet table is sharded by tweet ID which has the epoch time as prefix. Check Twitter Snowflake ID. The user/follow tables should be shared by user ID instead. Sharding is more about a single table I assume. Each database shard will host one partition of each table which is “sharded” independently.