Cache thrashing occurs when the total memory footprint of frequently accessed data—the working set—is larger than the cache itself. The eviction policy continuously removes entries that are still needed, only to reload them moments later. This creates a vicious cycle where the CPU or inference engine spends more time managing cache misses than performing useful computation, often reducing throughput by an order of magnitude.
Glossary
Cache Thrashing

What is Cache Thrashing?
Cache thrashing is a pathological performance state where a cache is forced to constantly evict and reload entries because the active working set of data exceeds the available cache capacity, causing throughput to collapse.
In sovereign inference caching, thrashing is triggered when the diversity of incoming queries overwhelms the semantic cache's vector index. Instead of serving low-latency hits, the system thrashes between embedding lookup, eviction, and recomputation. Mitigation requires increasing cache memory, implementing cache tiering to absorb working set fluctuations, or deploying adaptive caching policies that detect thrashing and dynamically adjust TTLs to stabilize the hit ratio.
Core Characteristics of Cache Thrashing
Cache thrashing is a catastrophic performance state where the working set of active queries exceeds the available cache memory, forcing the system into a perpetual cycle of eviction and reloading. The cache provides no benefit while consuming significant CPU and I/O overhead.
The Eviction Death Spiral
Thrashing occurs when the working set—the collection of entries actively being accessed—is larger than the cache capacity. Every new request forces an eviction of an entry that will be needed again almost immediately. The cache hit ratio collapses toward 0%, yet the system incurs the full overhead of cache lookups, eviction processing, and reloading from the origin. This creates a negative net benefit: the cache makes the system slower than having no cache at all.
Root Cause: Working Set Exceeds Capacity
The primary trigger is a mismatch between cache size and access patterns. Key scenarios include:
- Rapid context switching between many distinct inference contexts that collectively exceed memory
- Highly random access patterns with low temporal locality, where entries are accessed once and never again
- Cache pollution from one-shot queries that displace frequently reused entries
- Memory pressure from the host system forcing the cache process to swap, compounding latency
Thrashing vs. Normal Misses
A healthy cache experiences compulsory misses (first access) and capacity misses (working set near limit). Thrashing is distinct: it is a non-linear phase transition where the miss rate suddenly spikes as the working set crosses the capacity threshold. Unlike normal operation where increasing cache size improves hit rate, a thrashing cache may show zero improvement from small size increases until the working set fits entirely. The system exhibits high CPU utilization with low throughput—a classic thrashing signature.
Detection Metrics
Identify thrashing through these telemetry signals:
- Hit ratio drops below 20% and continues declining under steady load
- Eviction rate spikes dramatically while the cache size remains at maximum
- Average TTL of evicted entries drops to seconds or milliseconds—entries are evicted before they can be reused
- Origin load increases to near-direct-access levels despite the cache layer being present
- P99 latency increases due to the combined cost of cache miss + eviction + reload
Mitigation Strategies
Resolving thrashing requires structural changes:
- Increase cache memory to exceed the working set size, moving past the phase transition point
- Implement cache tiering with a larger, slower secondary cache to absorb the working set overflow
- Apply admission policies that reject caching for one-hit-wonder entries, preventing cache pollution
- Use probabilistic eviction like TinyLFU that estimates entry frequency to protect frequently accessed items
- Partition the cache by tenant or query type to isolate thrashing workloads from stable ones
Sovereign Infrastructure Implications
In sovereign deployments with fixed, pre-provisioned hardware, thrashing is especially dangerous because elastic scaling is restricted. An air-gapped GPU cluster cannot burst to cloud resources. Mitigation must be proactive:
- Workload characterization before deployment to right-size cache allocations
- Circuit breakers that detect thrashing and temporarily bypass the cache to serve directly from the model, preserving throughput at the cost of latency
- Semantic cache compaction using Product Quantization to fit more embeddings in the same memory footprint
Frequently Asked Questions
Cache thrashing represents a critical failure mode in sovereign inference caching layers where the working set exceeds available memory, causing performance to collapse. The following questions address the root causes, detection methods, and remediation strategies for this pathological state.
Cache thrashing is a pathological performance state where a caching layer spends more compute cycles evicting and reloading entries than actually serving cached responses. It occurs when the working set—the set of data actively accessed by the application—significantly exceeds the available cache memory capacity. In sovereign inference environments, this manifests when the volume of distinct LLM query embeddings surpasses the allocated memory for the semantic cache. The system enters a vicious cycle: a new request forces eviction of a recently cached entry, which is then immediately requested again, triggering another eviction. The cache hit ratio plummets toward zero, while backend model inference latency spikes as every request becomes a cache miss. This is distinct from simple capacity pressure; thrashing specifically describes the oscillating state where evictions directly cause subsequent misses in rapid succession.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Cache thrashing is closely linked to eviction policy design, working set estimation, and resilience patterns. These concepts help diagnose, prevent, and mitigate thrashing in sovereign inference caching layers.
Cache Eviction Policy
The deterministic algorithm that decides which entries to remove when a cache reaches its memory capacity. A poorly chosen policy is the primary cause of thrashing.
- LRU (Least Recently Used): Discards the oldest access; vulnerable to thrashing when working sets exceed cache size.
- LFU (Least Frequently Used): Tracks access frequency; resists one-hit-wonder pollution but adapts slowly.
- ARC (Adaptive Replacement Cache): Balances recency and frequency, self-tuning to resist sequential scan thrashing.
- TinyLFU: Uses a compact sketch to estimate frequency with minimal memory, ideal for high-throughput semantic caches.
Working Set Estimation
The set of unique cache keys actively accessed within a given time window. Thrashing begins when the working set size sustainably exceeds the allocated cache capacity.
- Denning's Working Set Model: Defines the working set as pages referenced in the last
Δtime units; directly applicable to cache key access patterns. - HyperLogLog Sketching: A probabilistic data structure that estimates unique key cardinality with ~2% error using only ~1.5KB of memory.
- Miss Ratio Curves (MRC): Profiles how hit rate changes with cache size; identifies the cliff edge where thrashing begins.
- Monitoring the gap between working set size and cache capacity provides early warning before performance collapses.
Cache Stampede
A cascading failure where a popular cache entry expires, causing a flood of concurrent requests to simultaneously hit the origin model. While distinct from thrashing, stampedes can trigger thrashing-like symptoms by overwhelming the backend.
- External Recompute: Multiple clients independently detect expiration and each recompute the value.
- Probabilistic Early Expiration: Artificially expires hot keys early with a probability proportional to their popularity, allowing one request to refresh while others use stale data.
- XFetch Algorithm: Computes optimal recomputation time using
delta * beta * log(rand())where delta is time-to-recompute and beta controls the refresh window. - Stampede-induced latency spikes can mimic thrashing in observability dashboards; distinguish by checking concurrent miss counts.
Circuit Breaker
A stability pattern that automatically stops sending requests to a failing cache backend or model endpoint when error rates exceed a threshold. Prevents thrashing from cascading into total system failure.
- Closed State: Normal operation; requests flow to the backend.
- Open State: Requests immediately fail fast without touching the backend; a cooldown timer prevents retries.
- Half-Open State: A limited number of probe requests test if the backend has recovered before fully closing the circuit.
- In sovereign inference caches, circuit breakers protect GPU clusters from being overwhelmed when thrashing causes repeated cache misses against the origin model.
Cache Tiering
A multi-level storage strategy that places the hottest, most frequently accessed data in fast, expensive memory while demoting cooler data to slower, cheaper storage. Mitigates thrashing by expanding effective capacity without linear cost.
- L1 (Hot): In-memory cache (e.g., Redis, Memcached) with microsecond latency; holds the active working set.
- L2 (Warm): Local SSD-backed cache (e.g., NVMe) with sub-millisecond latency; holds the extended working set.
- L3 (Cold): Object storage or distributed cache with higher latency; holds long-tail entries.
- Promotes entries to L1 on access; demotes based on frequency decay. Prevents thrashing by absorbing working set overflow into lower tiers rather than evicting hot entries.
Graceful Degradation
A resilience strategy where the system serves stale cached data or a static fallback response when the primary inference backend is unavailable. Essential for maintaining availability during thrashing-induced backend overload.
- Stale-While-Revalidate: Serve expired cache entry immediately while asynchronously refreshing in the background.
- Static Fallback: Return a pre-computed default response when no cache entry exists and the backend is unreachable.
- Soft TTL vs Hard TTL: Soft TTL triggers background refresh; hard TTL is the absolute expiration after which entries are never served.
- In sovereign deployments, graceful degradation ensures air-gapped systems remain operational even when model servers are under duress from thrashing workloads.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us