Client Throttling rule

Use the Client Throttling rule to limit calls to a Service or endpoint and help protect a Snaplex from being overloaded by too many requests.

Limits the number of requests allowed from a client during the specified time period. Applying this rule can help protect a Snaplex from being overloaded by too many requests. The Client Throttling rule rule records the count and rate of requests from individual clients. It compares the values against those specified in the Service Tiers settings. When a limit is met, the client's ability to make requests is throttled for some amount of time—queuing the request for a short period of time, or rejecting the request with a 429 Too Many Requests error. If the request is rejected and the client supports the Retry-After HTTP header, the client can retry the request after the specified number of seconds.

Rule execution order

This rule is executed after the request passes authentication and authorization.

Settings

Field Description
When this rule should be applied An expression that defines one or more conditions that must be true for the rule to execute.

Default value: N/A

Example: The expression request.method == "POST" causes the rule to execute only on POST requests.

Service Tiers Enter levels of a service tier to apply to clients as a condition. Enter each Condition as an expression that is evaluated against a request and used with the specified limits to restrict the request rate. If no matches are found, the limits defined in Default Tier are used.
Condition

Required. Choose the expression that defines this service tier. The expression has access to the request object, so the condition can match on the method, request headers, URI, and the user name or roles.

Default value: False

Example:
  1. To match POST requests: request.method == 'POST'
  2. To match POST requests from users with the admin role: request.method == ‘POST’ && request.isUserInRole('admin')
Request Limit

Required. The number of requests to allow for the defined period. 

This field determines the client’s quota over the long-term with a separate short-term quota used to prevent bursts of requests from overloading a Snaplex. For example, if a service tier is set to allow 5,000 requests per hour, it would be undesirable for all of those requests to be allowed through in a single minute.

Default value: 1000

Example: 100

Per Required. . The unit of time for the period: DAY, HOUR, MINUTE, or SECOND

Default value: HOUR

Example: DAY

Default Tier Required. Specify the values for the default service tier.
Request Limit

Required. The number of requests to allow for the defined period.

Default value: 5000

Example: 3500

Required. The unit of time for the period: DAY, HOUR, MINUTE, or SECOND for the specified default Request Limit.

Default value: HOUR

Example: DAY

Throttling Required. These settings control how requests that are over the limit are handled. A request can be queued and retried if the limit will be refreshed within a certain time. Otherwise, it will be rejected with a 429 Too Many Requests error.
Attempts Required. The number of attempts to try before rejecting a request.

Default value: 3

Example: 3

Delay in ms Required. The number of milliseconds to delay before retrying a request. This field determines the timeframe before the token refill in which requests can be queued. If the request arrives well before the refill time, it is rejected.
Note: The client connection to the server is kept open during this delay and continues to consume resources. Setting this value too high can result in clients consuming too many resources.

Default value: 500

Example: 1000

Description

Required. A brief description of this rule.

Default value: Repeat requests are being limited to no more than the specified limit

Example: Task client throttles

Peak Calculation Chart

With the Client Throttling rule enabled, the maximum number of calls that the system limits in a minute is 1000. The following expression gives you the smallest number between 1000 and the ceiling of your limit divided by 10, where the function returns the smallest integer value equal or greater than value: Math.min(1000, Math.ceil(limit / 10))=. Smaller of one of the two numbers: 1,000 or the ceiling of your Service Tier's Limit / 10

Use the following matrix to determine the peak limit based on the rule Tier Limit:

Table 1. Peak Calculation Matrix
Per (Unit of Time) Up to 60 API calls More than 60 API calls
Minutes 5 per second Math.min(1000, Math.ceil(Limit / 10)) per second
Hour 5 per minute Math.min(1000, Math.ceil(Limit / 10)) per minute
Day 5 per minute Math.min(1000, Math.ceil(Limit / 10)) per minute
Note: Although the Client Throttle rule supports the time unit of seconds, the peak calculation does not apply to a setting in seconds since that is the smallest increment of time.