KatInterview

Cutting Read Latency in a Normalized Relational Schema

System DesignModel answer
MediumModel answerSystem Designdatabase-designdenormalizationcaching

Last updated

Speed up the hottest reads of a live service backed by a normalized database, and explain the write-path cost, freshness impact and rollout plan of each change.

A production service stores its data in a normalized relational database. Its most frequent read endpoints build each response by joining several related tables, and read latency on those endpoints is above what the team wants.

Your task: describe how you would change the database design and the read path to lower read latency.

In your answer, cover:

  • How you would find out where the time goes before changing anything.
  • Which schema, indexing and query changes you would make, and which read path each one targets.
  • Whether and how you would add caching, including invalidation, a bound on staleness, and what happens when many entries expire together.
  • What each change costs in write latency, storage, complexity and data freshness.
  • How you would keep any derived or duplicated data correct over time.
  • How you would roll the change out safely on a live system.

You have about 15 minutes, so lead with the changes that matter most and be prepared to go deeper on any of them. State any assumptions you make about the workload (read/write ratio, table sizes, freshness requirements, latency target).

Hints

Hint 1

Do not redesign first. Which queries are slow, and is the time spent in joins, aggregates computed at read time, missing indexes, many round trips per request, or lock contention with writes?

Hint 2

Order the fixes from cheapest and safest to most invasive: query and index fixes, then read replicas and caching, then precomputed or denormalized read models. For each, name the write cost and the staleness it introduces.

Hint 3

Derived data drifts. Decide how it is updated (same transaction, async events, or periodic rebuild), how you detect and repair mismatches, and how you migrate with dual writes, backfill, shadow reads and a fast rollback.