Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS SQS operations in lambda takes too long on cold start

I've got a Lambda that uses the AWS Java SDK.

In this lambda's handler, I've got code that looks like this:

AmazonSQS sqs = AmazonSQSClientBuilder.defaultClient();
sqs.sendMessage( ... )

I'd expect the above lines to be pretty fast, and for most cases, this is what I'm observing.

However on cold starts, this code is taking about 20 seconds to execute. In fact, just the first line, the client builder, is taking about 10 seconds to complete.

Is this the expected performance of the AWS SQS java api's on cold starts?

like image 347
V Maharajh Avatar asked Dec 19 '25 22:12

V Maharajh


1 Answers

You can create a "keep warm" trigger on cloudwatch that calls your lambda every 5-15 minutes to keep it warm. You get a million free calls every month on lambda so it shouldn't really affect you too much. This is how libraries like zappa keep your APIs warm so it is a well established practice.

You can read more here.

like image 69
Ninad Gaikwad Avatar answered Dec 21 '25 18:12

Ninad Gaikwad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!