2

I recently asked a question to a professor in a QA session. I didn't have the chance to follow up the question because of the volume of the questions asked that day.

So the question is: How do people (in general) get around of the cold start time of AWS Lambda in VPC interacting with RDS?

And his answer is: The ENI which is the long part of the process only attaches at the beginning of the container. So if you run a small select top 1 on your database each minute or so it will keep the connection open and not have to attach the ENI

So my follow up question is,

I have multiple lambda functions. Should I run the SELECT TOP 1 on a single lambda function, or should I ping all of my lambda functions from cloudwatch (and select TOP 1) if the event is from cloudwatch?

Thank you!

1 Answer 1

4

The issue is not with the RDS, but with the Lambda provisioning. The whole ENI thing happens when you've got a "cold" lambda job (one which is not running and not assigned to any container instance). When you try to run a "cold" Lambda job you'll end up experiencing rather large latency no matter what: the AWS system must find a vacant instance, copy your job there, provision additional resources (ENIs, routing table entries, etc.) and only then execute your code (and the execution latency itself may also be rather high if you're using Java or C#).

To prevent your job from going "cold" you don't have to ping the database. You just have to ensure that the job is invoked regularly and often enough, even if it does nothing (you can add a field to your job parameter or environment to the tune "do nothing and exit").

Sign up to request clarification or add additional context in comments.

2 Comments

Ah got it! and if I have 5 lambda functions than I have to invoke 5 of them to ensure they are not going "cold" is that the case?
Basically, yes. Also, AWS Lambda is best effort, so even an oft run function can suddenly become "cold", for example, when instance it's cached on is suddenly removed for maintenance.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.