Unknown reason for API Gateway WebSocket LimitExceededException

1

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

2 Answers
1

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/

prabu
answered 2 years ago
0

"The websocket client side" means the client who subscribe the Websocket. For example , A--->B--->C , When A calls postToConnection of B, B will send data to C, but the recieve buffer of C if full, so there will be exception of B maybe named timeout. So B returns LimitExceededException to A.

simon
answered 5 months 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