Skip to content

Throttling events consumption

Trimble Event Service uses throttling to limit consumers from polling the service excessively. Throttling protects the server from a considerable load and ensures equitable distribution of its resources. This feature limits the consuming applications to poll at 100 transactions per second (TPS) or requests per second. If the consuming application exceeds the threshold, the requests are throttled and the client is blocked for 45 seconds.

If a consumer’s max poll record is 10, with 100 transactions, they can poll up to 1000 messages/sec (100 x 10).

Websocket

If a consumer crosses the threshold, the server sends a message stating Too Many Requests every 2 seconds to the client. Connections are left open for another 15 seconds. During this period, the server won’t process any throttled requests from the client. However, consumers can send back acknowledgments during this period. After 15 seconds, the server will close all connections associated with the consumer and further block connecting with the consumer for a total of 45 seconds.

While closing throttled connections, the Events server will send back the status code 1006 with the message Too Many Requests.

Recommendations:

  • When the threshold is reached, the consumer will start receiving a message Too Many Requests. During this time the consumer is recommended to stop polling.
  • If reconnection fails after exhausting retry limit, consumers have to establish a new connection manually and start polling.
  • Make sure new connections poll within the threshold limit to avoid getting blocked consecutively.
  • When a considerable lag is observed from the response of Consumer Metadata API the consumers should try to reduce the lag gradually rather than burst poll requests.

HTTP behavior

If a consumer crosses the threshold limit, the server sends a response with a status code 429 and with the message Too Many Requests. No new requests are allowed for 45 seconds.

Recommendations:

  • During throttling, the consumer receives the status code 429 with the message Too Many Requests, which indicates the consumer must stop polling.
  • The consumer should wait for 45 seconds before any new request.
  • After the throttling period, consumers should poll within limits to avoid getting blocked consecutively.
  • When a considerable lag is observed from the response of Consumer Metadata API the consumers should try to reduce the lag gradually rather than burst poll requests.