cloudpatterns.appClassroomKatasWhiteboardBlog
Data LineLesson

Access patterns & denormalization

Ledger's chat moved to a key-based store. List the questions first, key the data so each one is a single read, and copy what every read needs — then pay for each copy on every change. When is the copy worth it?

13 minMediumStation: Access patterns & denormalization

Members lesson

Membership isn’t open yet. The free lessons are open — 16 of them.

  1. Chat pages openedUsers
  2. Messages sentUsers
  3. Author names fetchedUsers
  4. Ledger chat APIWeb API
  5. Ledger names APIWeb API
  6. Ledger chat store (pool of 17)Database
From step 1 — Every chat page is five queries: one range read of the latest messages, holding a connection for 15 ms, and about four name lookups of 5 ms each — 300 range reads and 1,200 lookups a second, plus 30 messages sent at 15 ms.

What you'll be able to do

  1. 1Choose a partition key and sort key that turn each listed access pattern into a single lookup or range read.
  2. 2Predict how many writes and how much extra storage a denormalized design costs when one shared fact changes.
  3. 3Choose whether to embed related data, copy part of it, or keep a reference, from how often it is read, how often it changes and whether it grows without bound.

Inside the lesson

steps
12
questions
11
simulations
4

You guess first, then run the system and see if you were right.

Step 1 · The setup

Ledger's group chat now lives in its own key-based store. The team kept the expenses habit: each message holds its author's member id, and the display names live once, in a members table.

The store has no joins. So a chat page reads the group's latest messages in one range read, then fetches each author's name — about 4 lookups a page. Watch 300 chat pages a second, with 30 messages sent alongside.

Steps 2–12 are for members