我可以通过Amazon API网关异步启动长时间运行的AWS Lambda流程吗? [英] Can I initiate a long-running AWS Lambda process via the Amazon API gateway asynchronously?

查看:44
本文介绍了我可以通过Amazon API网关异步启动长时间运行的AWS Lambda流程吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要启动一个长期运行的AWS Lambda作业(几分钟),将其输出写入S3.它将用Java(实际上是Kotlin,但这没关系)编写.

I need to initiate a long-running AWS Lambda job (several minutes) that will write its output to S3. It will be written in Java (actually Kotlin, but that shouldn't matter).

我正在研究Amazon API Gateway,它将作为该任务与其他AWS Lambda作业和将与其通信的iOS移动应用程序之间的接口.

I'm investigating the Amazon API Gateway as the interface between this and other AWS Lambda jobs and an iOS mobile app that will talk to it.

是否可以直接从API网关或另一个Lambda函数异步调用此类长时间运行的Lambda进程?

Is it possible to asynchronously invoke such long-running Lambda processes, either directly from the API Gateway, or from another Lambda function?

推荐答案

我认为您不能直接通过API网关异步调用Lambda,但可以通过API从另一个Lambda调用Lambda.在Java中,您可以使用

I don't think you can invoke a Lambda asynchronously directly through the API Gateway, but you can invoke the lambda from another lambda through the API. In Java, you'd use AWSLambdaClient.invoke() with an InvocationType of Event.

对于长时间运行的作业,请谨慎使用Lambda:Lambda调用有300秒的硬限制.我建议使用Lambda在EC2之类的持久资源中调用代码,以长时间运行后端进程.

Be careful using Lambda for long running jobs: there is a hard 300 second limit on Lambda invocations. I'd recommend having a Lambda invoke code in a persistent resource like EC2 for long running backend processes.

这篇关于我可以通过Amazon API网关异步启动长时间运行的AWS Lambda流程吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