响应然后继续使用AWS Lambda/API网关吗? [英] Respond then continue working with AWS Lambda/API Gateway?

查看:54
本文介绍了响应然后继续使用AWS Lambda/API网关吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前有一个Web钩子正在调用AWS API Gateway-> AWS Lambda函数代理.我想使Web挂钩更具响应性,并在继续在Lambda中进行处理的同时返回较早的答复.

I currently have a Web hook that's calling AWS API Gateway -> AWS Lambda function proxy. I'd like to make the web hook more responsive and return an early reply while continuing processing in the Lambda.

我继续并从Lambda(节点v6.10)处获得了此早期答复,但它似乎并没有提高响应速度.尽管已经收到回调的响应,API网关是否仍以某种方式等待Lambda完成执行?

I went ahead and did this early reply from the Lambda (Node v6.10) but it didn't appear to have improved responsiveness. Is API Gateway somehow waiting for the Lambda to finish executing despite having the response from the callback already?

另一个想法是从Lambda发布SNS通知并进行第二次Lambda侦听并继续进行处理,但是如果有更简单的方法,则宁愿避免这种复杂性.

The other idea is to post an SNS notification from Lambda and have a second Lambda listen and continue processing but would rather avoid that complication if there's a simpler way.

推荐答案

API网关当前仅支持Lambda函数的同步调用(aka InvocationType:RequestResponse ),所以是的,它正在等待完整的调用.Lambda的回应.

API Gateway currently only supports synchronous invocation (aka InvocationType: RequestResponse) of Lambda functions, so yes, it is waiting for the full response from the Lambda.

要支持您的用例,您可以使用SNS或其他中间AWS服务(例如Kinesis,SQS等).但是您也可以单独使用Lambda来完成.让第一个Lambda函数与 InvocationType:'Event'异步触发第二个Lambda函数,这将实现您想要的效果.

To support your use case, you could use SNS or an another intermediary AWS service like Kinesis, SQS, etc. But you could also do it with Lambda alone. Have the first Lambda function trigger a second Lambda function asynchronously with InvocationType: 'Event', this will achieve the effect you desire.

有关更多详细信息,请参见此帖子: https://stackoverflow.com/a/31745774/5705481

See this post for more details: https://stackoverflow.com/a/31745774/5705481

这篇关于响应然后继续使用AWS Lambda/API网关吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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