Ravindra BagaleCourses & study guides मराठी Track your progress

AWS Cloud

DynamoDB DAX Caching and Read Acceleration

DAX is a sports car — useless if the road (keys) is wrong. Mexico City gaming lead Carlos Rivera and Kochi media engineer Priya Nair said: We added DAX before fixing a hot PK — cache stampeded on miss. Cache hot Gets after Query shapes are right. Capacity: capacity. Modeling: modeling.

In this chapter

  • Explain DAX simply
  • Know consistency trade-offs
  • Decide DAX vs cheaper caches
  • Industry map
  • Lab mindset + cleanup

1. Everyday example: counter display

A shop counter shows stock from a whiteboard (cache). Board can lag; cashier still checks the notebook (DynamoDB) for money. Meera caches public doctor profiles; never caches prescription ledgers.

2. Vertical steps

Why -> What -> How -> Lab -> CleanupWhyWhatHowLabCleanup
Cleanup

3. Purpose

Hot GetItem paths can dominate RCU and latency. After keys are correct, a cache can absorb repeated reads. DAX is DynamoDB-aware cache — but node hours cost even idle.

4. Overview

DAX: managed in-memory cluster in front of DynamoDB. Item and query caches; consistency nuances vs direct DynamoDB strong reads. Alternatives: API Gateway/CloudFront, ElastiCache, or app caches.

5. Steps

  1. Prove the hot path is Get/Query — not Scan.
  2. Fix keys/hot partitions first.
  3. Estimate QPS and item size for cluster sizing talk.
  4. Decide: DAX vs CDN/API cache vs ElastiCache.
  5. Plan miss path and invalidation/TTL mental model.
  6. Never put money-critical strong-read ledgers on stale cache alone.

6. Commands with output and meaning

# DAX is managed separately from the table API.
aws dax describe-clusters --region ap-south-1
# Output: Clusters list (empty if none). Meaning: optional infra —
# create only after a written hot-Get justification; delete lab clusters same day.

describe-clusters shows spend. Create only with justification; lab clusters deleted same day.

7. Industry stories

  • Gaming (Carlos): avatar/profile Gets via DAX; wallet direct.
  • Media (Priya): public metadata CDN; personalized via DynamoDB.
  • Retail (Aisha): product card cache; checkout strong path.
  • SaaS (Omar): feature-flag Gets cached; billing direct.
  • IoT (Mei): prefer rollups/S3 over DAX for time-series.
  • Bank (Lucas): no DAX on ledger — strong correctness.

8. Lab

  1. Write: three reads OK to cache; two must be strong.
  2. Optional: describe-clusters; if you create a tiny lab cluster, delete same day.
  3. Re-measure without cache after key fix — often enough.

Cleanup (stop billing)

  1. Delete lab resources you created.
  2. Confirm with describe that names are gone.

9. Ops checklist before you ship

  1. Confirm TTL attribute name and units (epoch seconds).
  2. Decide soft-delete vs hard-delete vs archive-to-S3.
  3. Enable PITR on any table you cannot rebuild from source.
  4. Document RPO/RTO and who runs restore drills.
  5. If multi-region: pick write stickiness and conflict rules.
  6. If DAX: prove cache-miss path and warm-up plan.
  7. Tag Owner + Expiry on every lab resource.
  8. Budget alert in the account before load tests.

10. Copy-paste DynamoDB CLI starters (batch 2)

export AWS_DEFAULT_REGION=ap-south-1

# TTL status
aws dynamodb describe-time-to-live --table-name ShopApp

# PITR / continuous backups
aws dynamodb describe-continuous-backups --table-name ShopApp

# On-demand backup
aws dynamodb create-backup --table-name ShopApp --backup-name lab-shop-$(date +%Y%m%d)

# List backups
aws dynamodb list-backups --table-name ShopApp

# Global table description (v2)
aws dynamodb describe-table --table-name ShopApp --query 'Table.Replicas'

11. More industry stories

  • Retail (Aisha Khan, Dubai): TTL clears abandoned carts; soft-delete keeps 30-day undo.
  • Bank (Lucas Meyer, Berlin): PITR on ledger table; restore drill every quarter.
  • Travel (Omar Haddad, Amman): Global Tables for catalog reads; inventory writes sticky.
  • Gaming (Carlos Rivera, Mexico City): DAX for hot profile Gets; never cache money ledgers.
  • Social (Priya Nair, Kochi): adjacency edges for follows; sparse GSI for unread inbox.
  • IoT (Mei Lin, Shenzhen): device#day PK + TTL 14 days; rollups to S3.

