Config Lab

Track 1 · Test Something Real · Toggle Wars

Know if the timeout change is safe to ship.

Config Lab tests a timeout and retry policy for a service dependency with a Flagsmith experiment, then applies a written ship rule that says ship, do not ship, or inconclusive.

For the backend or on-call engineer who has to choose a client timeout and retry setting and wants evidence instead of a guess.

smoke check, own Flagsmith in Docker, about 2 min
$ SESSIONS=150 SESSIONS_AA=150 SESSIONS_SLOW=150 \
  SUFFIX=-q OWN_STACK=1 ./run.sh

Needs Docker, curl and Python 3.10+. The first start also pulls images, so it takes longer on a slow network. A check of the path, not evidence. The full-size run takes about 21 minutes.

The problem

Timeouts and retries are set by guess. A wrong guess hurts quietly.

Say a dependency has been failing in short bursts. Someone proposes a 300 ms timeout with one retry instead of the current 1000 ms and none. It sounds sensible. A canary looks fine. Whether it helps depends on how the dependency fails, and that is the thing nobody measured.

Putting the change behind a Flagsmith experiment gives you numbers. Flagsmith's experiment banner can still mislead if you read it as a verdict. In these runs it was wrong twice.

The product, as it ran

One verdict in words, next to Flagsmith's numbers.

These are the recorded screens, taken on 29 Nov 2026 from Flagsmith 2.295.2 and the lab dashboard. The traffic behind every screen is simulated. Click an image to open it full size.

Lab dashboard, :8411Simulated
Lab dashboard with five experiment cards. Each card has a one-sentence verdict, a table of per-arm success rate, mean latency and retry calls, and Flagsmith's lift, interval and chance to win. The slow card reads: Do not ship fast_retry, primary is Losing.
The dashboard after a small 120-session check run, so most cards read inconclusive. It said "do not ship yet" for flaky even though Flagsmith called fast_retry winning (chance 0.975), because the 95% interval (-0.2% to +95.5%) includes 0.
Flagsmith experiment: A/B on slowSimulated
Flagsmith experiment page for dependency-policy-ab-ab_slow with 600 users, a green banner reading fast_retry is outperforming Control by -18.8 percent with less than 1 percent probability of being the best variant, and a lift card showing -18.8 percent.
Slow profile, 600 sessions. The banner says consider rolling out fast_retry. The lift card says -18.8%. That wording is Flagsmith's; the lab dashboard says do not ship.
Flagsmith experiment: A/B on flakySimulated
Flagsmith experiment page for the flaky profile showing the experiment summary, rollout configuration and result cards.
Flaky profile, 600 sessions (296 control, 304 fast_retry; shared development Flagsmith). Success 47.3% to 69.1%, interval [+25.3%, +66.8%], chance to be best above 99%. The rollout shows fast_retry at 100% because tools/ship.py shipped the winner.
Flagsmith experiment: A/ASimulated
Flagsmith experiment page for the A/A run, where both arms use the same policy, with a banner suggesting aa_copy as winner.
A/A, 400 sessions. The banner calls a winner between two arms that run the same code. By the ship rule this is no winner.

How it works

A real service, a seeded fault stub, and a rule written before the runs.

A small service calls a flaky dependency. Its timeout and retry policy sits behind a Flagsmith multivariate flag. A load script drives scripted sessions through it. Flagsmith serves the variants, collects the metrics and computes the statistics. The dashboard applies the ship rule.

Config Lab data flow The load script sends five requests per session, with identity session-N, to the service policy. The service reads the dependency_policy flag from Flagsmith, which serves a variant and receives exposure and four events per session. The service applies timeout_ms and retries when calling the dependency stub, which behaves as healthy, slow or flaky. The lab dashboard reads results from the Flagsmith API and applies the ship rule to give a verdict. Load scriptidentity session-N5 requests / session Service policytimeout_ms, retriesone flag read / session Dependency stubhealthy | slow | flakyseeded faults Flagsmith (own Docker)flag dependency_policymultivariate, 50/50 Lab dashboard :8411reads Flagsmith APIapplies the ship rule ship | stop | inconclusive GET x5 policy applied variant out,exposure + 4 events in results Metrics: session_all_ok (primary),session_slow (guardrail),retry_calls (cost), session_mean_ms
  1. Load script. Starts a session with identity session-N and makes 5 requests.
  2. Service policy. Reads the dependency_policy flag once from Flagsmith, which records the exposure.
  3. Dependency stub. The service calls it with the served timeout_ms and retries; the stub misbehaves as healthy, slow or flaky.
  4. Events. The session sends 4 events back to Flagsmith.
  5. Lab dashboard. Reads results from the Flagsmith API, applies the ship rule and prints ship, do not ship or inconclusive.

The flag

One multivariate flag, dependency_policy, split 50/50. The identity is session-<n> and the flag is read once per session.

controltimeout_ms=1000,retries=0
fast_retrytimeout_ms=300,retries=1
patient_retrytimeout_ms=500,retries=2

patient_retry was run on the slow profile only. If Flagsmith is down, the service serves a hard-coded policy and the session joins no experiment.

The ship rule

Enforced by the dashboard. All of these must hold:

  • The primary metric is Winning in Flagsmith (chance to win above 0.95).
  • Its 95% interval does not include 0.
  • Success rises by at least 5 points.
  • At least 100 identities are in the experiment.
  • No guardrail is Losing.
  • If Flagsmith cannot score the guardrail, the variant does not fire it more than control (raw counts).

The 5-point bar and the guardrail test were written before the first runs. The interval check and the 100-identity floor were added on 28 Nov after review.

The fault profiles

Fixed before any run. The stub injects errors and delays from a seeded random generator.

healthy40 ms ± 15 ms, 0% errors
slow20% of calls take 600-900 ms
flaky15% instant 503, 10% take 600-900 ms

Measured on the stub, 400 calls each: flaky gave 17.8% 503 and 9.8% slow calls; healthy p50 48 ms, p95 65 ms.

Flagsmith features the code uses

Flagsmith featureWhat the code doesWhere
Multivariate flagdependency_policy carries the timeout and retry policy as its value.tools/setup_experiment.py
Experimentation (self-hosted)Creates an experiment per run with metrics, starts it, refreshes and reads its results.tools/setup_experiment.py, tools/read_results.py, docker-compose.yml
Experiment metricsFour metrics with direction and expected direction.tools/setup_experiment.py
Python SDK get_experiment_flagReads the variant once per session; this records the exposure.src/service/session.py
Python SDK track_eventSends the conversion events per identity.src/service/session.py, src/loadgen/run.py
IdentitiesOne identity per session.src/loadgen/run.py
Rollout and completion APIShips the winner, ends on control, or only raises the rollout.tools/ship.py
Admin REST APIBootstraps organisation, project and environments; the dashboard reads results.tools/bootstrap.py, src/lab/server.py
Fallback when Flagsmith is downServes the hard-coded policy, sends no events. Tested: 30 of 30 sessions fell back correctly.src/service/session.py

Results

The same policy helped in one case and hurt in another.

Simulated All runs use simulated load on one machine against a seeded stub. The service really waits, times out and retries against a running HTTP dependency, so latency and retry counts are measured. The fault profiles are my own models, not measurements of a real dependency.

controlvariant (colour shows what the ship rule said)
Session success rate, control against variant, five simulated runsControl to variant success rate: flaky fast_retry 44.7 to 72.5 percent, slow fast_retry 100 to 81.2, slow patient_retry 100 to 95.1, healthy fast_retry 100 to 100, A/A on flaky 45.2 to 45.6.40%60%80%100%session success rate (all 5 requests ok, none over 1500 ms)run (simulated load)control to variantrule saysA/B on flakycontrol vs fast_retry44.7% to 72.5%SHIP+27.8 ptsA/B on slowcontrol vs fast_retry100% to 81.2%DO NOT SHIP-18.8 ptsA/B on slowcontrol vs patient_retry100% to 95.1%DO NOT SHIP-4.9 ptsA/B on healthycontrol vs fast_retry100% to 100%INCONCLUSIVEno differenceA/A on flakycontrol vs aa_copy45.2% to 45.6%NO WINNERidentical arms
A/B on flakySHIP
control vs fast_retry: 44.7% to 72.5% (+27.8 pts)
A/B on slowDO NOT SHIP
control vs fast_retry: 100% to 81.2% (-18.8 pts)
A/B on slowDO NOT SHIP
control vs patient_retry: 100% to 95.1% (-4.9 pts)
A/B on healthyINCONCLUSIVE
control vs fast_retry: 100% to 100% (no difference)
A/A on flakyNO WINNER
control vs aa_copy: 45.2% to 45.6% (identical arms)
40%60%80%100%

Session success rate, control (ring) to variant (dot).

Hypotheses and stop rules were written down before each run. Per-run numbers: docs/evidence/runs-summary.md in the project.
RunSessionsResult (simulated)
A/A on flaky1000 + 40 pilotNo winner. Lift +0.003, 95% interval [-0.130, +0.135], chance to win 0.515.
A/B on flaky2000Supported. Success 44.7% to 72.5% (+27.8 points), interval +49% to +75% relative. Mean latency 108 to 79 ms. Cost: 1.26 extra dependency calls per session.
A/B on healthy2000Inconclusive. Both arms 100% success, 0 retries, 43 ms. The zero-width interval comes from zero variance, not from precision.
A/B on slow600Refuted: do not ship. Success 100% to 81.2%, interval [-0.231, -0.144]. Mean latency fell 199 to 113 ms, but a 300 ms timeout aborts calls that would have finished in 600-900 ms.
A/B on slow, patient_retry600As predicted, do not ship. Success 100% to 95.1%. 21.1% of patient_retry sessions were slow (over 1000 ms) vs 0% for control.
Replicated twice on 29 Nov

Full size, all five runs, on a fresh stack each time. Same direction every time: flaky 41.9% to 73.6% and 43.8% to 72.4% (ship), slow 100% to 78.6% and 79.7% (do not ship).

One prediction was wrong

For fast_retry on slow I wrote down that success would not drop. The run refuted that. I predicted the patient_retry result correctly.

The rule is what transfers

The three profiles are models, so the numbers are specific to this lab. The decision rule is the part to reuse. Which profile you are in is the thing to measure first.

The decision, in one paragraph

Use fast_retry (300 ms timeout, 1 retry) only where the dependency fails fast and intermittently. Do not use it where the dependency is merely slow: success fell about 19 points, and the gentler patient_retry still fell 5 points with 21% slow sessions. Expect no gain where the dependency is healthy.

What it does not do

Limits, stated up front.

  • No real users, no pilot.All load is simulated. The result is about this lab's fault model, not about any production service.
  • No demo video, public repository or hosting yet.The screenshots on this page are the only recorded output of the UI. The run takes minutes of Docker time instead of a click.
  • The guardrail could not fire on flaky and healthy.No stub call exceeds about 900 ms, so neither arm can cross the 1000 ms line there. Its silence is no evidence of safety. It does fire for patient_retry on slow.
  • Flagsmith cannot score a metric with 0 control conversions.retry_calls stays "Collecting data" in every run, so two of the four metrics have no Flagsmith inference. Retry cost comes from our own counts.
  • Only session_slow can block a ship.The other two "not increase" metrics are registered in Flagsmith but the ship rule ignores them, to keep the rule that was written before the runs.
  • Power was not calculated.At the flaky baseline and 1000 sessions per arm, about 6.2 points are detectable. A 5-point effect could have been missed. The observed +27.8 is far above that.
  • Only this fault profile and seed.A full outage, or a dependency that slows down under retry load, would behave differently. This lab does not model retries multiplying load.
  • Lab-specific driver.Plain HTTP GET only, five calls per session, and it was not run against any service other than the stub.

Run it

Three commands, from unit tests to a full run.

Run them from the project folder. Needs Docker, curl and Python 3.10+. On macOS the default 3.9 is too old: brew install python@3.11. No .env is needed. Step-by-step guide for a first run.

unit tests, no Docker, no Flagsmith
$ ./run.sh test
smoke check of the whole path, about 2 min
$ SESSIONS=150 SESSIONS_AA=150 SESSIONS_SLOW=150 \
  SUFFIX=-q OWN_STACK=1 ./run.sh
full size, the five runs, about 21 min
$ OWN_STACK=1 ./run.sh

The full run starts its own Flagsmith with Docker, then serves the lab dashboard at http://localhost:8411 (Flagsmith UI: http://localhost:8401). Stub on 8409. Override ports with DEP_PORT, DASH_PORT, FS_PORT.

Measured times

  • Stack up to liveness33 s
  • Unit tests17 s
  • All five phases, full size18 min 50 s
  • Start to teardown, full runabout 21 min
  • Smoke check, three phasesabout 2 min

None measured on a quiet machine. The first start also pulls images and runs migrations, which depends on your network.

Tests

38 unit tests (20 in tests/test_core.py, 18 in tests/test_service.py) that need no running Flagsmith. They cover policy parsing, fault-profile rates, the policy runner against a real in-process stub, session logic with a fake Flagsmith client, and the dashboard's verdict rules. The path through a real Flagsmith is covered by tools/smoke.py and the runs, not by unit tests. There is no CI.

On your own service

Point the load script at a URL with --target; each session's five requests go there with the policy Flagsmith served. Set the policy to use when the flag is missing with CONFIG_LAB_FALLBACK. This has not been run against any service other than the stub.