boxo icon indicating copy to clipboard operation
boxo copied to clipboard

feat(gateway): implement request concurrency limit

Open gitsrc opened this issue 8 months ago • 2 comments

This commit introduces a mechanism to limit the number of concurrent in-flight HTTP requests to the gateway.

  • Implements a configurable limit for concurrent requests.
  • Returns HTTP 503 Service Unavailable with Retry-After header when the limit is reached.
  • Includes a default limit to protect against traffic spikes when exposed without a reverse proxy.

This change enhances gateway's resilience and prevents overload by limiting concurrent requests.

#881

gitsrc avatar Mar 19 '25 11:03 gitsrc

Triage notes: this will be triaged as part Kubo v0.35 (@lidel )

hsanjuan avatar Mar 25 '25 15:03 hsanjuan

Triage notes: moving to ~0.36~ 0.37

lidel avatar May 06 '25 14:05 lidel

Triage notes: @lidel is still on it, has not forgotten about, will be dealt with in due time.

hsanjuan avatar Jun 10 '25 14:06 hsanjuan

This endeavor needs more metrics and tests and integration with timeouts.

The atomic.AddInt32 proposed in this PR is ok, however feels like not the best tool for the job. Let's go with more idiomatic semaphore approach from https://github.com/ipfs/boxo/pull/994 which has lower risk of busy-waiting/checking/mutating shared int value in a tight loop.

lidel avatar Aug 11 '25 03:08 lidel