Skip to content

Support Rate Limiting in the Octopus C# Client #10202

Description

@borland

The enhancement

The Need

In #10155, Octopus Server gained an HTTP rate limiter, which rejects requests with an HTTP 429 (TooManyRequests) error if a client issues them too rapidly.

The Octopus C# Client did not understand these requests, and would simply propagate an HTTP 429 by throwing an OctopusException

Solution

Octopus C# client version 22.9.2886 introduces support for rate limiting.

When the Octopus Server rejects a request with a 429, the client will now wait the duration specified in the Retry-After HTTP response header, then try again. The user of the client is not affected, they will not experience any exceptions or failures, just the delay.

Configuration:

The OctopusClientOptions object gains three new options:

  • RateLimitRetryCount - an integer number, defaulting to 3 which specifies how many times the client will retry an HTTP 429 before giving up.
    • Set this to 0 to disable the client's retry behavior
  • RateLimitRetryDefaultDelay - TimeSpan, defaulting to 2 seconds which specifies how long the client should wait if it sees an HTTP 429 without a Retry-After header. The server should always set a header, this is just a defense-in-depth mechanism
  • RateLimitRetryMaxDelay - TimeSpan, defaulting to 30 seconds, which is a safety net against unexpected server responses. If the server's Retry-After header tells the client to wait more than this length of time, the client will throw the OctopusException rather than waiting for an unreasonable amount of time. The server should not send invalid responses, this is just a defense-in-depth mechanism.

Edge case

  • Requests which stream content (e.g. file uploads) cannot be safely retried by the client. If the server sends a 429 in response to one, the exception will be thrown immediately.

Links

https://octopus.com/docs/administration/managing-infrastructure/rate-limiting/

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/enhancementThis issue represents an enhancement we are committed to adding to Octopus as some time

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions