简体   繁体   English

多次执行 AWS Lambda function 的 API 会引发“消息”:“端点请求超时”。 如何解决这个问题?

[英]Executing API of a AWS Lambda function multiple times throws “message”: “Endpoint request timed out”. How to resolve this problem?

Lambda Specs: Python Version - 3.7 || Lambda 规格:Python 版本 - 3.7 || Memory - 10240MB (10GB) Memory - 10240MB (10GB)

The Synchronous API timeout limit is 30 seconds.同步 API 超时限制为 30 秒。 My code executes for 4 seconds.我的代码执行 4 秒。 The below code is a sample one that sleeps for 4 seconds.下面的代码是一个休眠 4 秒的示例。 I'm using EFS mounted in Ubuntu for storing the packages as the limit of lambda deployment is 250MB.我正在使用安装在 Ubuntu 中的 EFS 来存储包,因为 lambda 部署的限制是 250MB。

import time
import json
import os
import sys 
sys.path.append("/mnt/access")
import math
import pandas as pd
import statsmodels.api as sm
import numpy as np
from datetime import datetime, timedelta
import sqlalchemy
from statsmodels.stats.outliers_influence import variance_inflation_factor

def lambda_handler(event, context):
    time.sleep(4)
  1. This is a simple code integrated with API Gateway.这是一个与 API 网关集成的简单代码。 It works fine when executed one or two times but when executed more than 10 times it runs into a timeout error.执行一到两次时它工作正常,但执行超过 10 次时会遇到超时错误。
  2. I tried to use Provisioned Concurrency but it is so expensive.我尝试使用预置并发,但它太贵了。 What to do to make it work all the time?怎么做才能让它一直工作? Any Alternatives?有什么选择吗?

What is the AWS Lambda function timeout set at? AWS Lambda function 超时设置是多少?

It sounds like the lambda function timeout is set too low.听起来 lambda function 超时设置得太低。 在此处输入图像描述

https://console.aws.amazon.com/lambda/home - open the function and set the timeout under basic settings. https://console.aws.amazon.com/lambda/home - 打开 function 并在基本设置下设置超时。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM