CompCode Academy

Lesson 2 of 4 · Free to read

Exercises

Exercises — Performance, SLOs & Data-store Signals

Watch & learn

Course video

Open on YouTube
How Prometheus Monitoring works — Prometheus scrape, TSDB, and alert architecture used in MNCs.

Course video

Open on YouTube
System Design Basics: Horizontal vs Vertical Scaling — Architecture trade-offs before you pick a stack.

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-lab repo
  • 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

  1. Write a k6 script posting orders with think time.
  2. Run a 5-minute baseline; capture p95 and error ratio.
  3. 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

  1. Reuse HTTP duration histogram for latency SLI.
  2. Carry original timestamp across SNS→SQS; observe fulfillment histogram.
  3. 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

  1. Write error-budget-policy.md with 25/50/100 actions for both SLOs.
  2. Expose basic DB metrics (connections, errors) or Redis hit ratio.
  3. 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.

New free lessons and course updates. Unsubscribe from any email.