V Maharajh
V Maharajh

Reputation: 9639

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?

Upvotes: 3

Views: 1556

Answers (1)

Ninad Gaikwad
Ninad Gaikwad

Reputation: 4480

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.

Upvotes: 2

Related Questions