TweakCode
Building Blocks lessons

Course 07 · Orientation

Building Blocks

Cache, database, queue, partition

The components behind almost every design: a cache for hot reads, a database with the right key, a queue for work the user should not wait for, and partitioning when one machine is truly the limit.

Start with Caching

The course journey

Build one family of skills at a time

Each technique is three short lessons, and each one builds on the lesson before it. A lesson walks through one problem step by step, then hands it to you along with a few more to solve on your own.

  1. 01Start here

    Caching

    Cache-aside on the hot key, with a plan for staleness and stampedes.

    Preview
    1. Stage 1

      Cache-Aside with LRU Eviction

    2. Stage 2

      TTL & Write Invalidation

    3. Stage 3

      Stampede Protection (Request Coalescing)

  2. 02Pro

    Databases

    A key, a replica, and a shard only when a number says so.

    1. Stage 1

      Primary-Key Access Patterns

    2. Stage 2

      Read Replicas & Read-Your-Writes

    3. Stage 3

      Sharding by Access Key

    Preview
  3. 03Pro

    Queues

    Work the user should not wait for, delivered at least once.

    1. Stage 1

      Async Work Off the Request Path

    2. Stage 2

      At-Least-Once Delivery & Idempotent Consumers

    3. Stage 3

      Backpressure & Queue Depth

    Preview
  4. 04Pro

    Partitioning

    Consistent hashing, the right key, and the hot key hashing cannot fix.

    1. Stage 1

      Consistent Hashing

    2. Stage 2

      Partition Key Selection

    3. Stage 3

      Hot-Key Mitigation

    Preview