We are currently running our AWS Lambda's in a VPC due to an earlier architectural decision.

We are also using MongoDB Atlas and a peering connection setup between the VPC and Atlas. This obviously is causing longer cold starts with the need of setting up the ENI.

I'm looking to cut this down by moving our database within the same VPC but want to do a sanity check if this is even possible.

Current flow is API Gateway -> AWS Lambda on VPC using Serverless Framework <- PEERING CONNECTION -> MongoDB Atlas for datastore.

  1. If we run something like DocumentDB or DynamoDB within the same VPC as the VPC that is running our AWS Lambdas, will we still encounter the ENI creation delay and limits?

  2. During a previous AWS Re:invent event there was talk of improving this by pooling the ENI's but we have not received any update about this going live yet, is there an update this?


Here is the announcement you're after: Improved VPC networking for AWS Lambda functions

That should speed up your Lambda cold starts significantly. In the announcement AWS claims that the change reduced their cold start "from 14.8 seconds to 933 ms".

Whether your Lambdas run in the same VPC as your MongoDB or not doesn't really matter, the Lambda cold start speed will be the same. However if you want to have more control of your networking, latency and maybe even reduce outbound data costs I would consider DocumentDB over MongoDB Atlas that runs in a different VPC.

Hope that helps :)


To minimize frequency of cold start, you can setup call to your lambda function every 5 minutes using cloudwatch or somethink else.

  • Yes, we already do that but the gist of the question is not cold starts per se. It's whether running external resources within the VPC would remove the ENI part of the cold start, not the cold start of the Lambda itself. – Simon Oct 31 '19 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.