Skip to content

Engineering gaps: no circuit breaker, usage normalization accuracy, cache invalidation, rate limit strategy #1

@huiguyy

Description

@huiguyy

Issue: Engineering Observations — Four Areas Needing Clarification or Enhancement

Hi, thanks for building Free-Way — it's a very useful tool for the free LLM ecosystem. After reviewing the codebase, I have four engineering observations that may benefit from documentation or implementation work:

1. No circuit breaker documented (高并发场景缺乏熔断机制)

The current automatic fallback strategy handles provider failures, but there is no documented circuit breaker or rate limiting behavior. In high-concurrency scenarios, if multiple providers are degraded simultaneously, the gateway may still fan out requests to unhealthy backends without throttling.

Suggested: Document the retry/fallback limits and consider adding a circuit breaker pattern (e.g., per-provider failure threshold → temporary open-circuit → health-check probe before reopening).

2. Usage normalization accuracy needs validation (Usage 归一化准确性需验证)

Different providers expose different field semantics in the usage object. The gateway normalizes usage at the gateway layer, but the mapping logic and accuracy of cross-provider normalization are not explicitly documented or tested.

Suggested: Add a USAGE_NORMALIZATION.md documenting:

  • Which fields are mapped (input tokens, output tokens, total tokens)
  • How each provider's native format is translated
  • Known edge cases or unsupported fields

3. Model catalog cache invalidation not specified (模型目录缓存失效策略不明确)

The catalog uses a cache fallback mechanism, but the invalidation strategy (TTL, event-based refresh, manual-only) is not documented. This may lead to stale model lists being served after a provider removes or adds models.

Suggested: Document:

  • Cache TTL (if any)
  • How POST /api/models/refresh behaves
  • Whether provider-level model availability changes trigger automatic re-fetch

4. No rate limit strategy documented (缺少 Provider 超限时的限流策略)

When a free-tier provider rate-limits or quota-exhausts, the current routing strategy is not specified. It's unclear whether the gateway:

  • Retries with exponential backoff
  • Immediately fails over to the next provider
  • Returns the 429 directly to the client

Suggested: Document the rate-limit handling behavior, ideally with configurable strategies (e.g., retry vs. fail-fast per provider).


Overall Free-Way is excellent — these are not blockers but quality-of-documentation and production-hardening items. Happy to contribute a PR if the maintainers are open to it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or requestgood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions