System Design: In-Memory Database Engine (Single-Node Core, Scale-Out Aware)
Context
Design the core of an in-memory, single-node database engine intended to be the building block for a larger distributed system. Data is primarily memory-resident on each node; durability and scale-out are achieved via logging, snapshots, and replication/sharding across multiple such nodes.
Requirements
-
CRUD operations on records.
-
Efficient querying: point lookups and range scans; basic filtering and ordering.
-
Transaction isolation: define levels supported (at least read committed and snapshot isolation; discuss path to serializable).
-
Persistence and backup: crash recovery, snapshots/checkpoints, WAL, and restore.
-
Horizontal scalability: strategy for replication and sharding across multiple single-node instances.
Deliverable
Provide a design that covers:
-
Data model and API surface.
-
In-memory storage layout and indexing.
-
Query execution approach.
-
Concurrency control and transaction management.
-
Durability: WAL, checkpoints/snapshots, recovery.
-
Backup/restore strategy.
-
Horizontal scaling: replication and sharding.
-
Operational concerns: garbage collection, observability, and pitfalls.