2 ms·
What kind of sharding strategy would be a good one for a reddit-like site? Would you shard based on post-id? Would you duplicate/denormalize the user comments
by drakenot 3y ago
What kind of sharding strategy would be a good one for a reddit-like site?
Would you shard based on post-id?
Would you duplicate/denormalize the user comments and store them along-side users also, to make the "show all comments for a particular user" operation easier?
- noduerme 3y agoI'd probably make user post lists lower on the priority for selects either way. Date range is clearly how you want to partition if you can, as long as you can table up points without hitting the whole damn history for every point change. For something with lots of subs I'd shard by sub / related subs and then partition by date range, subpartition by user id range (probably). That would make user score accretion very slow but most immediate views within a sub or a thread fast. But it would depend on the patterns and seeing what queries took the longest. Triggers to user_points on some monolith table might be doable. Also at that point you can run jobs to build user post tables and point scores in a lazy way. Placing immediate post writes and hot thread reads as first priority makes sense if you do have to trade off performance somewhere.