Part 3 of 4 · 2 min read
Exercises
Easy
Easy 1: Run it (30 minutes)
Run python -m pytest -q and python run_all.py in code/mini-stream.
Done when: you report duplicates with and without Last-Event-ID.
Easy 2: Event types (30 minutes)
Design the event types and payloads for your agent's stream.
Done when: each has an id, a type, and a note on whether it may be dropped.
Easy 3: Find your timeouts (30 minutes)
List every idle timeout between your browser and your agent (gateway, load balancer, CDN).
Done when: you pick a heartbeat interval below the smallest.
Hint
retry and heartbeat should be well under the idle timeout.
Medium
Medium 1: Real SSE endpoint (4 hours)
Serve the event store over a real HTTP SSE endpoint with FastAPI or Express.
Done when: curl -N shows events and a reconnect with Last-Event-ID resumes.
Hint
read Last-Event-ID from the request header on connect.
Medium 2: Browser client (3 hours)
Write a small page using EventSource that de-duplicates by id and shows progress.
Done when: killing the server mid-run and restarting it resumes the display without repeats.
Hint
keep a set of seen ids in the page.
Medium 3: Approval over SSE (3 hours)
Emit an approval_request, close the stream, and resume after a POST approval.
Done when: the run continues after a pause longer than your proxy timeout.
Hard
Hard 1: Gateway test (6 hours)
Put your stream behind a real reverse proxy and CDN and measure buffering and idle timeouts. (I did not run this, so your numbers are the ground truth.)
Done when: you report first-byte time and disconnect time with and without your fixes.
Hint
X-Accel-Buffering: no and Cache-Control: no-transform are common fixes, depending on the proxy.
Hard 2: WebSocket comparison (8 hours)
Implement the same stream over WebSockets and compare deploy behaviour behind a load balancer. (I did not run this.)
Done when: you report what happens to open connections during a rolling deploy for each design.
Hard 3: Slow-client load test (6 hours)
Run 1,000 slow clients against your server. (I did not run this.)
Done when: you show server memory with and without bounded buffers.