Caching strategies

Task Statement 2.1: Design scalable and loosely coupled architectures.

📘AWS Certified Solutions Architect – (SAA-C03)


1. What is Caching?

Caching means storing frequently accessed data in a temporary, high-speed storage layer so that future requests for that data can be served faster.

Instead of repeatedly fetching data from a slow system (like a database or external API), the system retrieves it from a faster layer called a cache.

In AWS architecture, caching is very important for:

  • Improving performance
  • Reducing latency
  • Lowering database load
  • Reducing cost
  • Increasing scalability

For the SAA-C03 exam, you must understand:

  • Where caching can be implemented
  • Which AWS services provide caching
  • When to use each caching strategy
  • How caching improves scalability and loose coupling

2. Why Caching Is Important for Scalable Architectures

When a system grows:

  • More users send requests
  • Databases get overloaded
  • Applications slow down
  • Costs increase

Caching helps by:

✅ Reducing the number of direct database calls
✅ Reducing compute usage
✅ Reducing network calls
✅ Improving response time
✅ Supporting horizontal scaling

In scalable systems, caching reduces dependency on backend systems, which helps create loosely coupled architectures.


3. Types of Caching in AWS Architectures

For the SAA-C03 exam, caching can be divided into:

  1. Client-side caching
  2. CDN caching (edge caching)
  3. Application-level caching
  4. Database caching
  5. DNS caching

Let’s understand each one clearly.


4. Edge Caching (CDN Caching)

Service: Amazon CloudFront

What It Does

CloudFront stores copies of static and dynamic content at edge locations around the world.

When a user requests content:

  • The request is served from the nearest edge location
  • The origin server (like S3 or EC2) is not contacted every time

What Can Be Cached?

  • Images
  • Videos
  • CSS, JavaScript files
  • API responses
  • HTML pages

Benefits

  • Very low latency
  • Reduced load on origin servers
  • Global performance improvement
  • DDoS protection integration

Exam Tip

If the question mentions:

  • Global users
  • Static content
  • Reducing latency worldwide
  • Reducing load on origin

→ The answer is usually CloudFront caching.


5. In-Memory Caching (Application-Level Caching)

Service: Amazon ElastiCache

What It Does

ElastiCache stores data in memory (RAM) for extremely fast access.

It supports:

  • Redis
  • Memcached

Memory access is much faster than database disk access.

When Is It Used?

  • Frequently accessed database query results
  • Session data
  • Leaderboards
  • Frequently used configuration data
  • API response caching

How It Improves Scalability

Instead of:
Application → Database (every time)

It becomes:
Application → Cache → Database (only if needed)

This reduces database load and allows the system to handle more users.


Redis vs Memcached (Exam Important)

Redis

  • Supports replication
  • Supports persistence
  • Supports complex data types
  • Multi-AZ support

Memcached

  • Simple key-value
  • No replication
  • No persistence
  • Multi-threaded

Exam Tip:

If high availability or replication is required → Choose Redis.


6. Database Caching

Service: Amazon RDS

RDS does not automatically cache everything, but you can:

  • Use read replicas
  • Use ElastiCache with RDS
  • Enable query caching (engine-dependent)

Read Replicas

Used for:

  • Offloading read traffic
  • Improving scalability

If the question says:

  • Heavy read workload
  • Reduce primary DB load
  • Improve performance

→ Use RDS Read Replica


7. DynamoDB Caching

Service: Amazon DynamoDB

Feature: DynamoDB Accelerator (DAX)

What is DAX?

DAX is an in-memory cache for DynamoDB.

It:

  • Reduces read latency from milliseconds to microseconds
  • Is fully managed
  • Works as a caching layer in front of DynamoDB

Exam Tip

If the question says:

  • DynamoDB performance issue
  • Improve read performance
  • Reduce latency
  • No application change required

→ The answer is DAX


8. API Caching

Service: Amazon API Gateway

API Gateway supports built-in caching.

When enabled:

  • Responses are cached
  • Repeated API calls return cached data
  • Backend load decreases

Used For:

  • Frequently requested API responses
  • Public APIs
  • Microservices architecture

9. Client-Side Caching

In this strategy:

  • The client (browser or application) stores responses locally
  • Uses HTTP cache headers

Example:

  • Cache-Control
  • Expires
  • ETag

Reduces repeated calls to backend services.

Exam usually tests:

  • How to reduce API calls
  • Improve performance
  • Reduce cost

10. TTL (Time to Live)

TTL defines how long data remains in cache.

After TTL expires:

  • Cache invalidates
  • Data must be fetched from origin again

Choosing TTL is very important:

Short TTL:

  • More fresh data
  • More backend calls

Long TTL:

  • Less backend load
  • Risk of stale data

11. Cache Invalidation

Sometimes cached data must be removed manually.

Methods:

  • Automatic TTL expiry
  • Manual invalidation
  • Cache versioning

For CloudFront:
You can invalidate specific files.


12. Write Strategies in Caching (Very Important for Exam)

There are 3 main write patterns:


1. Cache-Aside (Lazy Loading)

Flow:

  1. Application checks cache
  2. If not found → fetch from database
  3. Store in cache
  4. Return to user

Most common pattern.

Used in:

  • ElastiCache
  • DAX

2. Write-Through

Flow:

  1. Application writes to cache
  2. Cache writes to database

Ensures:

  • Cache always updated
  • Data consistency improved

3. Write-Behind (Write-Back)

Flow:

  1. Write to cache
  2. Cache updates database later

Improves performance but:

  • Risk of data loss if cache fails

Exam may test:

  • Performance vs consistency trade-offs

13. How Caching Supports Loose Coupling

Loose coupling means:
Components do not depend tightly on each other.

Caching helps because:

  • Application does not always depend on database
  • Backend systems can fail without immediate impact
  • Traffic spikes are absorbed by cache
  • Reduces direct system-to-system dependency

This improves:

  • Fault tolerance
  • Scalability
  • Availability

14. When NOT to Use Caching

Caching is not good for:

  • Frequently changing data
  • Real-time financial data
  • Critical real-time updates
  • Very small workloads

Exam may test this by asking:
“Which solution ensures the most up-to-date data?”

Answer:
Avoid heavy caching.


15. Cost Optimization Using Caching

Caching reduces:

  • RDS compute cost
  • DynamoDB read capacity usage
  • EC2 processing load
  • API calls
  • Data transfer

CloudFront reduces:

  • Origin data transfer cost

16. Common Exam Scenarios and What to Choose

ScenarioBest Service
Global content deliveryCloudFront
Reduce RDS read loadRead Replica or ElastiCache
Improve DynamoDB read performanceDAX
Cache API responsesAPI Gateway caching
Store session dataElastiCache Redis
Reduce database costAdd caching layer

17. Architecture Pattern for Scalable Design

Typical scalable architecture:

Users → CloudFront → Load Balancer → EC2 → ElastiCache → RDS

Caching reduces pressure on:

  • EC2
  • Database
  • Network

This allows:

  • Horizontal scaling
  • Auto Scaling groups
  • Microservices growth

18. Key Differences to Remember for Exam

  • CloudFront = Edge caching
  • ElastiCache = In-memory caching
  • DAX = DynamoDB caching
  • Read Replicas = Database scaling
  • API Gateway caching = API response caching

19. High Availability and Caching

ElastiCache Redis:

  • Multi-AZ
  • Automatic failover

CloudFront:

  • Global redundancy

DAX:

  • Multi-node cluster support

20. Final Exam Checklist (Very Important)

You must understand:

✔ When to use CloudFront vs ElastiCache
✔ Redis vs Memcached differences
✔ DAX purpose
✔ TTL and invalidation
✔ Write-through vs Cache-aside
✔ How caching reduces database load
✔ How caching improves scalability
✔ How caching supports loose coupling


Final Summary

Caching is one of the most important strategies in scalable AWS architectures.

It:

  • Improves speed
  • Reduces backend pressure
  • Reduces cost
  • Improves availability
  • Supports loosely coupled design

For SAA-C03, expect scenario-based questions like:

  • “Application performance is slow due to high read traffic.”
  • “Users globally experience high latency.”
  • “Database is overloaded with read queries.”
  • “Need microsecond latency for DynamoDB.”

In those cases, caching is usually the correct architectural improvement.

Buy Me a Coffee