- Newest
- Most votes
- Most comments
Concurrency should always be used with Max. Invocations should be used with Sum usually. Duration should be Average or Max.
The discrepancy you're observing between the maximum concurrency of 9 and the SUM statistic of 67 for a 1-minute interval is due to how Lambda concurrency metrics are calculated and reported.
The ConcurrentExecutions metric, which is what you're likely looking at, represents the number of function instances that are processing events at a given time. When you're viewing this metric with the MAX statistic, you're seeing the peak number of concurrent executions within the selected time period, which in your case is 9.
However, when you switch to the SUM statistic for a 1-minute interval, you're not seeing the sum of concurrent executions, but rather the sum of all the data points collected within that minute. Lambda typically reports metrics every few seconds, so the SUM statistic is essentially adding up all these individual data points.
For example, if your function maintained a concurrency of 9 for the entire minute, and Lambda reported this value every 5 seconds, you would see a SUM of 108 (9 concurrent executions * 12 data points in a minute). Your observed SUM of 67 suggests that your function didn't maintain peak concurrency for the entire minute, which is expected given the nature of your test.
It's important to note that the SUM statistic for concurrency metrics doesn't provide a meaningful measure of actual concurrent executions. For monitoring concurrency, it's generally more useful to look at the MAX statistic, which shows you the peak concurrency reached during the time period.
If you want to calculate the average concurrency over a period, you could use the AVG statistic instead of SUM. This would give you a more accurate representation of the typical concurrency level over time.
Remember, concurrency in Lambda is calculated as (average requests per second) * (average request duration in seconds). Your function sleeps for 1 second, which contributes to maintaining some level of concurrency during your test run.
Sources
Understanding Lambda function scaling - AWS Lambda
Types of metrics for Lambda functions - AWS Lambda
Monitoring concurrency - AWS Lambda
Relevant content
- asked 3 years ago
- asked 4 years ago
- asked 2 years ago
- AWS OFFICIALUpdated 4 years ago
