-70% execution time on a critical Lambda
Current role at DEPT · for a U.S. financial client
- Problem
- The heaviest Lambda ran a complex query that pulled a large amount of data over millions of records, and spent much of its time sorting them in the database.
- What I did
- Attacked it on several fronts: simplified the queries, reworked the joins, improved the indexes and rewrote the backend logic behind it from scratch. The rewrite also took the sorting out of the database: results are grouped in an object keyed by a small numeric ID (at most ~2,000 values), which JavaScript iterates in ascending order. Instead of an ORDER BY over millions of rows, only a couple of thousand groups end up sorted.
- Result
- From ~2.5 s to ~800 ms (600 ms in the best case): about 70% less execution time, plus lower CPU and memory usage, measured with CloudWatch and Splunk.