PNL Learn

Caching, Queues and Background Jobs

Keep services fast and reliable with caches, queues and retries.

Two things separate a service that survives real traffic from one that falls over: it does not do the same expensive work twice, and it does not lose work when something fails. You will build a cache-aside read path with TTLs and invalidation, an LRU cache with expiry, and a rebuild lock that stops a stampede; set HTTP caching headers that a browser and a CDN actually obey; move slow work into a job queue with at-least-once delivery, idempotency keys, exponential backoff and a dead letter queue; schedule recurring work with the outbox pattern and honest answers about exactly-once; choose between threads, processes and an event loop and write async code that runs calls concurrently with deadlines and bounds; protect a service with timeout budgets, circuit breakers, fallbacks and load shedding; and receive webhooks safely with HMAC signatures and replay protection. The course ends with an order pipeline that caches its catalog, enqueues its email and inventory work, retries what fails, parks what cannot be saved, and keeps checkout fast through a mail provider outage.

AdvancedPython9 lessons101 exercisesAbout 7.5 h
Create a free account

What you will learn

  • Cache-aside
  • TTLs and invalidation
  • LRU caches
  • HTTP caching
  • Job queues
  • Idempotency
  • Retries and backoff
  • Dead letter queues
  • The outbox pattern
  • Concurrency models
  • Async I/O
  • Circuit breakers
  • Webhook signatures

Lessons

  1. 1

    Caching

    Cache-aside reads, TTLs on a clock you control, invalidating on write, keys that name every input, surviving a stampede, and an LRU with TTL you build yourself.

    11 exercises

  2. 2

    HTTP and Application Caching

    Cache-Control that browsers and CDNs actually obey, validators and 304s, Vary and per user safety, stale-while-revalidate, and what must never be cached.

    12 exercises

  3. 3

    Queues and Background Jobs

    Move slow work off the request, deliver it at least once, make the handlers idempotent, retry with backoff and jitter, and park what can never succeed.

    12 exercises

  4. 4

    Scheduling and Reliability

    Cron schedules that skip rather than pile up, the outbox pattern for the dual write problem, what exactly-once really means, being a good client of somebody else's rate limit, and the numbers that tell you a queue is stuck.

    12 exercises

  5. 5

    Concurrency Models: Threads, Processes and the Event Loop

    Tell IO-bound from CPU-bound work, see what the GIL does and does not serialize, choose threads, processes or an event loop for a job, and learn why one blocking call stalls every request on an async server.

    12 exercises

  6. 6

    Async I/O in Practice

    Write coroutines that await a client, run them concurrently and collect results in order, give every call a deadline, bound how many run at once, keep blocking work off the loop, and shut workers down gracefully.

    11 exercises

  7. 7

    Resilience Between Services

    Give a request one timeout budget across its whole call chain, stop retries multiplying, build a circuit breaker with closed, open and half-open states, degrade to a cached answer, shed load with a bounded queue and a 503, and choose between work queues and pub/sub.

    12 exercises

  8. 8

    Receiving Webhooks Safely

    Verify a webhook's HMAC signature over the raw body, compare it in constant time, reject replays with a signed timestamp and a tolerance, rotate secrets, acknowledge fast, and process each event once even when it arrives twice or out of order.

    11 exercises

  9. 9

    Putting It Together

    Build the order pipeline in six stages: a cached catalog, a checkout that writes its messages in the same transaction, a relay with idempotent handlers, a worker with retries and a dead letter queue, the loop that drives it, and receipts that survive a mail provider outage behind a circuit breaker.

    8 exercises

How you practice

You practice in the browser and every exercise gives you feedback right away. This course uses these formats:

  • Code exercise: 47
  • Fix the bug: 13
  • Predict the output: 11
  • Select all that apply: 7
  • Multiple choice: 7
  • Fill in the blank: 6
  • Match the pairs: 4
  • Type the answer: 3
  • Reorder lines: 3

Aligned to

CS2023ACM / IEEE-CS / AAAISource
  • Parallel and Distributed Computing
    • PDC-ProgramsPrograms
    • PDC-CommunicationCommunication
    • PDC-CoordinationCoordination

Proto Node Labs is not affiliated with or endorsed by ACM / IEEE-CS / AAAI. Exam names are trademarks of their owners.