12. Glossary (batch 2)

TermMeaning
TTLTime to Live — attribute with epoch seconds; DynamoDB deletes later
Soft deleteFlag deleted=true; item remains until TTL/archive
PITRPoint-in-time recovery — continuous backups window
Global TableMulti-region replicated DynamoDB table
LWWLast-writer-wins conflict resolution on replicas
DAXDynamoDB Accelerator — in-memory cache cluster
Adjacency listEdge items modeling relationships in one table
Fan-outWrite once; push copies to many feeds/inboxes

13. Practice: explain out loud

  1. 60s: TTL vs soft-delete vs S3 archive.
  2. 60s: PITR vs on-demand backup.
  3. 60s: when Global Tables help and hurt.
  4. 60s: DAX consistency trade-off.
  5. 60s: CartLite checkout keys in one breath.
  6. 60s: follow edge vs feed item.
  7. Record once; cut filler; record again.

14. Safe lab hygiene

  • Use ap-south-1 labs with a budget alert.
  • Prefix lab tables with lab- and your initials.
  • Delete replicas, DAX clusters, and backups you created for labs.
  • Never enable Global Tables on production without a write plan.
  • Tag every resource Owner + Expiry.
  • Export/import labs can create large S3 bills — delete prefixes.

16. Delete / archive decision pad

NeedPreferWhy
Undo 7-30 daysSoft-delete flagUser restore
Hard expiry, no readTTL attributeAuto delete later
Compliance keep coldExport/archive to S3Cheap long store
Mistake recoveryPITR / backupTable-level restore

17. Ten oral drill questions

  1. What units does DynamoDB TTL use?
  2. Does TTL delete instantly?
  3. PITR window typical length?
  4. Global Tables conflict default?
  5. When sticky writes matter?
  6. DAX vs API Gateway cache?
  7. Cart PK for a shopper?
  8. Order lines under which PK?
  9. Follow edge SK example?
  10. Unread inbox sparse GSI idea?

18. RPO / RTO mini workshop

  1. Write the worst data loss you can accept (RPO) in minutes.
  2. Write how long restore may take (RTO) before business pain.
  3. Map: on-demand backup vs PITR vs multi-region replica.
  4. Schedule a restore drill on a lab table this month.
  5. Name the person who runs the drill.

19. Cost watch list (batch 2)

  • PITR storage and on-demand backup storage.
  • Global Tables: replicated WCUs in every region.
  • DAX node hours even at idle.
  • Export to S3 + S3 storage + Athena later.
  • Streams + Lambda still bill during TTL deletes.

20. Project Definition of Done

  1. Access patterns written and peer-reviewed.
  2. Sample items drawn for happy path + one failure.
  3. Lab table created, exercised, deleted (or tagged Expiry).
  4. At least one conditional write or transaction exercised.
  5. Cleanup commands pasted in your notes.
  6. One interview answer recorded out loud.
  • TTL hygiene → Backup/PITR for “oops” recovery.
  • Global Tables → sticky writes from capacity/hot lessons.
  • DAX → only after Query shapes are correct.
  • P1 CartLite reuses modeling + transactions.
  • P2 Social reuses adjacency + Streams ideas.

22. Quick self-check (yes/no)

  1. I can explain TTL delay vs instant DeleteItem.
  2. I know when soft-delete beats hard delete.
  3. I can start PITR and say what restore costs in time.
  4. I can name one reason NOT to use Global Tables.
  5. I know DAX does not fix a bad partition key.
  6. I can sketch CartLite USER# and ORD# keys.
  7. I can sketch a follow edge item.
  8. I delete lab replicas/DAX/backups the same day.

23. Common errors and fixes

Each row is a real mistake students and juniors hit. Read the fix before you panic.

Error / symptomFix
DAX before key fixFix keys first.
Cache money ledgerStrong path.
Forget idle node costDelete labs.
Assume strong like GetItemKnow DAX consistency.
Cache ScansDo not — fix model.
No miss planDocument miss.
Stampede on expirySoft TTL / lock.
One huge node foreverRight-size / HA.
Ignore VPC/SGNetwork path.

24. Troubleshooting checklist

  1. Empty clusters: none created — OK.
  2. High latency still: check keys/hot.
  3. Stale reads: expected cache lag — design.
  4. Bill surprise: node hours.
  5. App errors: endpoint/SG/IAM.

25. FAQ

Q. Should I always use a single table?

Often yes for related access patterns; not a religion. Separate tables are fine for unrelated domains or different capacity/security needs.

Q. Do I still need RDS?

