Cache the Hot Path
Medium About 55 min Free with an account
The product page hammers the database directly and melts under load. Design a read path with a load balancer, a cache and a replica, while keeping the client off the database.
The brief
Requirement: Serve a read-heavy hot path without melting the database. The product page is the busiest read in the system: thousands of requests fetch the same small set of rows, and today every one of them reaches the database, so at peak it saturates and p99 latency spikes past a second. The database is also a single point of failure: lose it and every product page dies with it.
Design a read path that absorbs the repeated reads, keeps the app tier redundant, and leaves the system of record standing when traffic peaks.
The topology represents responsibilities and interaction semantics. You do not need to choose a specific product, eviction policy, or replication mode. This tier checks structure; the workload model then measures how your design holds up.
Drag components from the palette, wire them together, then Check your design. Prefer to be guided step by step? The first hint holds the guided plan.
After the structural checks pass, Katabench runs a deterministic workload model. Check runs the public steady-peak scenario; Submit also runs fixed hidden cold-cache and app-failure scenarios. Your design must:
- Sustain at least 9,500 requests/second with p99 latency ≤ 100 ms.
- Keep the error rate at or below 0.5% and recover from an injected app failure within 2 s.
- Stay below 85% modeled CPU/memory, a 5,000-request queue, and $1,800/month modeled cost.
Select a component to change its capacity tier or cache memory. One canvas node is one independently failing instance; add nodes to scale horizontally. Cost is a versioned educational estimate, not a cloud-provider quote.
- A client must never connect directly to a database. Route every request through the app tier.
The same topology and settings always produce the same result: the simulator uses fixed workload versions and seeds, never browser or worker wall-clock timing.
How it is graded
You build the design on a canvas, and Katabench checks the topology against the challenge's design rules.
Related guides
What it practices
- Caching
- Put a cache in front of hot reads and decide what stays fresh.
Do these first
Related katas
- Fan Out Home Timelines Medium Free with account Reading every followed author on demand is collapsing the database. Publish post events and materialize timelines asynchronously.
- Cache DNS and Robots Rules Medium Pro Share DNS answers and robots policy across fetchers so repeated control lookups do not dominate the crawl or violate site rules.
- Cache the Redirect Medium Pro Reads outnumber writes a thousand to one and every redirect still hits the database. Cache the read path only (writes go around it) and give the links a replica.
- Cache the Video Watch Page Medium Pro Every premiere viewer reads the same watch-page rows. Cache the metadata reads; the video bytes keep their own uncached path to storage.