DVA-C03 practice question: Concurrency and performance tuning (2 of 3)
Troubleshooting and Optimization A free question from our original DVA-C03 practice exam. Try it, then open the answer to see why each option is right or wrong.
An image-resizing Lambda function is set to 256 MB of memory.
CloudWatch shows that it uses only about 150 MB, but each run is slow because the resize work is CPU-bound. The developer wants the function to finish faster, with the least effort and no change to the code's logic.
What should the developer do?
Choose one answer.
AA. Reduce the memory to 160 MB, because the function does not use the rest of it.
BB. Increase the function timeout so that it has more time to finish.
CC. Add reserved concurrency so that each invocation gets a dedicated CPU.
DD. Increase the memory setting, which also increases the CPU that Lambda allocates.
Show the answer and explanation
Answer: D
A. Wrong: Less memory also means less CPU, so the function would run more slowly. Memory use is not the same as the memory setting that controls CPU.
B. Wrong: A longer timeout only allows a run to last longer. It does not make the CPU-bound work finish sooner.
C. Wrong: Reserved concurrency limits how many invocations can run at once. It does not allocate CPU to any one invocation.
Lambda has no separate CPU setting, because CPU is allocated in proportion to memory. A CPU-bound function therefore often runs faster when its memory is raised, even if its memory use is low. Tools such as AWS Lambda Power Tuning can find the cheapest setting that gives the best speed.
Want more on Concurrency and performance tuning? The 5 full-length practice sets have 13 more Concurrency and performance tuning questions, 390 in all, none of them in the free exam. One payment of $14.99, no subscription. See the practice sets →