Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for policy identifier #130

Merged
merged 31 commits into from
Sep 29, 2024
Merged
Changes from 4 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a544a5a
Fix: #64. Combine header.
ioggstream Nov 17, 2022
0b47e95
Updated with policy parameter
darrelmiller Jul 19, 2023
6f5909b
Merge remote-tracking branch 'origin/main' into darrelmiller-policyname
darrelmiller Jul 19, 2023
08d1ada
Removed limit
darrelmiller Jul 19, 2023
c3fa4e5
Updated based on IETF117 feedback
darrelmiller Nov 6, 2023
562114b
Run make fix-lint.
ioggstream Jan 8, 2024
02a991c
remove unsupported 'example' sourcecode type.
ioggstream Jan 8, 2024
0fad367
Fix section references.
ioggstream Jan 8, 2024
fc0dc0b
Update draft-ietf-httpapi-ratelimit-headers.md
ioggstream May 5, 2024
7a94332
Update draft-ietf-httpapi-ratelimit-headers.md
darrelmiller Jun 2, 2024
9b9c2d8
Added author to assign appropriate blame
darrelmiller Jun 2, 2024
ee0e5b9
Merge branch 'darrelmiller-policyname' of https://github.com/ietf-wg-…
darrelmiller Jun 2, 2024
2d203f3
Updates based on feedback to PR
darrelmiller Jul 8, 2024
77e31a0
uncommented front matter
darrelmiller Jul 8, 2024
4196337
Add support to pk
darrelmiller Jul 14, 2024
df6faac
Restoring front matter
darrelmiller Jul 14, 2024
55fcfee
fixed again
darrelmiller Jul 14, 2024
c683773
added missing value to front matter
darrelmiller Jul 14, 2024
00f5fa4
Fixed YAML frontmatter
darrelmiller Jul 14, 2024
62b57bf
Fixed indent
darrelmiller Jul 14, 2024
6c037ed
Removed trailing whitespace
darrelmiller Jul 14, 2024
93ef0f0
Added specialized item headings
darrelmiller Jul 14, 2024
d909a83
reenabled frontmatter
darrelmiller Jul 14, 2024
7a1c8d1
Major refresh
darrelmiller Sep 28, 2024
82e1a15
Updated examples
darrelmiller Sep 29, 2024
2b47acd
Updated based on make linting errors
darrelmiller Sep 29, 2024
e29b364
Added linting fixes
darrelmiller Sep 29, 2024
10657fe
Revert "Added linting fixes"
darrelmiller Sep 29, 2024
c9d03f7
Updated upload artifacts workflow
darrelmiller Sep 29, 2024
00ab09f
Merge branch 'darrelmiller-policyname' of /mnt/c/Users/darrmi/src/git…
darrelmiller Sep 29, 2024
f75528e
Removed generated files from source
darrelmiller Sep 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 28 additions & 61 deletions draft-ietf-httpapi-ratelimit-headers.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ author:
name: Alejandro Martinez Ruiz
org: Red Hat
email: [email protected]
-
ins: D. Miller
name: Darrel Miller
org: Microsoft
email: [email protected]
darrelmiller marked this conversation as resolved.
Show resolved Hide resolved

entity:
SELF: "RFC nnnn"
Expand All @@ -57,21 +62,20 @@ This document defines the RateLimit-Policy and RateLimit HTTP header fields for

# Introduction

Rate limiting HTTP clients has become a widespread practice, especially for HTTP APIs. Typically, servers who do so limit the number of acceptable requests in a given time window (e.g. 10 requests per second). See {{rate-limiting}} for further information on the current usage of rate limiting in HTTP.
Rate limiting of HTTP clients has become a widespread practice, especially for HTTP APIs. Typically, servers who do so limit the number of acceptable requests in a given time window (e.g. 10 requests per second). See {{rate-limiting}} for further information on the current usage of rate limiting in HTTP.

Currently, there is no standard way for servers to communicate quotas so that clients can throttle its requests to prevent errors. This document defines a set of standard HTTP header fields to enable rate limiting:
Currently, there is no standard way for servers to communicate quotas so that clients can throttle their requests to prevent errors. This document defines a set of standard HTTP header fields to enable rate limiting:

