Lambda throttle without reaching concurrency limit

0

I have a lambda function served an ALB. I was using 5 EC2 instances to concurrency send http requests to the ALB. the lambda throttle when cloudwatch metrics only shows that the concurrency execution for all lambdas is around 400, and I am sure that the limit is 1000. what might be the cause? the lambda is not on VPC.

asked a year ago721 views
2 Answers
5

Account level lambda concurrency ensures that, these many number of concurrent executions in this account can happen however, if you have reserved concurrency set at any lambda function then other lambda function may be throttled as net concurrency = Account level concurrency - (Total number of reserved concurrency). Did you check, if there is reserved concurrency set on any lambda function.

I'd like to explain it this way, let say:

Total number of lambda functions in the account: 500

Account level concurrency: 14000

There are 7 lambda functions in the account, which have reserved concurrency set on it, each with 200 as concurrent executions, this means that account level concurrency remained zero and rest of all lambda functions would be throttled even if these 7 lambda functions are not running.

Reserved concurrency is often adopted for mission critical applications where those lambda functions can't afford throttling but at the same it simply takes the reservation from account level concurrency.

Refer this doc, which exactly says the same thing and this seems to be happening in your case.

Other thing to consider is number of requests per second. See "Lambda API requests" -> "Invocation request quota" section Lambda quotas

Also, if you want to help figure out the functions, then you can do this way:

   1.) aws lambda list-functions --profile <profile_name> --query 'Functions[*].FunctionName'

Redirect output of previous step to a file. Once you get the list, check the concurrency for each lambda function as below by reading the file, which does have list of lambda functions:

   2.) aws lambda get-function-concurrency --function-name <function_name> --profile <profile_name>
profile pictureAWS
EXPERT
answered a year ago
profile pictureAWS
EXPERT
reviewed a year ago
  • I did not set the reserved concurrency but did set the provisioned concurrency, which is also not sure why the cloudwatch metric shows that provisioned concurrency execution is lower than the set value while the concurrency execution exceeded it.

  • It seems that you are hitting invocation requests per second quota, which means even if concurrency execution does not reach 1,000(over all account level concurrency), if the invocations are over 10,000 per second it will throttle.

    I believe you'd have already gone through this to have clearer understanding, just for your reference:

       Concurrent execution is the total number of concurrent execution available in that account.
       Reserved concurrency is the maximum number of concurrent instances you want to allocate to your function.
       Provisioned concurrency is the number of pre-initialized execution environments you want to allocate to your function.
    
  • It seems that you are hitting invocation requests per second quota, which means even if concurrency execution does not reach 1,000(over all account level concurrency), if the invocations are over 10,000 per second it will throttle.

    Go to Cloudwatch -> Metrics -> All Metric -> Source and paste the following query to see total number of invocations per second while doing the load test. This would explain the throttling in your case:

            {
                "metrics": [
                    [ { "expression": "SEARCH('{AWS/Lambda,FunctionName} (\"Invocations\")', 'Sum', 300)", "label": "LI", "id": "e1", "region": "us-east-1" } ]
                ],
                "view": "timeSeries",
                "stacked": false,
                "region": "us-east-1",
                "stat": "Sum",
                "period": 300,
                "title": "Lambda Invocations"
            }
    

    I believe you'd have already gone through this to have clearer understanding, mentioning here just for your reference from AWS Lambda documentation Lambda Concurrency:

    1. Concurrent execution is the total number of concurrent execution available in that account. 2. Reserved concurrency is the maximum number of concurrent instances you want to allocate to your function. 3. Provisioned concurrency is the number of pre-initialized execution environments you want to allocate to your function.

  • thanks regarding my problem it is clear now that I hit the invocation request limit. I still don't understand the cloudwatch metric part tho.

    I have cloudwatch metrics showing Concurrent Execution and Provisioned Concurrent Execution, both use MAX as statistic. I set the provisioned concurrency to 500, but most time the metrics show 500 > concurrent execution > provisioned concurrency.

    My initial thought was is suppose to be using provisioned concurrency instead of using "Spill over provisioned concurrency". Can you help me understand this part? thanks

  • Like I mentioned above, provisioned concurrency is the number of pre-initialized execution environments that you want to allocate to your function to reduce latency and cold start. Important point to note here is, AWS Documentations says You can configure Provisioned Concurrency up to the Unreserved account concurrency in your account, minus 100. The remaining 100 units of concurrency are for functions that aren't using reserved concurrency. For example, if your account has a concurrency limit of 1,000, and you haven't assigned any reserved or provisioned concurrency to any of your other functions, you can configure a maximum of 900 provisioned concurrency units for a single function.

    In your case, unreserved account concurrency is 400, so max 300 provisioned execution environments can be allotted, rest would be running using account level unreserved concurrency and as that unreserved concurrency limit would be exhausted, your lambda function would start getting throttled. Hope this helps. I'd highly encourage you to go through the concurrency documentation which I shared earlier, that would help you in a big way for better understanding.

    Feel free to comment here if you have any additional questions, happy to help. If this answers your question, please Accept answer and upvote it. TIA.

2

There are a few factors that can cause function throttling:

  • Account concurrency limit. You said that in your case, the overall concurrency was around 400, which is probably below the default 1000 concurrency limit.
  • Function concurrency limit (using Reserved concurrency). This will happen only if you actually configured reserved concurrency for the test function, or maybe, for some other function, If your account limit is 1000, and you configured some other functions with reserved concurrency of 600 total, you remain with only 400 for the rest of the function.
  • There is a less known limit which is number of requests per second. The default value for that is 10 * account concurrency. This means that if you have the default account concurrency of 1000, you can only invoke 10,000 functions per second. As your use case seems to be some sort of load testing, I would assume that this is the limit that you are actually hitting. You can monitor also the sum of invocations to check what is the actual rate.
profile pictureAWS
EXPERT
Uri
answered a year ago
profile pictureAWS
EXPERT
reviewed a year ago
  • I do not set reserve concurrency.

    I did try to hit it from my local machine and it doesn't get throttled and can hit close to 1000 concurrent limit. yes I am load testing the function.

    Regarding sum of invocation, does it means even tho the concurrency execution does not reach 1,000, if the invocations are over 10,000 per second it will throttle?

  • Another question is the cloudwatch metric shows that "concurrent execution" is higher than "provisioned concurrent execution" which is fine. but why the "provisioned concurrent execution" is below what is set?

    I set the provisioned concurrency to 500, and during test it shows the provisioned concurrent execution 100~300 while at the same time the concurrent execution is more than 500.

  • To your questions: 1. Yes, if the invocations are over 10,000 per second, you will be throttled. and 2. There is another limit which is the RPS for provisioned concurrency functions. which 10 * the number set for provisioned concurrency for the function. If you set your PC to 500, you will be able to invoke the provisioned function 5000 RPS. The rest will go to regular functions.

    BTW, to overcome the throttling issue without PC, just ask for a concurrency limit increase. For PC functions, you will need to configure higher number, which has higher cost. Make sure that you need PC.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions