简体   繁体   中英

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 || Memory - 10240MB (10GB)

The Synchronous API timeout limit is 30 seconds. My code executes for 4 seconds. The below code is a sample one that sleeps for 4 seconds. I'm using EFS mounted in Ubuntu for storing the packages as the limit of lambda deployment is 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. It works fine when executed one or two times but when executed more than 10 times it runs into a timeout error.
  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?

It sounds like the lambda function timeout is set too low. 在此处输入图像描述

https://console.aws.amazon.com/lambda/home - open the function and set the timeout under basic settings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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