HARDData Storagestaff engineer

Design a Distributed Cache

Design a distributed caching system like Redis or Memcached that can handle millions of requests per second.

Estimated Time: 45 minutes
GoogleAmazonMetaMicrosoft
#caching#distributed-systems#consistent-hashing#lru

Solution Overview

Redis uses in-memory hash tables with persistence via RDB snapshots or AOF logs. Skip lists provide O(log n) operations. Pub/Sub pattern for real-time messaging. Multiple data structures: strings, lists, sets, sorted sets, hashes.

Architecture Pattern

In-memory data structure store with persistence and pub/sub

Key Concepts

Hash TablesSkip ListsReplicationLua ScriptingAOF

Used By Companies

TwitterUberShopify

Learn Implementation Details

Explore a complete guide for building this system from scratch with step-by-step tutorials:

Solution Overview

Redis uses in-memory hash tables with persistence via RDB snapshots or AOF logs. Skip lists provide O(log n) operations. Pub/Sub pattern for real-time messaging. Multiple data structures: strings, lists, sets, sorted sets, hashes.

Hints to Get Started
1

Research consistent hashing

2

How do you handle hot keys?

3

Consider cache invalidation strategies

Companies
  • •Twitter
  • •Uber
  • •Shopify
Key Concepts
  • •Hash Tables
  • •Skip Lists
  • •Replication
  • •Lua Scripting
  • •AOF
Implementation Url

https://github.com/codecrafters-io/build-your-own-x#build-your-own-redis