သဘောတရား
Caching strategies
Keep a copy of hot data close to the reader: at the edge, in front of the API, in memory next to the database.
ဒီသင်ခန်းစာကို မြန်မာဘာသာ မပြန်ရသေးလို့ အင်္ဂလိပ်လို ပြထားပါတယ်။
A request can be answered at any stop before the database: browser, edge, API, memory.
Cache filled
- Lazy loading
- On a miss, when read
- Write-through
- On every write
Stale data
- Lazy loading
- Possible until the TTL ends
- Write-through
- Rare
Wasted memory
- Lazy loading
- None: only read data
- Write-through
- Data nobody reads
First read
- Lazy loading
- Slow: miss, then fill
- Write-through
- Fast: already cached
Best for
- Lazy loading
- Read-heavy, a little age is fine
- Write-through
- Fresh data after a write
| Compare | Lazy loading | Write-through |
|---|---|---|
| Cache filled | On a miss, when read | On every write |
| Stale data | Possible until the TTL ends | Rare |
| Wasted memory | None: only read data | Data nobody reads |
| First read | Slow: miss, then fill | Fast: already cached |
| Best for | Read-heavy, a little age is fine | Fresh data after a write |
1 / 2
Cache filled
- Lazy loading
- On a miss, when read
- Write-through
- On every write
Stale data
- Lazy loading
- Possible until the TTL ends
- Write-through
- Rare
Wasted memory
- Lazy loading
- None: only read data
- Write-through
- Data nobody reads
| Compare | Lazy loading | Write-through |
|---|---|---|
| Cache filled | On a miss, when read | On every write |
| Stale data | Possible until the TTL ends | Rare |
| Wasted memory | None: only read data | Data nobody reads |
2 / 2
First read
- Lazy loading
- Slow: miss, then fill
- Write-through
- Fast: already cached
Best for
- Lazy loading
- Read-heavy, a little age is fine
- Write-through
- Fresh data after a write
| Compare | Lazy loading | Write-through |
|---|---|---|
| First read | Slow: miss, then fill | Fast: already cached |
| Best for | Read-heavy, a little age is fine | Fresh data after a write |
ဘာလဲ
A cache stores the result of work so the next request is fast and cheap. It cuts latency, load on the database and cost. You can cache at every layer between user and data: the browser, Amazon CloudFront at the edge, Amazon API Gateway, Amazon ElastiCache in your VPC, DynamoDB Accelerator (DAX) in front of DynamoDB, and the database’s own buffer pool.
ဘာလဲ
Two ways fill a cache. Lazy loading (cache-aside): the app checks the cache, and on a miss it reads the database and writes the result to the cache. Only requested data is cached, and a cache failure is survivable, but a miss costs three trips and data can be stale. Write-through: every write goes to the cache and the database. The cache is fresh, but it holds data nobody reads, and writes are slower. Many designs combine both with a TTL.
ဘာလဲ
A time to live (TTL) is how long an item may stay. A short TTL means fresher data and more misses. Cache only what can be a little old. To remove data early, invalidate it: CloudFront and API Gateway both allow this. ElastiCache for Redis supports replication and Multi-AZ failover. Memcached is simpler and has no replication.
မှတ်ထားရန်
- Cache where data is read most: edge, API, application, database.
- Lazy loading fills the cache on a miss. Write-through updates it on every write.
- TTL limits how stale data can get. Invalidate to remove data early.
- DAX caches DynamoDB reads in microseconds and is API compatible with DynamoDB.
မှတ်ထားရန်
- A cold cache sends all traffic to the database. Warm it, and add jitter to TTLs so items do not expire together.
- Do not cache personal or fast-changing data.
စာမေးပွဲမှာ
- “Repeated reads of a rarely changing table slow the database” points to ElastiCache in front of it, or read replicas.
- “DynamoDB reads need microsecond latency with few code changes” points to DAX.
- “Static content for global users” points to CloudFront.
- “Cache API responses for five minutes” points to API Gateway caching.
ဒါတွေနဲ့ မရောပါနဲ့
Amazon ElastiCacheIn-memory cache. Choose Valkey or Redis OSS for rich features, Memcached for a simple multithreaded cache.
Amazon CloudFrontA CDN with cache rules, private S3 origins, origin failover, signed access and code at the edge.
Amazon API GatewayPick the API type and endpoint type, then add authorizers, throttling, caching and a private path to the backend.
ဒီ task များတွင်လည်း ပါသည်
ဒီ task ထဲမှာ · 2.1
- Microservices and stateless design
- Multi-tier architectures
- Event-driven and loose coupling patterns
- Serverless application patterns
- AWS Amplify and AWS Device Farm
- Horizontal vs vertical scaling
- Caching strategies
Load Balancing
API Gateway
- When and how to containerize
SQS
SNS
EventBridge
Step Functions
MQ
Secrets Manager
- Choosing purpose-built services
- Choosing object, file or block
Lambda
- Read replicas
ElastiCache
CloudFront
Global Accelerator
Transfer Family
S3
EFS
EBS
Fargate
ECS
EKS