简体   繁体   English

如何以秒为单位监控 Lambda 并发执行(或找到更好的解决方案来限制 Lambda 并发执行)?

[英]How Could I Monitor Lambda Concurrent Executions on a Second-by-Second Basis (or Find a Better Solution to Limit Lambda ConcurrentExecutions)?

I am working on a massive distributive computing platform built within AWS Lambda. The platform is extremely spiky, so most of the time the number of ConcurrentExecutions is below 50, but we can hit maximum (1000 currently) for up to an hour or more if a large batch job hits the system (it is an event-driven system).我正在 AWS Lambda 内构建的大型分布式计算平台上工作。该平台非常尖锐,所以大多数时候 ConcurrentExecutions 的数量低于 50,但我们可以达到最大值(目前为 1000)达一个小时或更长时间,如果一个大批量作业命中系统(它是一个事件驱动的系统)。 This is a problem as we will have customer-facing APIs that will lag terribly.这是一个问题,因为我们将拥有非常滞后的面向客户的 API。 Finally, I am not an architect, so I have minimal control over how the system was designed, but I have been asked to devise a clever Concurrent Execution limiting solution最后,我不是架构师,所以我对系统的设计方式几乎没有控制权,但有人要求我 devise 一个聪明的并发执行限制解决方案

I'm not new to AWS, so I know about the standard ways to handle this problem.我不是 AWS 的新手,所以我知道处理这个问题的标准方法。 #1 is reserve concurrency on the user-facing lambdas. #1 是面向用户的 lambda 的保留并发。 I'm not allowed to do that for the sake of this exercise (though I'll go tell my boss thats whats necessary if it truly is).为了这个练习,我不允许这样做(尽管我会 go 告诉我的老板那是必要的,如果确实如此)。 I'm thinking of a system where we designate high-priority (for UI) and low priority functions (for batch processing), and the low-priority functions will check a stored (DynamoDB) value output from Cloudwatch on the current number of ConcurrentExecutions.我在考虑一个系统,我们在其中指定高优先级(用于 UI)和低优先级函数(用于批处理),低优先级函数将检查来自 Cloudwatch 的存储(DynamoDB)值 output 当前的并发执行数. If a low priority function finds that we are in danger of using all the ConcurrentExecutions, it will post to a queue with exponential backoff in place.如果低优先级 function 发现我们有使用所有 ConcurrentExecutions 的危险,它将发布到一个队列,并使用指数退避。 This all should work, save the problem that ConcurrentExecutions are only monitored in one-minute increments, which is too slow, as many of our Lambdas run for around 500ms.这一切都应该有效,除了 ConcurrentExecutions 仅以一分钟的增量进行监控的问题,这太慢了,因为我们的许多 Lambda 运行大约 500 毫秒。

So my questions are as follows:所以我的问题如下:

  1. Is there a way to set up a custom ConcurrentExecutions metric that has second-by-second data points, and if so, how would you do it?有没有一种方法可以设置具有逐秒数据点的自定义 ConcurrentExecutions 指标,如果可以,您会怎么做?

  2. Is there a better way to implement a counter than Cloudwatch?有没有比 Cloudwatch 更好的方法来实现计数器?

  3. Am I just missing something here and someone has a clever way to manage Lambda ConcurrentExecutions我只是在这里遗漏了什么,有人有一个聪明的方法来管理 Lambda ConcurrentExecutions

I don't think it's necessary to create a monitor or throttling solution at all.我认为根本没有必要创建监视器或节流解决方案。 You will need to to build test and maintain something additional to your core solution.您将需要构建测试并维护核心解决方案的一些额外内容。 Instead, two suggestions:相反,两个建议:

Sounds like the current design has one lambda function doing too much.听起来当前的设计有一个 lambda function 做得太多了。 Decompose the Lambdas further, so you can split the Lambdas into a Ui/public lambda, and one or more dedicated to the batch processes.进一步分解 Lambda,这样您就可以将 Lambda 拆分为一个 Ui/public lambda,以及一个或多个专用于批处理的过程。 This way you can spread the concurrent execution limit across more Lambdas.通过这种方式,您可以将并发执行限制分散到更多 Lambda 中。 The limit is per Lambda function.该限制是每 Lambda function。

Second, request a service quota/limit increase二、请求增加服务配额/限制

To raise the limit above 1,000 concurrent function executions, submit a request to the AWS Support Center by following the steps in our documentation.要将限制提高到 1,000 次并发 function 执行,请按照我们文档中的步骤向 AWS 支持中心提交请求。 This feature is available in all regions where Lambda is available.可拨打Lambda的所有地区均可使用此功能。

See AWS Lambda Raises Default Concurrent Execution Limits.请参阅 AWS Lambda 提高默认并发执行限制。 https://aws.amazon.com/about-aws/whats-new/2017/05/aws-lambda-raises-default-concurrent-execution-limit/ https://aws.amazon.com/about-aws/whats-new/2017/05/aws-lambda-raises-default-concurrent-execution-limit/

The limit management team is very flexible when asking for a limit to be raped they were generally raise it to any reasonable number that our solution requires.限制管理团队在要求强奸限制时非常灵活,他们通常将其提高到我们的解决方案所需的任何合理数量。

To request a limit increase, see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-resource-limits.html要请求提高限制,请参阅https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-resource-limits.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 aws-xray-sdk nodejs lambda 到 lambda xray 没有在第二个 lambda 上采样痕迹 - aws-xray-sdk nodejs lambda to lambda xray is not sampling the traces on second lambda 调用并发 lambda 时,AWS Lambda 如何分配 CPU? - How AWS Lambda allocates CPU when concurrent lambda invoked? 如何延长 5 秒超时限制 - How can I extend the 5-second timeout limit serverless如何限制并行执行 lambda function - How to limit parallel execution of serverless lambda function 如何找到 lambda function 的端点 API? - How do I find the API endpoint of a lambda function? 限制从 AWS SQS 触发的 AWS Lambda 的并发调用(忽略预留并发)? - Limit concurrent invocation of a AWS Lambda triggered from AWS SQS (Reserved concurrency ignored)? AWS Step Functions 标准工作流程并发执行限制 - AWS Step Functions standard workflows concurrent executions limit 如何限制lambda function每分钟的通话次数? - how to limit the number of lambda function calls per minute? AWS Kinesis,并发 Lambda 处理,保证顺序 - AWS Kinesis, concurrent Lambda processing with a guaranteed ordering 如何注册 opentelemetry lambda 扩展? - How can I register opentelemetry lambda exention?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM