3

It's my first time with AWS Lambdas and DynamoDB, in Python.

I have my Table with only 474 records and a total weight of 890,4 kilobytes. The filtered selection is around only 380 records.

Quite small, but still it takes severall seconds to query. Really too slow.

I use a global secondary index, as it's supposed to be the way to filter the collection.

dynamo = boto3.resource('dynamodb', region_name='us-east-1',
     aws_access_key_id='my_key',
     aws_secret_access_key= 'my_key')

table = dynamodb.Table('my_table_name')

response = table.query(
    IndexName='venta_arge_ok-index',
    KeyConditionExpression=Key('venta_arge_ok').eq('True'))

When I test the Lambda in the console I get this figures:

  • Memory Size: 128 MB
  • Max Memory Used: 84

Run the test several times and got consistent times around 3 sec:

  • Duration: 3270.27 ms
  • Duration: 3069.37 ms
  • Duration: 3290.68 ms
  • Duration: 3013.34 ms
  • Duration: 3157.71 ms

What am I missing here? Thanks!

7
  • Did you try increasing the Lambda function timeout to see if it eventually succeeds? It could be timing out due to a network misconfiguration, if you deployed the Lambda function in a VPC. Commented Apr 7, 2022 at 20:10
  • @MarkB just updated the info, after increasing the timeouot. The query is just above 3 sec, but it seems still too much for such a small data collection. Or maybe it's normal and I'm confused? Commented Apr 7, 2022 at 21:29
  • 1
    Is Lambda function in the same AWS region as the DynamoDB table? us-east-1? Commented Apr 7, 2022 at 22:08
  • Typically no need for access key and secret key in a Lambda function. Assign the appropriate permissions to the IAM role you configure the Lambda function with. Commented Apr 7, 2022 at 22:37
  • 2
    Try increasing the function size as well. 128MB is so small. Take note that increasing memory size also increases CPU and network. Commented Apr 8, 2022 at 1:28

1 Answer 1

5

As Noel Llevares pointed, the issue was related with memory size (and it's related CPU power increase).

The same Lambda gave the following results for each memmory size tested:

128 MB - 3 sec 256 MB - 1.5 sec 512 MB - 0.75 sec 1024 MB - 0.4 sec

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.