Skip to content
Prev Previous commit
Next Next commit
fixed demo and updated docs
  • Loading branch information
sniper35 committed Feb 8, 2026
commit 73b065e7206f8c94176d79881908c92e431bf63a
7 changes: 6 additions & 1 deletion examples/diffusion_router/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ curl -X POST 'http://localhost:30080/add_worker?url=http://localhost:10090'

The router uses a **least-request** strategy: each incoming request is forwarded to the worker with the fewest in-flight requests. This is workload-aware and avoids hot-spotting compared to round-robin. When a request completes, the worker's count is decremented, keeping the load state accurate in real time.

Workers that fail consecutive health checks (default: 3) are quarantined and excluded from the routing pool. A background loop pings each worker's `GET /health` endpoint at a configurable interval (default: 10s).
Workers that fail consecutive health checks (default: 3) are quarantined and excluded from the routing pool and will not be added back to avoid stale weights(See [discussion](https://github.com/radixark/miles/pull/260#discussion_r2654274449)). A background loop pings each worker's `GET /health` endpoint at a configurable interval (default: 10s).

## Benchmark script(under examples/diffusion_router/):
- examples/diffusion_router/bench_routing_algorithms.py — top-level comparison runner
- examples/diffusion_router/bench_router.py — single-algorithm benchmark (spawned per algorithm)
- examples/diffusion_router/demo.py — router process (spawned by bench_router.py)

## Notes

Expand Down
4 changes: 3 additions & 1 deletion examples/diffusion_router/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ def main():

# Pre-register any workers specified on the command line
for url in args.worker_urls:
router.add_worker_sync(url)
if url not in router.worker_request_counts:
router.worker_request_counts[url] = 0
router.worker_failure_counts[url] = 0
if args.verbose:
print(f"[demo] Pre-registered worker: {url}")

Expand Down