Skip to main content

Failover, SLA & Rate Limits

Peer-to-peer hardware is inherently more dynamic than a single colocation rack. Tenson engineers reliability directly into the Edge API Gateway so Buyers experience centralized-grade uptime at P2P prices.


1. Silent 3,000ms TTFT Failover​

  1. When POST /v1/chat/completions arrives, the Gateway selects the highest-scoring online node from Redis ZSET grid:model:<id> and atomically reserves a concurrency slot via acquire_slot.lua.
  2. The Gateway dispatches job_request over the worker's persistent WebSocket and starts a strict 3,000ms Time-To-First-Token (TTFT) timer.
  3. If the worker stalls, is cold-loading weights, or loses connectivity before emitting token #1:
    • Gateway immediately sends job_cancel (reason: "ttft_timeout_3000ms").
    • Releases the Redis slot via release_slot.lua.
    • Applies a -2.0 reputation penalty to the stalled node in PostgreSQL.
    • Silently retries the next highest-scoring node (up to 2 P2P retries).

Your SDK never sees a dropped connection or error during pre-first-token failover.


2. 100% Mid-Stream Drop Protection​

Once token #1 has been streamed to the Buyer, silent retry is impossible. If a worker disconnects mid-stream:

  • The WebSocket Hub detects the closed socket immediately and closes all active JobStream channels for that node with ErrWorkerDisconnected.
  • Gateway runs RefundEscrow — returning 100% of your reserved escrow points automatically (you pay $0.00 for any incomplete stream).
  • Gateway logs status = 'failed_midstream' in inference_jobs and docks the worker -5.0 reputation.

3. Invisible Centralized Overflow Fallback​

During regional demand spikes when all P2P concurrency slots for a model are full:

  • Rather than returning 503, the Gateway transparently streams the request through Tenson's configured upstream open-weights cluster (OVERFLOW_BASE_URL).
  • Pricing to the Buyer remains identical.
  • inference_jobs.is_fallback is recorded as true, and Platform Treasury retains 100% of the job charge to cover upstream compute cost.

4. Rate Limits (429 Too Many Requests)​

Every API key carries per-key rate_limit_rpm (default 60–120 RPM) enforced in Redis via rl:rpm:<api_key_id>:<minute_bucket> with a 65s TTL. Exceeding the limit returns standard OpenAI 429 (error.code = "rate_limit_exceeded").