By using AWS re:Post, you agree to the Terms of Use
/Unknown reason for API Gateway WebSocket LimitExceededException/

Unknown reason for API Gateway WebSocket LimitExceededException

0

We have several API Gateway WebSocket APIs, all regional. As their usage has gone up, the most used one has started getting LimitExceededException when we send data from Lambda, through the socket, to the connected browsers. We are using the javascript sdk's postToConnection function. The usual behavior is we will not get this error at all, then we will get several hundred spread out over 2-4 minutes.

The only documentation we've been able to find that may be related to this limit is the account level quota of 10,000 per second (and we're not sure if that's the actual limit we should be looking at). If that is the limit, the problem then is that we are nowhere near it. For a single deployed API we're hitting a maximum of 3000 messages sent through the socket per minute with an overall account total of about 5000 per minute. So nowhere near the 10,000 per second.

The only thing we think may be causing it is we have a "large" number messages going through the socket relative to the number of connected clients. For the api that's maxing at about 3000 messages per minute, we usually have 2-8 connected clients. Our only guess is there may be a lower limit to number of messages per second we can send to a specific socket connection, however we cannot find any docs on this.

Thanks for any help anyone can provide

1 Answers
0

LimitExceededException - The client is sending more than the allowed number of requests per unit of time or the WebSocket client side buffer is full.

In your case the client refers to the Lambda that is calling postToConnection API.... there is a limit at which this API can be invoked per second... once we go beyond the limit thats when it results in the LimitExceededException. https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/apigatewaymanagementapi/AmazonApiGatewayManagementApi.html#postToConnection-com.amazonaws.services.apigatewaymanagementapi.model.PostToConnectionRequest-

Note: Request rate limit of postToConnection is unknown as we couldn't find related documentation.

Possible Solution: Check the response from postToConnection if it results in LimitExceededException then retry by waiting for few hundred milliseconds. Best practice is to apply exponential backoff with jitter https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/

answered a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions