惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Engineering at Meta
Engineering at Meta
The GitHub Blog
The GitHub Blog
博客园_首页
T
The Blog of Author Tim Ferriss
H
Hackread – Cybersecurity News, Data Breaches, AI and More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
腾讯CDC
I
InfoQ
量子位
J
Java Code Geeks
P
Proofpoint News Feed
有赞技术团队
有赞技术团队
Webroot Blog
Webroot Blog
Martin Fowler
Martin Fowler
D
Docker
F
Fortinet All Blogs
云风的 BLOG
云风的 BLOG
V
Vulnerabilities – Threatpost
罗磊的独立博客
P
Proofpoint News Feed
T
The Exploit Database - CXSecurity.com
Cyberwarzone
Cyberwarzone
P
Privacy & Cybersecurity Law Blog
Last Week in AI
Last Week in AI
爱范儿
爱范儿
The Hacker News
The Hacker News
S
SegmentFault 最新的问题
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
V
V2EX
Simon Willison's Weblog
Simon Willison's Weblog
AI
AI
Y
Y Combinator Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
GbyAI
GbyAI
V
Visual Studio Blog
H
Heimdal Security Blog
S
Secure Thoughts
B
Blog RSS Feed
雷峰网
雷峰网
T
Tenable Blog
C
Check Point Blog
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
A
About on SuperTechFans
Recent Commits to openclaw:main
Recent Commits to openclaw:main

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Caching in System Design - The Secret to High Performance
Sushant Gaurav · 2026-06-16 · via DEV Community

There is a point in every system’s growth where adding more servers stops being enough.

You scale horizontally. You introduce load balancers. You distribute traffic efficiently. And yet, something still feels off.

Requests are slower than expected. Databases are under constant pressure. Systems that should scale effortlessly begin to struggle under repeated work.

And then you realise something fundamental:

The system is doing the same work again and again.

The same queries.
The same computations.
The same responses.

Over and over.

This is not a scaling problem.

It is a redundancy problem.

And the solution to this problem is one of the most powerful ideas in system design:

Caching.

What Is Caching, Really?

At a surface level, caching is often defined as storing frequently accessed data in a faster storage layer so it can be retrieved quickly.

But this definition, while correct, does not capture its true significance.

Caching is not just a performance optimisation.

It is a shift in how systems think about work.

Instead of asking:

Can we compute this quickly?

Caching asks:

Do we need to compute this at all?

That shift from computation to reuse is what makes caching so powerful.

The Cost of Repeated Work

To understand why caching matters, we need to look at what happens without it.

Imagine a system where every user request requires:

  • Fetching data from a database
  • Performing business logic
  • Formatting a response

This process may take only a few milliseconds per request. But at scale, those milliseconds add up.

When thousands or millions of users request the same data, the system is forced to:

  • Execute identical database queries repeatedly
  • Perform the same computations
  • Generate the same responses

This creates unnecessary load on the system, especially on components like databases, which are often the most expensive and limited resources.

Over time, this repeated work becomes the bottleneck.

Caching addresses this by eliminating redundant effort.

The Core Idea - Store Once, Serve Many

At its heart, caching is simple.

When a request is processed, instead of discarding the result, the system stores it in a cache. The next time the same request arrives, the system can return the cached result instead of recomputing it.

Caching Core Idea

This introduces two fundamental concepts:

  • Cache Hit - The data is found in the cache and returned immediately
  • Cache Miss - The data is not in the cache, so it must be computed and then stored

The effectiveness of a caching system is often measured by its cache hit rate.

Higher hit rate → fewer expensive operations → better performance.

Why Caching Changes Everything

Caching has a profound impact on system behaviour.

Reduced Latency

Fetching data from memory is significantly faster than querying a database or calling an external service.

Increased Throughput

By reducing the load on core systems, caching allows more requests to be handled simultaneously.

Lower System Load

Databases, APIs, and backend services experience less pressure, improving overall system stability.

Better Scalability

Systems can handle larger traffic without proportionally increasing infrastructure.

This is why caching is used extensively in large-scale systems.

Platforms like Netflix and Google rely heavily on caching at multiple layers to serve massive amounts of data efficiently.

Where Does the Cache Live?

One of the most important design decisions in caching is where to place the cache.

Because caching is not a single layer, it can exist at multiple points in the system.

Application-Level Cache

The simplest form of caching happens within the application itself.

Data is stored in memory inside the server process.

This is:

  • Extremely fast
  • Easy to implement

But it has limitations:

  • Not shared across servers
  • Lost when the server restarts

This works well for small-scale systems or single-node setups.

Distributed Cache

As systems scale horizontally, caching must also scale.

Instead of storing cache locally, systems use distributed caching systems that are shared across multiple servers.

This allows:

  • Consistent access to cached data
  • Better cache utilisation
  • Scalability across nodes

However, it introduces:

  • Network overhead
  • Cache synchronisation challenges

Edge Cache (CDN)

At the highest level, caching can move closer to the user.

Content Delivery Networks (CDNs) store cached data in geographically distributed locations.

