Replication, Partitioning, and Sharding Questions

Scaling and distributing data across nodes: primary-replica and multi-primary replication, read-replica scaling, horizontal partitioning, and sharding strategies with their key-selection and rebalancing challenges. Covers replication lag, failover and split-brain handling, cross-shard operations such as joins, distributed transactions, and global secondary indexes, and the operational cost of a partitioned topology. Key to designing databases that scale horizontally.

EasyTechnical
136 practiced

List and explain four properties that make a good shard key. For each property, give a brief example (user_id, timestamp, region, email hash, etc.) and explain why it helps avoid hotspots or cross-shard queries.

MediumTechnical
103 practiced

Explain replication lag in read replicas: common causes, the user-visible impact, and SRE strategies to detect and alert on replication lag. Which metrics would you collect (and their percentiles), and what reasonable alert thresholds might you recommend in production?

MediumTechnical
76 practiced

You manage a Postgres 13 OLTP cluster receiving 100M events/day. Given this schema:

CREATE TABLE events (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL,
occurred_at TIMESTAMP NOT NULL,
event_type TEXT,
payload JSONB
);

Write a Postgres CREATE TABLE and partitioning strategy (monthly partitions) in SQL, including indexes and a plan to add future partitions. Explain why you chose the partition key and index placements.

HardSystem Design
72 practiced

Design a method to generate globally unique IDs across shards with low latency. Requirements: IDs must be sortable by time, space efficient, collision-free, and support up to 100k ID generations/sec across the cluster. Discuss approaches like Twitter Snowflake, UUID variants, or centralized ID services.

HardTechnical
91 practiced

Cross-shard joins are expensive. Describe three practical strategies to handle queries that join data across shards (e.g., join users to transactions where users are sharded by user_id and transactions by account_id). For each strategy discuss latency, complexity, and when you'd pick it.

Unlock Full Question Bank

Get access to all Replication, Partitioning, and Sharding interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.