How nested data structures in DynamoDB make GetItem calls up to 34 times slower with Python and Lambda and what you can do about it
A methodical approach with a clear conclusion! Some suggestions:
-
In the Flat Payload try to use payload of random characters to avoid compression interfering with results.
-
Statistically speaking more is better. Increasing from 100 measurements to 10000 measurements would improve the tools you can use to investigate.
-
The increased number of measurements would allow for meaningful more usage of percentiles, e.g. 95th percentile measurements help rule out weird outliers in latency which are often responsible for significant variations in mean averages.
-
A clearer context of time taken for different parts of the process. I see in the conclusion that there are mentions of overheads and deserialisation taking percentages of runtime but without context that doesn’t mean much. Is that faster or slower than the ideal time taken? What impact do these differences have in terms of execution speed?
I know to avoid nested JSON with boto3 and DynamoDB now either way ![]()
Those are great suggestions - thank you! I’ll keep them in mind for the next one ![]()
Anecdotally I looked at some of the debug prints from boto3 to get a feeling about how long each step in the pipeline took, but I was too lazy to write a log-parser to do more calculations in that area and unfortunately there aren’t many hooks into boto3.
In general the actual time taken from the request to DynamoDB to the response being first registered in boto3 was minuscule, the bulk of the time it spent parsing and processing the data in Python.
Very interesting results. My only concern is the payload of flat objects. Since you put “XXXX…” as a payload, it’s possible that it was nicely compressed in transport, which resulted in lower latency. I would suggest making the tests with randomly generated data for both flat and nested structures.
But apart from that, other conclusions are interesting. As always, giving a Lambda more memory does magic with performance.