I understand the AWS Lambda is a serverless concept wherein a piece of code can be triggered on some event.
I want to understand how does the Lambda handle scaling?
For eg. if my Lambda function sits inside a VPC subnet as it wants to access VPC resources, and that the subnet has a CIDR of, which would result in 251 available IPs after subtracting the AWS reserved 5 IPs

Would that mean if my AWS Lambda function gets 252 invocations at the exact same time,
Only 251 of the requests would be served and 1 would either timeout or will get executed once one of the 252 functions completes execution?
Does the Subnet size matter for the AWS Lambda scaling?

I am following this reference doc which mentions concurrent execution limits per region,
Can I assume that irrespective of whether an AWS Lambda function is No VPC or if it's inside a VPC subnet, it will scale as per mentioned limits in the doc? enter image description here

  • .. the lambda functions may even have a single IP with your subnet.. the subnet size should net matter in fact – gusto2 Mar 10 at 21:15

Yes, you are right. Subnet size definitely does matter, you have to be careful with your CIDR blocks. With that one last invocation (252nd), it depends on the way your lambda is invoked: synchronously (e.g. API Gateway) or asynchronously (e.g. SQS). If it is called synchronously, it'll be just throttled and your API will respond with 429 HTTP status, which stands for "too many requests". If it is asynchronous, it'll be throttled and will be retried within a six hour period window. More detailed description you can find on this page.

Also I recently published a post in my blog, which is related to your question. You may find it useful.

  • So if I select 2 subnets for the Lambda function, each subnet of 251 size, and if the function gets invoked via API Gateway, would that mean my new scaling size is 251+251= 502? – Aniruddha Raje Mar 10 at 21:17
  • Unless your subnets are not dedicated to lambda and there's something more (EC2 instances?) inside them, it should be 502. It's a good practice to put lambda in different subnets, because it becomes multi AZ, which is fault tolerant. – Vladyslav Usenko Mar 10 at 21:21
  • 1
    Also, I have to mention that at ReInvent 2018 Mark Booger (lead engineer of AWS Lambda team) announced a solution for 2019 both for VPC cold starts and this ugly approach to calculate IP addresses: twitter.com/jeremy_daly/status/1068272580556087296 – Vladyslav Usenko Mar 10 at 21:23
  • Ok so it putting the function under multiple subnets would make it HA and also help in scaling to the sum size of available private IPs of the subnets the function sits in combined? – Aniruddha Raje Mar 10 at 21:24
  • yeah, since VPC is not an actual data center in the cloud (like people call it), but rather a software defined network, we can leverage things like this – Vladyslav Usenko Mar 10 at 21:28

Your Answer

