Lesson 2 of 4 · Free to read
Exercises
Exercises — Performance, SLOs & Data-store Signals
Watch & learn
Course video
Course video
Keep a lab notebook: hypothesis → command → result. Speed without evidence is not a skill.
How to use this file
- Work Lab A → B → C on the same
orders-labrepo - Prefer Docker Desktop; use Kind when the lab says so
- Definition of Done at the bottom is the phase gate
Lab A — k6 baseline
Time: 45–60 min
Goal: Steady load script for /orders.
Setup
k6 installed; api reachable.
Steps
- Write a k6 script posting orders with think time.
- Run a 5-minute baseline; capture p95 and error ratio.
- Save results next to dashboards.
Snippet — Minimal k6 snippet
import http from 'k6/http';
import { sleep } from 'k6';
export const options = { vus: 5, duration: '5m' };
export default function () {
http.post('http://localhost:8080/orders', JSON.stringify({ sku: 'SKU-1', qty: 1 }), {
headers: { 'Content-Type': 'application/json' },
});
sleep(1);
}
Success criteria
- Baseline numbers recorded
If stuck
Ramp VUs slowly — cold-start noise confuses SLOs.
Lab B — Journey SLIs + recording rules
Time: 60–90 min
Goal: Latency + freshness SLIs queryable.
Setup
Histograms for HTTP and fulfillment.
Steps
- Reuse HTTP duration histogram for latency SLI.
- Carry original timestamp across SNS→SQS; observe fulfillment histogram.
- Add Prometheus recording rules for fast_ratio series.
Success criteria
- Both series queryable under k6 load
If stuck
Freshness NaN usually means histogram not scraped yet — generate traffic first.
Lab C — Error-budget policy + datastores
Time: 45–60 min
Goal: Written policy + Postgres/Redis signals.
Setup
Optional Postgres/Redis sidecars for metadata/idempotency.
Steps
- Write
error-budget-policy.mdwith 25/50/100 actions for both SLOs. - Expose basic DB metrics (connections, errors) or Redis hit ratio.
- Explain how a pool exhaustion would burn the freshness SLO.
Success criteria
- Policy committed
- At least one datastore panel on dashboard
If stuck
If you skip real DB, simulate with a documented failure mode and metric stub — be honest.
Stretch goals
- Multi-window multi-burn-rate alerts on both new SLIs
Definition of Done
- Two journey SLOs defined
- Recording rules work under k6
- Error-budget policy exists
Exercises — Performance, SLOs & Data-store Signals.