Yes for heavy joins, multi-row SQL reports, and strong relational constraints. See the intro DynamoDB vs RDS chapter.

Q. Is Scan evil?

Scan is a tool for rare admin jobs and small tables. Design so hot paths use Query/GetItem.

Q. Where are Put/Get command details?

In the CRUD survey, CLI and SDK chapters — this deep set links them instead of copying.

Q. DAX mandatory?

No — often CDN/app cache enough.

Q. Fixes hot PK?

No.

Q. Strong read?

Prefer direct DynamoDB when required.

Q. Link capacity?

Yes for cost.

26. Interview Q&A

Q. (B) DAX?

DynamoDB Accelerator in-memory cache cluster.

Q. (B) First step?

Fix access patterns/keys.

Q. (M) When not DAX?

Strong money paths; tiny traffic; Scan-heavy.

Q. (M) Idle cost?

Nodes bill even with low QPS.

Q. (S/MNC) Stampede?

Many misses after expiry hit DB together.

Q. (MNC) Alternative?

CloudFront/API cache/ElastiCache/app.

27. Tips in English, Marathi and Hindi

Ravindra Bagale's Tip (EN)

Make the Query cheap first; then decide if a cache earns its rent.

Ravindra Bagale's Tip (MR)

आधी Query स्वस्त; मग cache.

Tip (HI)

पहले Query सस्ता, फिर cache।

Try at home

  1. List 3 cacheable vs 2 non-cacheable reads.
  2. Price a small DAX node roughly (docs).
  3. Re-read modeling one page.

In short

  1. DAX after correct keys.
  2. Consistency and idle cost matter.
  3. Alternatives often enough.
  4. Delete lab clusters.

Revision, interview and comparison cards

Revise this lesson in a few minutes. Save the cards on your phone or download them as PNG files. The QR code on each card opens this lesson.

Revision card: DAX after keys. Cache on a hot PK stampsedes on miss. Fix Query shapes first; then consider DAX for hot Gets. Prove Get/Query → estimate QPS → pick tool → plan miss. Carlos Rivera caches avatars; wallet stays direct.
Revision card: DAX after keys · Download PNG · Open card page
Revision card: Cache rent. Idle nodes still bill; alternatives may be enough. DAX vs CDN/API/ElastiCache — pick for the read shape. Justify cluster → tag Owner/Expiry → delete labs same day. Priya Nair prefers CDN for public metadata.
Revision card: Cache rent · Download PNG · Open card page
Comparison: DAX vs Direct DynamoDB. DAX: Microsecond item/query cache idle node cost. Direct DynamoDB: Strong path and source of truth.
Comparison: DAX vs Direct DynamoDB · Download PNG · Open card page
Comparison: DAX vs CDN or API cache. DAX: DynamoDB-aware cache in the VPC. CDN or API cache: Public or edge HTTP cache.
Comparison: DAX vs CDN or API cache · Download PNG · Open card page
Interview card: Prove Get/Query. Caching a Scan is wasted money. Confirm hot path is GetItem/Query before DAX. Trace top endpoints → reject Scans → then cache talk.
Interview card: Prove Get/Query · Download PNG · Open card page
Interview card: Miss path. Unknown miss behaviour causes stampedes. Document TTL, stampede control, and DB fallback. Write miss doc → load test → tune.
Interview card: Miss path · Download PNG · Open card page
Interview card: Pick a cache. DAX is not the only cache. Public → CDN; personalized hot Get → DAX/ElastiCache/app. Classify reads → pick tool → cost check.
Interview card: Pick a cache · Download PNG · Open card page
Interview card: Delete lab DAX. Forgotten clusters burn money overnight. describe-clusters; delete labs; tag Expiry. Create only with ticket → same-day delete → verify empty.
Interview card: Delete lab DAX · Download PNG · Open card page

More cards: Ravi Sir's Cards.

Practice Tasks

Practice checks run in your browser. They check the answer for this exercise; they do not create resources or connect to your AWS account.

About this scenario

Amravati Agro Market is a agriculture business in Amravati. Anjali Thakre looks after its IT and cloud work. They count money in INR and run their AWS resources in the ap-south-1 Region. In the tasks below you do real jobs for them using what this lesson teaches. All names, account IDs, IP addresses and numbers are made up for practice.

0 / 16

Easy Choose a cache built for DynamoDB

Repeated reads against DynamoDB meet the cache eligibility rules, and you want an in-memory accelerator that speaks the DynamoDB API. Name the AWS service.

  1. Read the situation and identify what you need to decide.
  2. Work through the relevant concept or calculation.
  3. Enter only the requested term or number.
  4. Check your answer, then read the explanation.

