<p>I don't entirely understand your use-case, but it sounds like you are trying to limit the number of Lambda invocations by restricting its IP range.</p>
<p>There are two better ways to rate limit your application. Option one would be to use API Gateway <strong>request throttling</strong>:</p>
<p><a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-request-throttling.html" rel="nofollow noreferrer">https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-request-throttling.html</a></p>
<p>Option two, Lambdas have a <strong>concurrency limit</strong> that can be set to achieve a similar behaviour to your approach:</p>
<p><a href="https://aws.amazon.com/about-aws/whats-new/2017/11/set-concurrency-limits-on-individual-aws-lambda-functions" rel="nofollow noreferrer">https://aws.amazon.com/about-aws/whats-new/2017/11/set-concurrency-limits-on-individual-aws-lambda-functions</a></p>
<p>Hope that helps with your design!</p>

CC BY-SA 4.0
2020-07-19T17:25:40.847Z
My issue was the other way around I'm restricted in the IP range I can give a lambda and wanted to check encase id missed anything in my thinking on the number of synchronous requests it would allow.

Basically me being OCD encase id missed anything though it should get picked up in testing if it will cause an issue.
doug
CC BY-SA 4.0
2020-07-16T17:03:38.210Z
2020-07-16T17:03:38.210Z
Woodland
<p>Am I right in thinking giving a lambda using an API gateway 3 subnets each with a range of 16 would result in 2 subnets being used at once and 1 IP used for the API gateway that is in the same subnets resulting in a max of 31 invocations before the error code 429 is returned due to Too Many Requests.
This is my thinking as there should be no other resources using an ip address that will be in these subnets but I can see testing it as being complicated and taking a very significant amount of time with my current knowledge.</p>

<aws-lambda>
AWS subnets for lambda synchronous invocations
doug
# AWS subnets for lambda synchronous invocations

(Asked by: username_0 on 2020-07-16)

Am I right in thinking giving a lambda using an API gateway 3 subnets each with a range of 16 would result in 2 subnets being used at once and 1 IP used for the API gateway that is in the same subnets resulting in a max of 31 invocations before the error code 429 is returned due to Too Many Requests.
This is my thinking as there should be no other resources using an ip address that will be in these subnets but I can see testing it as being complicated and taking a very significant amount of time with my current knowledge.

**Tags:** aws-lambda


---

## 1 answers

### Answer by username_1 on 2020-07-16. Score: 0

I don't entirely understand your use-case, but it sounds like you are trying to limit the number of Lambda invocations by restricting its IP range.

There are two better ways to rate limit your application. Option one would be to use API Gateway **request throttling**:

<https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-request-throttling.html>

Option two, Lambdas have a **concurrency limit** that can be set to achieve a similar behaviour to your approach:

<https://aws.amazon.com/about-aws/whats-new/2017/11/set-concurrency-limits-on-individual-aws-lambda-functions>

Hope that helps with your design!

> **Comments:**
> **username_0**: My issue was the other way around I'm restricted in the IP range I can give a lambda and wanted to check encase id missed anything in my thinking on the number of synchronous requests it would allow.  Basically me being OCD encase id missed anything though it should get picked up in testing if it will cause an issue.  

---

