DEV Community

Avery Lin
Avery Lin

Posted on

Overlap Before DNS

The kettle clicked off at twenty to midnight. A solo founder had a landing page and a dream. The checkout handler had never met a second caller.

Stripe sat in test mode beside a README. The DNS record still pointed at a parked domain. Nothing in the stack had overlapped with itself.

That gap is not a branding problem. It is a physics problem on a quiet night. One happy curl does not stand in for twenty.

Public feeds this week filled with louder AI demos. Voice loops and browser agents ate the scroll. A one-person shop still sells through HTTP.

Chasing the demo calendar does not move cash. Overlap still arrives on the first real morning. The invoice should stay blank until then.

Think of a club soundcheck before doors open. One microphone can hide a frayed cable. Twenty open channels reveal the ground hum.

An indie rehearsal can steal that idea. It does not need a rented load farm. It needs a boring harness and a free box.

The proposed method stays small on purpose. The product tree stays frozen during the run. Only the harness files may change at all.

A founder copies the live shape of checkout. The path, headers, and JSON body stay identical. Think-time jitter sits between the worker calls.

Twenty workers start together and then drift. Each records status, latency, and error class. The run fails on any 5xx or hang.

This article does not report executed numbers. The script below is a labeled proposal. Treat it as a starting artifact, not a benchmark.

#!/usr/bin/env python3
"""Proposed overlap harness. Unexecuted here. Not a benchmark."""
from __future__ import annotations

import argparse
import json
import random
import time
import uuid
from concurrent.futures import ThreadPoolExecutor, as_completed
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen

WARMUP_MARK = "warmup"


def one_call(url: str, body: bytes, key: str, timeout: float) -> dict:
    started = time.perf_counter()
    req = Request(
        url,
        data=body,
        method="POST",
        headers={
            "Content-Type": "application/json",
            "Idempotency-Key": key,
            "Accept": "application/json",
        },
    )
    try:
        with urlopen(req, timeout=timeout) as resp:
            status = resp.status
            payload = resp.read(2048)
    except HTTPError as exc:
        status = exc.code
        payload = exc.read(2048) if exc.fp else b""
    except URLError as exc:
        return {
            "ok": False,
            "class": "network",
            "status": 0,
            "ms": round((time.perf_counter() - started) * 1000, 1),
            "key": key,
            "err": str(exc.reason),
        }
    except TimeoutError:
        return {
            "ok": False,
            "class": "timeout",
            "status": 0,
            "ms": round((time.perf_counter() - started) * 1000, 1),
            "key": key,
            "err": "timeout",
        }
    ms = round((time.perf_counter() - started) * 1000, 1)
    klass = "pass"
    ok = 200 <= status < 300 or status == 409
    if status >= 500:
        klass = "5xx"
        ok = False
    elif status == 409:
        klass = "idempotent-replay"
    elif status == 429:
        klass = "limited"
        ok = False
    elif not ok:
        klass = f"http-{status}"
    return {
        "ok": ok,
        "class": klass,
        "status": status,
        "ms": ms,
        "key": key,
        "bytes": len(payload),
    }