- RateLimit: to convey
the server's current limit of quota units available to the client in the policy time window,
the remaining quota units in the current window,
and the time remaining in the current window, specified in seconds, and
- RateLimit-Policy: the service policy limits.

These fields allow the establishment of complex rate limiting policies, including using multiple and variable time windows and dynamic quotas, and implementing concurrency limits.
These fields enable establishing complex rate limiting policies, including using multiple and variable time windows and dynamic quotas, and implementing concurrency limits.

The behavior of the RateLimit header field is compatible with the delay-seconds notation of Retry-After.


## Goals {#goals}

The goals of this document are:
Expand Down Expand Up @@ -109,7 +113,7 @@ The following features are out of the scope of this document:
successful (see {{Section 15.3 of HTTP}}) and non-successful responses.
This specification does not cover whether non Successful
responses count on quota usage,
nor it mandates any correlation between the RateLimit values
nor does it mandates any correlation between the RateLimit values
and the returned status code.

Throttling policy:
Expand Down Expand Up @@ -141,16 +145,16 @@ A quota policy is maintained by a server to limit the activity (counted in quota

Quota policies can be advertised by servers (see {{ratelimit-policy-field}}), but they are not required to be, and more than one quota policy can affect a given request from a client to a server.

A quota policy is expressed in Structured Fields {{STRUCTURED-FIELDS}} as a sf-Item that identifies the policy and its associated parameters.
A quota policy is expressed in Structured Fields {{STRUCTURED-FIELDS}} syntax as a sf-Item that identifies the policy and its associated parameters.

The following parameters are defined in this specification:

l:
: The REQUIRED "l" parameter uses a non-negative integer value to limit the activity (counted in quota units) of a given client ({{service-limit}}).
: The REQUIRED "l" parameter uses a non-negative integer value to "limit" the activity (counted in quota units) of a given client ({{service-limit}}).

w:
: The OPTIONAL "w" parameter value conveys
a time window ({{time-window}}).
a time "window" ({{time-window}}).

For example, a quota policy named "default" of 100 quota units per minute is expressed as:

Expand Down Expand Up @@ -185,29 +189,21 @@ Quota policies MAY limit the number of acceptable requests within a given time i

The time window is a non-negative Integer value expressing that interval in seconds, similar to the "delay-seconds" rule defined in {{Section 10.2.3 of HTTP}}. Subsecond precision is not supported.

By default, a quota policy does not constrain the distribution of quota units within the time window. If necessary, these details can be conveyed as extension parameters.

For example, two quota policies containing further details via extension parameters:

~~~
tier1;l=100;w=60;comment="fixed window"
protect;l=12;w=1;burst=1000
~~~

By default, a quota policy does not constrain the distribution of quota units within the time window.

# RateLimit header field Definitions

The following RateLimit response header fields are defined.
The following response header fields are defined.

## RateLimit {#ratelimit-field}
## RateLimit Field {#ratelimit-field}

A server uses the "RateLimit" response header field to communicate the client quota consumption state.

The field is expressed as a Structured Fields {{STRUCTURED-FIELDS}} sf-Item that identifies the policy and its associated consumption state as parameters.

An origin server MUST not return a response that contains multiple rate limit fields with the same policy value.
An origin server MAY return one or more rate limit fields. It MUST not return a response that contains multiple rate limit fields with the same policy value. Rate limit fields SHOULD use policy identifiers that correspond to policy identifiers declared in RateLimit-Policy fields.

The field is a Dictionary. The allowed keys are defined in the "Hypertext Transfer Protocol (HTTP) RateLimit Keywords and Parameters Registry", as described in {{iana-ratelimit-parameters}}.
The allowed parameters are defined in the "Hypertext Transfer Protocol (HTTP) RateLimit Parameters Registry", as described in {{iana-ratelimit-parameters}}.

The following parameters are defined in this specification:

Expand All @@ -224,26 +220,16 @@ This field cannot appear in a trailer section.
~~~


## Remaining Parameter {#ratelimit-remaining-parameter}
### Remaining Parameter {#ratelimit-remaining-parameter}

The "r" parameter indicates the remaining quota units associated with the expiring-limit.

It is an Item and its value is a non-negative Integer expressed in [quota units](#service-limit).
This specification does not define Parameters for it.
If they appear, they MUST be ignored.
The "r" parameter indicates the remaining quota units for the identified policy ({{ratelimit-remaining-parameter}}).

It is a non-negative Integer expressed in [quota units](#service-limit).
Clients MUST NOT assume that a positive remaining value is a guarantee that further requests will be served.

When the value of the remaining keyword is low, it indicates that the server may soon throttle the client (see {{providing-ratelimit-fields}}).

For example:

~~~
r=50
~~~


## Reset Keyword {#ratelimit-reset-parameter}
### Reset Parameter {#ratelimit-reset-parameter}

The "t" parameter indicates the number of seconds until the quota associated with the expiring-limit resets.

Expand All @@ -253,24 +239,15 @@ It is a non-negative Integer compatible with the delay-seconds rule, because:
and clock skew between client and server (see {{Section 5.6.7 of HTTP}});
- it mitigates the risk related to thundering herd when too many clients are serviced with the same timestamp.


For example:

~~~
t=50
~~~

The client MUST NOT assume that all its service limit will be reset at the moment indicated by the reset keyword. The server MAY arbitrarily alter the reset keyword value between subsequent requests; for example, in case of resource saturation or to implement sliding window policies.

The client MUST NOT assume that all its service limit will be reset at the moment indicated by the reset keyword. The server MAY arbitrarily alter the reset paramter value between subsequent requests; for example, in case of resource saturation or to implement sliding window policies.

## RateLimit-Policy {#ratelimit-policy-field}

The "RateLimit-Policy" response header field contains properties of the quota policy of the target resource that are expected to remain consistent over a the lifetime of a connection. It is this characteristic that differentiates itself from the [RateLimit](#ratelimit-field) that contains values that may change on every request. Its value is informative.
The "RateLimit-Policy" response header field contains information about the quota policy of the target resource that is expected to remain consistent over a the lifetime of a connection. It is this characteristic that differentiates itself from the [RateLimit](#ratelimit-field) that contains values that may change on every request. Its value is informative.

The field is a non-empty List of Items. Each item is a [quota policy](#quota-policy).
Two quota policies MUST NOT be associated with the same quota units value unless they are differentiated with a unique p parameter value.

This field can convey the time window associated with the expiring-limit, as shown in this example:
This field MAY convey the time window associated with the expiring-limit, as shown in this example:

~~~
RateLimit-Policy: default;l=100;w=10
Expand All @@ -280,14 +257,8 @@ This field can convey the time window associated with the expiring-limit, as sho
These examples show multiple policies being returned:

~~~
RateLimit-Policy: persec;l=10;w=1, permin;l=50;w=60, perhr;l=1000;w=3600, perday;l=5000;w=86400
RateLimit-Policy: persec;l=10;w=1;burst=1000, perhr;l=1000;w=3600
~~~

An example of invalid header field value with two policies associated with the same quota units without a unique "p" parameter value to differentiate them:

~~~
RateLimit-Policy: spike;l=10;w=1, rate;l=10;w=60
RateLimit-Policy: permin;l=50;w=60, perhr;l=1000;w=3600, perday;l=5000;w=86400
RateLimit: permin;r=20;w=23, perhr;r=399;w=2402
~~~

This field cannot appear in a trailer section.
Expand Down Expand Up @@ -1191,10 +1162,7 @@ Here are some interoperability issues:
* X-RateLimit-Reset and X-Rate-Limit-Reset

The semantic of RateLimit depends on the windowing algorithm.
The semantic of RateLimit depends on the windowing algorithm.
A sliding window policy for example may result in having a
remaining keyword
value related to the ratio between the current and the maximum throughput.
A sliding window policy for example, may result in having a remaining keyword value related to the ratio between the current and the maximum throughput.
e.g.

~~~
Expand Down Expand Up @@ -1228,8 +1196,7 @@ Aapo Talvensaari,
Nathan Friedly
and Sanyam Dogra.

In addition to the people above, this document owes a lot to the extensive discussion
in the HTTPAPI workgroup, including
In addition to the people above, this document owes a lot to the extensive discussion in the HTTPAPI workgroup, including
Rich Salz,
Darrel Miller
and Julian Reschke.
Expand Down
Loading