// simulator
Caching Strategies Simulator
Learn caching fundamentals with an interactive simulator. Visualize cache hits, misses, eviction policies (LRU, LFU, FIFO), and understand write strategies.
LRU: Removes the item accessed longest ago
Green ring = in cache
Press 1-6 to request, R to reset
Cache is empty
Every request goes to the database (50-200ms). Slow!Every request = slow DB call
Repeated requests return instantly (1-10ms). 20x faster!Repeat requests = instant!
The eviction policy decides what to remove when cache is full.
Understanding Caching Strategies
Eviction Policies
- LRU (Least Recently Used): Evicts items not accessed recently. Most common in practice.
- LFU (Least Frequently Used): Evicts items accessed least often. Great for identifying hot data.
- FIFO (First In, First Out): Simple queue-based approach, evicts oldest items first.
- TTL (Time To Live): Evicts items based on expiration time. Common for sessions.
Write Strategies
- Write-Through: Writes to cache and database simultaneously. Strong consistency but higher latency.
- Write-Back: Writes to cache first, async to database. Better performance but risk of data loss.
- Write-Around: Writes directly to database, bypasses cache. Reduces cache pollution.
Key concepts
- Hit rate: Percentage of requests served from cache (higher is better).
- Cache size: Balance between memory usage and hit rate.
- Hot data: Frequently accessed items that benefit most from caching.
- Cache invalidation: One of the hardest problems in computer science.
Try next
// simulator
Horizontal vs Vertical Scaling Simulator
Interactive game to learn scaling strategies for web applications. Experiment with horizontal and vertical scaling, see the effects on performance, cost, and reliability with realistic pricing simulation and budget constraints.
// simulator
BCDR Simulator
Learn Business Continuity & Disaster Recovery with interactive RTO/RPO planning, failover strategies, and disaster scenarios. Understand hot, warm, and cold DR sites.
// simulator
Load Balancer Algorithm Simulator
Learn how different load balancing algorithms distribute traffic across servers. Experiment with Round Robin, Least Connections, IP Hash, and more. See how load balancers handle failures and optimize performance.