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
posta un anno fa514 visualizzazioni
2 Risposte
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
ESPERTO
Uri
con risposta un anno fa
  • 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
con risposta un anno fa
ESPERTO
verificato un anno fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande