AWS Developer DVA-C02 · Troubleshooting and Optimization · hard
An AWS Lambda function processes CPU-intensive image resizing and takes 4,000 ms (4.0 seconds) when configured with 512 MB of memory. When the developer increases the function's memory allocation to 2,048 MB (4x memory), the execution duration drops to 1,000 ms (1.0 second) because Lambda allocates vCPU power proportionally to memory (1,769 MB = 1 full vCPU). Since AWS Lambda duration billing is proportional to $\text{GB-seconds} = \text{Memory (GB)} \times \text{Duration (s)}$, how does the duration compute cost of 2,048 MB for 1.0 s compare to 512 MB for 4.0 s?
Published · Last updated · checked before publication — how we verify questions
Options
Answer: A. Identical compute cost (2.0 GB-seconds in both cases) with 4x faster latency
Calculate the billed GB-seconds for both configurations: - Configuration A (512 MB = 0.5 GB for 4.0 s): $0.5\text{ GB} \times 4.0\text{ s} = \mathbf{2.0\text{ GB-seconds}}$ - Configuration B (2,048 MB = 2.0 GB for 1.0 s): $2.0\text{ GB} \times 1.0\text{ s} = \mathbf{2.0\text{ GB-seconds}}$ Therefore, the duration compute cost is identical (2.0 GB-seconds, 0% cost increase) while the user experiences 4x faster response latency (1.0 s vs 4.0 s)!
Why the other options are wrong
- B. 4x higher compute cost (8.0 GB-seconds vs 2.0 GB-seconds) for 2,048 MB RAM — Because duration dropped by 4x (4.0 s to 1.0 s), the 4x memory increase cancels out (2.0 GB * 1.0 s = 2.0 GB-s).
- C. 16x higher compute cost because Lambda bills quadratically above 1,024 MB — AWS Lambda bills linearly per GB-second, not quadratically.
- D. 50% lower compute cost (1.0 GB-seconds vs 2.0 GB-seconds) for 512 MB — At 512 MB (0.5 GB) for 4 seconds, the function consumes 0.5 * 4 = 2.0 GB-seconds, not 1.0.
More Troubleshooting and Optimization questions
- A backend application uses Amazon ElastiCache for Redis in front of an Amazon RDS PostgreSQL database. Whenever the…
- A developer wants their AWS Lambda function to emit custom business metrics (OrderValue, CheckoutLatencyMs) alongside…
- An Amazon SQS standard queue has its default VisibilityTimeout set to 30 seconds. A worker EC2 instance polls the…
- A developer instruments a microservices payment API with the AWS X-Ray SDK. They want to attach custom key-value data…
All Troubleshooting and Optimization questions and the topic overview →
AWS and Amazon Web Services are trademarks of Amazon.com, Inc. PrepIQ Hub is not affiliated with, endorsed by, or sponsored by Amazon Web Services.