This is the easy code that I am trying in AWS Lambda:
from boto3 import client
s3_client = client('s3')
def lambda_handler(event, context):
list_buckets = s3_client.list_buckets()['Buckets']
for bucket in list_buckets:
s3_client.get_bucket_location(Bucket=bucket['Name'])
The durations by configuration are:
Duration: 6863.23 ms Billed Duration: 6864 ms Memory Size: 128 MB Max Memory Used: 82 MB Init Duration: 455.51 ms
Duration: 1839.79 ms Billed Duration: 1840 ms Memory Size: 10240 MB Max Memory Used: 82 MB Init Duration: 402.88 ms
I know the more lambda memory, the more the CPU but I do not understand… Why these differences? I thought the majority of the duration time was the API calls/responses and this time must be fixed and independent of the lambda memory.
Maybe the s3_client.get_bucket_location
call does a lot of things (in memory things) after the API response is received?