PRO

Effect Shard Router with Backpressure

A work router that keeps one viral key or one noisy tenant from drowning a single worker. A consistent-hash ring (FNV-1a with virtual nodes) places cold keys, and any key that crosses a frequency threshold is split by power-of-two-choices: hash two ring positions and dispatch to the shallower shard, so a hot key spreads across several workers instead of pinning one. Each shard is a bounded Queue, so a full queue makes offer block and backpressure propagates to the producer rather than growing an unbounded backlog in memory. Low-priority work goes to a dropping Queue that sheds load under pressure instead of blocking, and a per-shard Metric gauge exposes live depth for autoscaling. Solves hot partitions and queue backlog. Pinned to effect 4.0.0-beta.98.

Install
npx shadcn@latest add https://ui.aryank.space/r/effect-shard-router-backpressure.json

Installs from ui.aryank.space. To add it by hand, copy the files in Files below, or register the @compronents namespace via the docs.

Visualization
hot key
Job
shard 1
Queue<Job>
shard 4
Queue<Job>
const id = yield* chooseShard(router, key); yield* Queue.offer(shards[id].queue, job)

A consistent-hash ring places cold keys; a key that crosses a frequency threshold splits by power-of-two-choices and dispatches to the shallower of two shards, so one hot key spreads across workers instead of drowning one.

Files

Dependencies