When a user requests content, it is served from the nearest location rather than the origin server.

This drastically reduces latency and server load.

This is how platforms like Amazon and Netflix deliver content globally with high performance.

The Trade-off Begins

At this point, caching may seem like a perfect solution.

Faster responses.
Lower load.
Better scalability.

So why not cache everything?

Because caching introduces a new and unavoidable challenge:

Data can become stale.

When the underlying data changes, cached data may no longer be accurate.

And this leads us to one of the hardest problems in system design:

Cache invalidation.

But as systems grow, a deeper and more uncomfortable truth begins to emerge:

Caching is easy to add… but very hard to get right.

Because the moment you introduce a cache, you are no longer just optimising performance, you are managing two versions of reality:

  • The source of truth (database)
  • The cached copy (fast, but potentially outdated)

And keeping these two in sync is where the real challenge begins.

Cache Invalidation - The Hardest Problem

There’s a well-known saying in system design:

There are only two hard things in Computer Science: cache invalidation and naming things.

It sounds like a joke, but it isn’t.

Cache invalidation is the process of ensuring that cached data remains accurate when the underlying data changes.

Let’s say a product’s price changes in the database. If the old price is still stored in the cache, users may see outdated information.

So the system must decide:

  • When should the cache be updated?
  • Should it be updated immediately or later?
  • Should it be removed entirely?

Each choice comes with trade-offs between consistency, performance, and complexity.

Common Approaches to Cache Invalidation

There is no single correct way to handle cache invalidation. Instead, systems use different strategies depending on their requirements.

Time-Based Expiration (TTL)

One of the simplest approaches is to assign a time-to-live (TTL) to cached data.

After a fixed duration, the cache entry expires and is removed.

This approach is:

  • Easy to implement
  • Predictable
  • Widely used

But it has limitations.

If the TTL is too long:

  • Data may remain stale for too long

If the TTL is too short:

  • Cache effectiveness decreases (more misses)

So choosing the right TTL becomes a balancing act.

Write-Based Invalidation

Another approach is to update or invalidate the cache whenever data changes.

For example:

  • When a product is updated → update or delete its cache entry

This ensures better consistency, but introduces complexity:

  • Every write operation must handle cache updates
  • Failures in cache updates can lead to inconsistencies

This approach works well when accuracy is critical.

Explicit Invalidation

Sometimes, systems explicitly remove cache entries when they know data has changed.

Instead of updating the cache, they simply delete it, forcing the next request to fetch fresh data.

This is simple and safe, but may temporarily increase load due to cache misses.

Caching Strategies - When to Read and Write

Beyond invalidation, another important question is:

When should the system interact with the cache?

This leads to different caching strategies.

Cache-Aside (Lazy Loading)

This is the most commonly used strategy.

When a request arrives:

  1. Check the cache
  2. If data exists → return it (cache hit)
  3. If not → fetch from database, store in cache, then return

Cache-Aside

This approach is:

  • Simple
  • Flexible
  • Widely adopted

But it can lead to stale data if not invalidated properly.

Write-Through Cache

In this strategy, data is written to both:

  • Cache
  • Database

simultaneously.

This ensures that the cache is always up-to-date.

However:

  • Writing becomes slower
  • More coordination is required

Write-Back (Write-Behind)

Here, data is first written to the cache, and the database is updated later.

This improves write performance but introduces risk:

  • If the cache fails before writing to the database, data may be lost

This strategy is used when performance is prioritised over immediate consistency.

Cache Eviction - Making Space for New Data

Caches are not infinite.

At some point, they run out of space.

So the system must decide:

Which data should be removed to make room for new data?

This is handled through eviction policies.

LRU (Least Recently Used)

Removes data that has not been accessed recently.

This works well because frequently accessed data tends to remain in the cache.

LFU (Least Frequently Used)

Removes data that is accessed the least often.

This is useful when certain data is consistently popular.

TTL-Based Eviction

Data is removed after a fixed time, regardless of usage.

Each policy reflects a different assumption about how users interact with data.

Choosing the right one depends on your access patterns.

When Caching Goes Wrong

Caching is powerful, but when misused, it can create serious problems.

Stale Data Issues

Users see outdated information, leading to inconsistencies.

Cache Stampede

When a popular cache entry expires, many requests hit the database simultaneously, overwhelming it.

Increased Complexity

Managing cache logic, invalidation, and consistency adds significant engineering overhead.

Hidden Bugs

Caching can mask underlying issues, making debugging harder.

The Deeper Insight

At this point, caching should no longer feel like a simple optimisation.

It is a trade-off system.

You trade:

  • Freshness for speed
  • Simplicity for performance
  • Consistency for scalability

And like everything in system design, there is no perfect choice.

Only the choice that best fits your requirements.

Final Thought

The most important thing to understand about caching is this:

Caching does not make your system faster; it makes your system do less work.

And at scale, doing less work is the only way to survive.

Because the systems that scale are not the ones that compute faster:

They are the ones that avoid unnecessary computation altogether.