amazon-web-servicesaws-lambdaaws-sdkserverlessserverless-offline

Is it possible to test lambda limits with serverless-offline?


I would like to test aws lambda limits locally with serverless-offline. When I ran this code I expected to see an error (TooManyRequestsException) but all request are sent successfully. Am I missing something, or is it not possible to test aws limits with serverless-offline?


const lambda = new Lambda({
    apiVersion: '2031',
    region: 'us-east-1',

    endpoint: 'http://localhost:3002',
})

async function runMultipleLamdas() {
    const params = {
        // FunctionName is composed of: service name - stage - function name, e.g.

        FunctionName: 'simple-http-endpoint-dev-currentTime',

        InvocationType: 'RequestResponse',

        Payload: JSON.stringify({ data: 'foo' }),
    }

    Promise.all(Array(10000).fill(lambda.invoke(params).promise())).then(
        (values) => {
            console.log(values)
        }
    )
}

runMultipleLamdas()

Solution

  • serverless-offline doesn't simulate the AWS service quota for concurrent Lambda function executions. The AWS default quota value of 1,000 concurrent execution per region is a soft limit anyway, and can be raised through the AWS Service Quotas console.