Facing Random Connection Timeouts with Elasticache in Lambda Functions

0
4
Asked By TechieExplorer42 On

I've got a Lambda function that handles around 200,000 invocations daily from SQS, and it runs on Node.js. I'm using Glide to connect to Elasticache Serverless v2 (valkey), but I'm experiencing about 30 connection timeouts each day. These timeouts are infrequent compared to the total requests, and I'm trying to figure out the cause. My Lambda is set up in a VPC, spanning two availability zones, with a NAT gateway in place. I've configured a 2-second connection timeout and a 5-second command execution timeout. The error I keep seeing in Sentry is:

ClosingError

Connection error: Cluster(Failed to create initial connections - IoError: Failed to refresh both connections - IoError: Node: "[redacted].serverless.use1.cache.amazonaws.com:6379" received errors: `timed out`, `timed out`)

Any insights would be appreciated!

3 Answers

Answered By NetworkNinja88 On

The errors could be related to network I/O problems. It might be something to look into on your infrastructure side.

Answered By ConnectionGuru99 On

Have you considered reusing your connections? Lambda can reuse invocation space, so it's a good idea to check if you have an existing open connection before trying to create a new one.

Answered By HardwareWhisperer7 On

An I/O error often points to possible hardware issues. Just a theory, but could be worth investigating further!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.