def main() -> int:
    parser = argparse.ArgumentParser(description="Proposed checkout overlap rehearsal")
    parser.add_argument("--url", required=True)
    parser.add_argument("--workers", type=int, default=20)
    parser.add_argument("--warmup", type=int, default=5)
    parser.add_argument("--timeout", type=float, default=8.0)
    parser.add_argument("--jitter", type=float, default=0.35)
    parser.add_argument("--sku", default="starter-pack")
    args = parser.parse_args()

    body = json.dumps({"sku": args.sku, "qty": 1, "source": "rehearsal"}).encode()
    run_id = uuid.uuid4().hex[:8]
    jobs = []
    for i in range(args.warmup):
        jobs.append((f"{WARMUP_MARK}-{run_id}-{i}", True))
    for i in range(args.workers):
        jobs.append((f"rehearsal-{run_id}-{i}", False))
    # One deliberate replay of the first live key.
    if args.workers:
        jobs.append((f"rehearsal-{run_id}-0", False))

    rows = []
    with ThreadPoolExecutor(max_workers=args.workers) as pool:
        futs = []
        for key, is_warmup in jobs:
            time.sleep(random.random() * args.jitter)
            futs.append(pool.submit(one_call, args.url, body, key, args.timeout))
            futs[-1].warmup = is_warmup  # type: ignore[attr-defined]
        for fut in as_completed(futs):
            row = fut.result()
            row["warmup"] = bool(getattr(fut, "warmup", False))
            rows.append(row)

    live = [r for r in rows if not r["warmup"]]
    fails = [r for r in live if not r["ok"]]
    lat = sorted(r["ms"] for r in live) or [0.0]
    report = {
        "run_id": run_id,
        "url": args.url,
        "workers": args.workers,
        "live_calls": len(live),
        "fails": len(fails),
        "p50_ms": lat[len(lat) // 2],
        "p95_ms": lat[min(len(lat) - 1, int(len(lat) * 0.95))],
        "classes": {},
        "fail_samples": fails[:8],
    }
    for r in live:
        report["classes"][r["class"]] = report["classes"].get(r["class"], 0) + 1
    print(json.dumps(report, indent=2))
    return 1 if fails else 0


if __name__ == "__main__":
    raise SystemExit(main())
Enter fullscreen mode Exit fullscreen mode

The harness speaks HTTP and nothing else. It never imports application code from the shop. That fence keeps drafts away from money paths.

A tiny stub helps prove the harness before the real route. The stub is a stand-in, not a product. Production rehearsal still needs the real checkout shape.

#!/usr/bin/env python3
"""Proposed local stub. Unexecuted here. Not the product."""
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
import json

SEEN = set()

class Handler(BaseHTTPRequestHandler):
    def do_POST(self):
        if self.path != "/checkout":
            self.send_error(404)
            return
        length = int(self.headers.get("Content-Length", "0"))
        _ = self.rfile.read(length)
        key = self.headers.get("Idempotency-Key", "")
        if key in SEEN:
            body = {"ok": False, "reason": "replay"}
            raw = json.dumps(body).encode()
            self.send_response(409)
        else:
            SEEN.add(key)
            body = {"ok": True, "order_id": f"ord-{len(SEEN):04d}"}
            raw = json.dumps(body).encode()
            self.send_response(200)
        self.send_header("Content-Type", "application/json")
        self.send_header("Content-Length", str(len(raw)))
        self.end_headers()
        self.wfile.write(raw)

    def log_message(self, fmt, *args):
        return

if __name__ == "__main__":
    ThreadingHTTPServer(("127.0.0.1", 8080), Handler).serve_forever()
Enter fullscreen mode Exit fullscreen mode

The commands stay copyable and intentionally dull. A founder runs the stub, then the harness. The same pair later aims at a rehearsal URL.

chmod +x harness.py stub.py
python3 stub.py &
STUB_PID=$!
sleep 0.4
python3 harness.py \
  --url http://127.0.0.1:8080/checkout \
  --workers 20 \
  --warmup 5 \
  --timeout 8 \
  --jitter 0.35 \
  --sku starter-pack
STATUS=$?
kill "$STUB_PID"
exit "$STATUS"
Enter fullscreen mode Exit fullscreen mode

Cold start on a free server will skew the first wave. Discard the warmup batch before reading latency. Keep the error classes even when latency looks fine.

A timeout wrapped in silence is still a fail. An idempotent 409 from a replayed key can pass. A 500 from a unique constraint is a stop-ship.

Twenty overlaps is a soundcheck, not a capacity plan. It will not find a lock that appears at two hundred. It will find the crash that appears at two.

The JSON report is the only trophy that matters. Classes tell a story that averages hide. A pile of limited rows is a lesson, not a green check.

Disclosure: This article was prepared as part of MonkeyCode's product outreach. MonkeyCode offers free model access for harness drafts. The same product line includes a free server option.

A founder can generate the script, then run it there. The model should edit harness files and ignore product code. A short prompt can state that fence in plain words.

Draft only files under ./harness.
Do not open, quote, or patch ./app.
Keep the worker count at 20.
Fail the run on timeout or 5xx.
Treat 409 on a repeated Idempotency-Key as success.
Do not add third-party calls.
Do not print secrets from the environment.
Enter fullscreen mode Exit fullscreen mode

Those are the operator-supplied availability claims used here. This article invents no model names or quotas. It invents no hardware, duration, or permanence.

The free server is a rehearsal hall, not a club night. Upload the two files and point --url at that host. Leave public DNS on the parked record until the report is clean.

# Proposed remote shape. Hostnames and auth stay with the founder.
python3 harness.py \
  --url https://REHEARSAL_HOST/checkout \
  --workers 20 \
  --warmup 5 \
  --timeout 8
Enter fullscreen mode Exit fullscreen mode

A free server is not a quiet production twin. Sleep states and noisy neighbors both exist. Shared CPU will lie about p95 under dusk traffic.

The coding model will happily draft a wrong assertion. It may treat 429 as success if the prompt is vague. The founder still reads every failure class by hand.

This rehearsal is a poor fit for some shops. Regulated teams need a named staging environment with logs. Anyone hitting a third-party quota should not spray twenty workers at it.

Load against Stripe, email, or SMS is out of bounds. Paid multi-region traffic belongs on a paid stage. A marketplace API with strict rate limits is also off limits.

Letting a model own the product loop dulls judgment. Letting it draft a disposable harness keeps the edge. The difference is who holds the stop-ship pen.

The founder still decides what a fail means. The script only reports status, timing, and class. Judgment stays with the person who will refund a user.

Ship after the soundcheck, not after the demo reel. Keep the bill at zero while the path is still fiction. Accept that twenty workers will miss the rare lock.

Founders who need a zero-bill rehearsal have a small path. They can try the free model and free server, then commit the harness. Overlap cannot wait for a paid cluster.

Top comments (0)