How to lose money with DynamoDb 💸

Jon Packer • RevolverConf 2024.1

(CONTEXT)

Hobby Project

Beer festival list app

Unique checkins

Avoid these beers at all costs

x-ratelimit-limit: 100

x-ratelimit-remaining: 0

✨ Untickd ✅

  • AWS Lambda + API Gateway
  • AWS Scheduled events
  • Data stored in DynamoDb
GET /ticks/:userId
 -> [{ "checkinId": 62137
       "beerId": 23298,
       "timestamp": "2022-11-23T18:43:22Z",
       "rating": 4.25 }, ...and 8959 more]

GET /tick/:userId/:beerId
 -> ❌: 404
 -> ✅: { "checkinId": 62137
          "beerId": 23298,
          ... etc }

The Plan

  • Store checkin histories in my database
  • Scheduled update from Untappd once an hour
  • Scale: 2000-3000 users, ~500-10000 checkins each
[foreshadowing]

Title Text

{
  "id": 1,
  "name": "A thing stored in DynamoDb",
  "attributes": {
    "contrived": true,
    "array": [1, 2, 3]
  }
}

Store documents in this database!

** not a document database

**

Schema:

Users table
{
  "userId": 12345, // primary key
  "checkins": {
    "<beer id>": {
      "checkinId": 12345,
      "timestamp": "2022-12-12T19:23:46Z",
      "rating": 3.75
    },
    ... and 8959 more
  }
}

Hmm, that's odd

Rewrite!

Checkins table
{
  "checkinId": 12345, // primary key
  "userId": 23456,
  "beerId": 34567,
  "timestamp": "2022-12-12T19:23:46Z",
  "rating": 3.75
}

To the moon 📈

Dramatic Reconstruction

❌ ProvisionedThroughputExceededException

📜 Secondary Indexes

How to lose money with hobby projects 💸

deck

By jonpacker

deck

  • 120