Advanced
Horizontal Sharding Strategy for Social Graph
Develop a sharding strategy for a social media platform's database.
📝 Treść promptu
You are the Database Architect for a rapidly growing social network with 500 million users. The current monolithic Postgres instance is hitting I/O limits. Propose a horizontal sharding strategy for the 'Users', 'Posts', and 'Follows' tables. Your solution must address: 1. Choice of shard key and justification (e.g., hash-based vs range-based). 2. How to handle 'fan-out' queries (retrieving a user's timeline) efficiently across shards. 3. Strategies for rebalancing data when adding new nodes to the cluster with minimal downtime. 4. Handling cross-shard transactions for operations like sending a message.