Skip to content

Conversation

lidel
Copy link
Member

@lidel lidel commented Aug 11, 2025

This PR adds built-in limiters for IPFS Gateway requests: retrieval-timeout (default: 30s) and max-concurrent-requests (default: 1024).

On ipfs.io

cc @gammazero @hsanjuan @ns4plabs for visibility as this PR moves some of Nginx responsibilities to Rainbow.

High load infrastructure like ipfs.io will need to ensure Nginx limits are bit higher than Rainbow, namely:

  • proxy_read_timeout (nginx) > RAINBOW_RETRIEVAL_TIMEOUT here (right now both 30s, we need to set proxy +5s)
  • worker_connections (nginx) > RAINBOW_MAX_CONCURRENT_REQUESTS (1024 needs to be raised, fysa ipfs.io uses value 10x bigger)

We can disable limits by setting both env variables to 0

@lidel
Copy link
Member Author

lidel commented Aug 11, 2025

I'll be fixing conformance failures in ipfs/boxo#994 – they are not related to feature added here, but existing bugs that now are surfaced by time-bound execution.

@lidel lidel requested review from hsanjuan and gammazero August 11, 2025 22:36
@lidel lidel marked this pull request as ready for review August 11, 2025 22:36

Maximum number of concurrent HTTP requests that the gateway will process.

This setting provides rate limiting to protect the gateway from resource exhaustion during high load scenarios. When the limit is reached, new requests will receive a `429 Too Many Requests` response with a `Retry-After` header indicating when the client should retry.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And when should that retry be? Is it hardcoded or dynamic or...?

Copy link
Member Author

@lidel lidel Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hsanjuan for now Retry-After header is hardcoded to 60 seconds. Pushed 789b053 to document that.

Making this dynamic would make ipfs/boxo#994 even more complex and wanted to avoid that for now.

We can make it configurable in the future PRs but my experience has been clients either detect header and have own smart backoff (using 60s value as initial hint only), or just ignore the header so for MVP static 1m should be ok.

lidel and others added 3 commits August 13, 2025 21:40
Co-authored-by: Andrew Gillis <11790789+gammazero@users.noreply.github.com>
@hsanjuan hsanjuan merged commit 68b4eb9 into main Aug 14, 2025
11 checks passed
@hsanjuan hsanjuan deleted the feat-additional-gateway-limits branch August 14, 2025 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants