Hi, I'm developing a custom events scheduler service that is built on top of Lambda (Node), DynamoDB and SQS. During testing, I encountered a recurring "Timeout Error ECONNRESET" when attempting to send messages to SQS.
Context
My setup involves a "scheduler" Lambda function that executes every minute to retrieve events scheduled for dispatch within the next 10 minutes from DynamoDB. These events are then enqueued in an SQS queue using a sendMessage call, with a delay set until their scheduled dispatch time. Subsequently, a "dispatcher" Lambda function consumes these messages to dispatch events to an EventBridge bus. To stress-test the system, I've been manually creating events scheduled for simultaneous emission.
My issue
The problem arises when I attempt to enqueue over approximately 2000 messages to the SQS "dispatcher" queue. At this point, the SDK throws TimeoutError ECONNRESET when sending messages to SQS, typically after three internal attempts. Each Lambda execution sends a maximum of 25 messages in parallel, and the volume of messages does not seem substantial enough to exceed SQS limitations. However, I am struggling to understand why this error occurs so frequently.
Additional information
- Region :
eu-central-1
- Lambda Node.js 20.x
- AWS SDK v3
Thanks for your answer, I revamped my implementation to avoid sending too many message in the same lambda process and used batching to reduce SQS calls it looks like I do not have the ECONNRESET error anymore.
Unfortunately EventBridge Scheduler doesn't totally fit my needs since it has a 60-second precision and for the purpose of my application I need something closer to a 1-second precision. But maybe combined with a sleep function in the dispatcher it could do the job, I'll further dig into it to!