如何将AWS API Gateway超时设置为高于30秒? [英] How can I set the AWS API Gateway timeout higher than 30 seconds?

查看:92
本文介绍了如何将AWS API Gateway超时设置为高于30秒?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里读到我可以将Lambda函数超时设置为15分钟(

我如何才能使用持续15分钟的功能,但是网关却在30秒后超时?

解决方案

不幸的是,没有一种方法可以将API网关超时增加到超过29秒.这是网关的限制.您可以将lambda函数设置为更长的原因是因为可以将其插入到其他AWS资源中,这些资源允许更高的超时处理阈值.

您可以探索以下一些方法来解决此问题和/或使用限制:

  1. 将您的函数拆分为较小的函数,并将它们链接在一起以查看性能是否得到提高.在这样做之前,您可以使用AWS X-Ray调试该功能,并查看花费最多时间的部分来确定需要拆分的内容.

  2. 增加该功能使用的内存.更高的内存分配可能会导致执行速度更快.我以前使用过此选项,并且能够解决超时限制.

  3. 您可以仅使用AWS开发工具包调用"invoke()"来调用lambda函数,而不是使用API​​ Gateway.这将绕过超时阈值.

希望其中的一种或几种会有所帮助:)

I read here that I can set my Lambda function timeout for 15 minutes (https://aws.amazon.com/about-aws/whats-new/2018/10/aws-lambda-supports-functions-that-can-run-up-to-15-minutes/)

However, when I try to set API Gateway inside the Integration Request settings, it does not allow me to set it higher than 29seconds:

How can I have a function that lasts 15 minutes, but a Gateway that time outs after 30 seconds?

解决方案

Unfortunately there isn't a way to increase the API Gateway timeout to longer than 29 seconds. This is a limitation of the gateway. The reason you can set the lambda function longer is because this can be plugged into other AWS resources that allow a higher threshold for timeout processing.

Here's some options you could explore to get around this and/or work with the limitation:

  1. Split your function out into smaller functions and chain those together to see if you get a performance increase. Before doing so you could use AWS X-Ray to debug the function and see what part is taking the most time to target what needs to be split out.

  2. Increase the memory used by the function. Higher memory allocation could result in faster execution. I have used this option before and was able to work around timeout limits.

  3. Instead of using API Gateway you could just use AWS SDK to call 'invoke()' which will invoke your lambda function. This will bypass the timeout threshold.

Hopefully one or a mix of those will help out :)

这篇关于如何将AWS API Gateway超时设置为高于30秒?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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