StoicBuilder
Later missionMission 42: Yesterday's priceYou can practise it now. It counts once you reach mission 42, after “Your first week on call”.Back to HQ
Exit lesson
Caching and invalidationProLesson 37 of 45, about 8 min
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
0 XP

The app: Beacon, logs, metrics and traces

Beaconharbor-apiGET /api/plans
No cache
p95 latencyno data95 in 100 requests are faster
Cache hit rateno dataanswered from Redis
Postgres queriesno datain the last minute
p95 latency, GET /api/plans, every 10 snow 842 ms

Redis, Postgres and the code

Redis the cachenot in use

Not in use yet. Every request goes to Postgres.

Postgres the source of truth
plans where id = 'team', price per seat a month
USD 12 EUR 11 GBP 10
api/plans.js the code that runs
1// GET /api/plans?currency=EUR2export async function getPlans(currency) {3 return db.loadPlans(currency); // about 840 ms, every time4}

The MagisterThis is Beacon, Harbor’s metrics, open on GET /api/plans, the call behind the pricing page. Each request runs a slow Postgres query: plans, features and prices per currency. Run a minute of traffic. p95 is the time 95 of every 100 requests come in under.

Step 1 of 8Run a minute of traffic
  • Run a minute of traffic
  • Tap how many Postgres queries that took

You’re not signed in, so this lesson won’t be saved to your path. Sign in free to keep your XP.