how to increase the concurrency of lambda?

0

I have aise my Full account concurrency to 300 and set one function reserved concurrency to 200 but when i use code to test, I found Total concurrent executions at dashboard is always 20. which I think it should be 200. Below is the code I use. make_async_call is the entrance of the function

def _call_lambda(lambda_client, request):
    return lambda_client.invoke(
        FunctionName='OptimizerStrategyBT',
        InvocationType='RequestResponse',
        Payload=json.dumps(request).encode('UTF-8')
    )


limit = asyncio.BoundedSemaphore(100)


async def _make_one_call(lambda_client, request):
    async with limit:
        loop = asyncio.get_running_loop()
        opt_parms = request['optParams']
        logger.debug(f"submit lambda with {opt_parms}")
        res = await loop.run_in_executor(
            None, lambda: _call_lambda(lambda_client, request))
        logger.debug(f"get response from lambda with {opt_parms}")
        data = res['Payload'].read()
        payload = json.loads(data)
        body = json.loads(payload['body'])
        return body['result']


async def make_async_call(requests):
    config_lambda = Config(read_timeout=900)
    lambda_client = boto3.client('lambda',
                                 config=config_lambda)

    tasks = [_make_one_call(lambda_client, request) for request in requests]

    tas = await asyncio.gather(*tasks)
    return tas
질문됨 일 년 전514회 조회
2개 답변
0

Concurrency equals approximately number of invocations per second * duration of the function. For example, if you invoke the function 1000 times / sec, and it takes the function 1 second to run, the concurrency will be ~1000. However, if the function takes 100ms to run, your concurrency will be ~100.

If you want to test your function at higher concurrency you either need to increase the invocation rate or extend the function duration.

profile pictureAWS
전문가
Uri
답변함 일 년 전
  • my function will take about 60s. I send about 100 request in one seconds. but only 20 concurrency

0

It's possible that the Total concurrent executions you see on the dashboard is limited by your AWS account's overall concurrency limit, which might be set to 20. Even though you've set the reserved concurrency for one function to 200 and the account concurrency to 300, you won't be able to exceed the overall limit.

To check your account's overall concurrency limit, you can go to the "Concurrency" tab in the Lambda console and look for the "Account concurrency" section. If it's set to 20, you can request an increase in your account concurrency limit by following the instructions provided in the console.

Another possibility is that your function is experiencing throttling due to exceeding its own concurrency limit, which might be set to a lower value than the reserved concurrency you've configured. You can check the function's concurrency configuration by going to the function's "Concurrency" tab in the Lambda console.

If none of the above explanations seem to apply, you might want to look at your function's CloudWatch logs to see if there are any errors or messages related to concurrency.

hash
답변함 일 년 전
전문가
검토됨 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