AWS WebSocket API: 'Internal Server Error' with Increased Connected Clients

0

Hello!

I have set up a WebSocket API on AWS with Lambda and DynamoDB following this AWS documentation.

When I test the WebSocket with just a few clients (like 2-3), everything works fine, including connections, disconnections, sending messages...

However, when I have a larger number of clients (around 150-200), I get an "Internal Server Error" message when attempting to send a message through the WebSocket API. (connect/disconnect works fine) {"action": "sendmessage", "message": "hello, everyone!"}

I followed all the settings in the AWS console as per the tutorial linked above. Do you have any idea what should be the problem?

  • Have you checked for throttling on your DynamoDB table? How are you handling errors in your Lambda, do you catch exceptions and return the correct response, otherwise it can return internal server error.

  • Hey, there is not throttling on the DynamoDB. For Lambda I used "the app creation template for AWS CloudFormation" from the tutorial above.

  • Did you check the Lambda for errors or timeouts?

  • I found throttles on the Lamda Dashboard https://imgur.com/a/M7gR32M How could I fix this? Sorry, new to AWS :D

2 Answers
1

From your comments it looks like you have both throttling and errors in your Lambda function. We have a great many resources describing throttling and how to overcome it:

By default, there are 1000 units of concurrency allocated to each AWS account per region. This capacity is shared by all the functions in your account, per region. What this implies is that no function in your account can be invoked simultaneously by a rate of more than 1000 times. And if more functions are being invoked at the same time, they will share from the 1000 available units

https://docs.aws.amazon.com/lambda/latest/operatorguide/throttling.html

https://aws.amazon.com/blogs/compute/understanding-aws-lambdas-invoke-throttle-limits/

https://docs.aws.amazon.com/lambda/latest/dg/invocation-retries.html

profile pictureAWS
EXPERT
answered 7 months ago
0

Hello,

Concurrency is a crucial factor to consider in AWS Lambda, as it can lead to application failures through a phenomenon known as Throttling. By default, each AWS account is allocated 1000 units of concurrency per region, shared among all functions in that region. This means that no function can be invoked more than 1000 times simultaneously, and if more invocations occur simultaneously, they will share from the available 1000 units. However, this limit can be increased by requesting support from AWS. Throttling in AWS Lambda happens when function invocations surpass the available concurrency units, resulting in the function not running and triggering a RateExceeded exception.

The following links should help you understand and give you more insights on how to troubleshoot throttling issues

https://repost.aws/knowledge-center/lambda-troubleshoot-throttling

https://aws.amazon.com/blogs/compute/understanding-aws-lambdas-invoke-throttle-limits/

AWS
answered 7 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