Create

Sign in to ReadmeX

or

How we handle your data: Privacy Policy

ReadmeX

Your AI reading companion

What would you like to catch up on?

Pick a briefing, or ask your own question.

Your community and people briefings stay personal to you.

Story

Layered Timeouts and Backoff for Resilient LLM Calls

AI summary

This tutorial presents layered timeouts, error-aware retries, exponential backoff with jitter, and a fallback chain for handling transient LLM dependency failures. It recommends retrying only recoverable errors such as timeouts, connection failures, 429 responses, and 5xx responses, while requiring idempotency for tool calls. The author also reports passing six resilience tests and 128 full regression tests for the accompanying example project.

In-depth insight

The article gives LLM application developers a concrete reliability pattern that distinguishes same-model retries, cross-model fallback, and rule-based handling without treating every failure as retryable.

系列《AI 应用生产化手册》第 23 篇(共 30 篇)· 模块六「架构韧性」开篇|配套开源项目:github.com/ChenYingbo/… 承接 R04 降级链(模型间兜底)与 O03 延迟分位(超时的监控信号)

一、先看问题:外部依赖抖动是常态,不是意外

模型调用是个外部依赖,网络抖一下、限流一下、上游 500 一下——天天发生。裸调的后果:

  • 一个请求能等 60 秒——timeout 没设或设太大,用户转圈转到放弃;连接早就挂了,你还在那干等。
  • 瞬时故障直接失败——网络抖一下、429 限流一下,明明重试一次就能成,却直接甩给用户一个 502。
  • 重试是"裸重试"——失败就立刻重试、连重 N 次把服务打爆、重试和降级还搅在一层里没轻重。

解法:分层超时 + 指数退避重试。连接/读取分级超时,让每类问题在最该暴露的时间暴露;只对可恢复错误重试、退避加抖动防风暴;重试耗尽了,再交给降级链(R04)。

#OpenAI SDK#httpx

Original · 6 min readRead the original
Group chat

No comments yet. Start the conversation.