Easy Choose the change before adding a cache

An app currently scans the whole table to show a single order. Which DynamoDB operation should it use if it already knows the complete order key?

  1. Read the situation and identify what you need to decide.
  2. Work through the relevant concept or calculation.
  3. Enter only the requested term or number.
  4. Check your answer, then read the explanation.

Easy Check an idle cache bill

A DAX cluster stays allocated overnight with zero requests. Which resource count still matters for hourly provisioned DAX charges?

  1. Read the situation and identify what you need to decide.
  2. Work through the relevant concept or calculation.
  3. Enter only the requested term or number.
  4. Check your answer, then read the explanation.

Easy Read the latest wallet write

A ledger screen needs the latest committed wallet balance from the base table. What kind of DynamoDB read should it request?

  1. Read the situation and identify what you need to decide.
  2. Work through the relevant concept or calculation.
  3. Enter only the requested term or number.
  4. Check your answer, then read the explanation.

Easy Describe table (baseline)

CLI.

Describe table ShopApp

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Easy Cacheable YAML

List.

YAML list cacheable with profile and flags.

  1. Start from the top-level keys the task names.
  2. Indent child keys with 2 spaces (no tabs).
  3. Fill in each property with the value from the task.
  4. Click Check answer. Key order does not matter.

Easy Calculate a read rate before sizing a cache

In one minute, your profile endpoint serves 3,000 reads at a steady pace. What is the average number of reads per second?

  1. Read the situation and identify what you need to decide.
  2. Work through the relevant concept or calculation.
  3. Enter only the requested term or number.
  4. Check your answer, then read the explanation.

Medium Name synchronized cache misses

A popular cached item expires. Hundreds of callers miss at once and all hit DynamoDB. What is this failure pattern called?

  1. Read the situation and identify what you need to decide.
  2. Work through the relevant concept or calculation.
  3. Enter only the requested term or number.
  4. Check your answer, then read the explanation.

Medium Diagnose concentrated writes that a cache cannot absorb

Nearly all writes target the same logical partition key. What underlying design problem remains even after adding a read cache?

  1. Read the situation and identify what you need to decide.
  2. Work through the relevant concept or calculation.
  3. Enter only the requested term or number.
  4. Check your answer, then read the explanation.

Medium Cache a public object at the edge

A public product image should be cached near browsers and is stored as an S3 object. Which AWS CDN fits that job?

  1. Read the situation and identify what you need to decide.
  2. Work through the relevant concept or calculation.
  3. Enter only the requested term or number.
  4. Check your answer, then read the explanation.

Medium Read a small keyed result set

You need all items for one known account partition key. Which DynamoDB operation should replace a Scan of the entire table?

  1. Read the situation and identify what you need to decide.
  2. Work through the relevant concept or calculation.
  3. Enter only the requested term or number.
  4. Check your answer, then read the explanation.

Medium Do-not-cache YAML

List.

YAML list nocache with ledger and checkout.

  1. Start from the top-level keys the task names.
  2. Indent child keys with 2 spaces (no tabs).
  3. Fill in each property with the value from the task.
  4. Click Check answer. Key order does not matter.

Hard State where a cache miss obtains data

A cache does not contain the requested order. Which AWS service holds the source data in this lesson?

  1. Read the situation and identify what you need to decide.
  2. Work through the relevant concept or calculation.
  3. Enter only the requested term or number.
  4. Check your answer, then read the explanation.

Hard Stop cache charges after the lab

After a DynamoDB read-acceleration lab, you need the test table for next week’s class. The lab’s cache is idle, but AWS Billing still shows node-hours. Which AWS resource should you delete to stop the cache charges while keeping the table available?

  1. Read the situation and identify what you need to decide.
  2. Work through the relevant concept or calculation.
  3. Enter only the requested term or number.
  4. Check your answer, then read the explanation.

Hard Check whether a strong read is cached

DAX receives a strongly consistent GetItem request. Does DAX serve it from its item cache? Enter yes or no.

  1. Read the situation and identify what you need to decide.
  2. Work through the relevant concept or calculation.
  3. Enter only the requested term or number.
  4. Check your answer, then read the explanation.

Hard Decide if the extra service is required

Your base-table read latency already meets the application goal. Is DAX required for DynamoDB GetItem or Query to function? Enter yes or no.

  1. Read the situation and identify what you need to decide.
  2. Work through the relevant concept or calculation.
  3. Enter only the requested term or number.
  4. Check your answer, then read the explanation.