Why this topic matters
DVA-C02 tests whether you can spot performance and cost problems in code and infrastructure, then fix them using the right AWS feature rather than brute-force scaling. Exam questions usually describe a slow, expensive, or throttled app and ask what change fixes it cheapest/fastest.
Lambda optimisation
- Increasing memory also increases proportional CPU and network - a common fix for slow functions is simply raising memory, not just code changes.
- Provisioned Concurrency removes cold starts by keeping execution environments warm - use for latency-sensitive APIs.
- Keep the handler lean: initialise SDK clients and DB connections OUTSIDE the handler function so they persist across warm invocations.
- Lambda SnapStart (Java, and now other runtimes) caches a snapshot of an initialised execution environment to cut cold-start time drastically.
- Use environment variables and Lambda layers to share code/dependencies instead of duplicating in every deployment package - smaller packages deploy and cold-start faster.
DynamoDB optimisation
- Design partition keys for even distribution - hot partitions throttle throughput even under provisioned capacity.
- Use DynamoDB Accelerator (DAX) for microsecond read caching in read-heavy workloads.
- Switch to on-demand capacity mode for unpredictable traffic; use provisioned with auto scaling for steady, predictable traffic - cheaper at scale.
- Batch operations (BatchGetItem, BatchWriteItem) reduce round trips versus single-item calls.
- Use sparse indexes and projections to avoid pulling unnecessary attributes.
Caching layers
- ElastiCache (Redis/Memcached) offloads repeated reads from RDS/DynamoDB - biggest win for read-heavy relational workloads.
- CloudFront caches at edge locations, cutting origin load and latency for static and semi-static content; use cache behaviours and TTLs per path pattern.
- API Gateway has its own response caching (per stage, TTL configurable 0-3600s) - reduces backend Lambda/API invocations for repeated identical requests.
Code-level and messaging optimisation
- Use SQS to decouple and buffer bursty workloads so downstream services process at their own pace - prevents overload rather than requiring bigger instances.
- Use asynchronous invocation or Step Functions for long-running workflows instead of synchronous blocking calls.
- X-Ray traces reveal exactly which downstream call or segment is the bottleneck - always the first tool the exam expects you to reach for when diagnosing 'why is this slow'.
- CloudWatch Lambda Insights and Application Signals give system-level metrics (memory used vs allocated, cold start counts) to right-size functions.
Common mistakes
- Assuming more compute always fixes it - often it is a hot partition key or missing cache, not raw power.
- Forgetting SDK client re-use across invocations, causing needless re-initialisation cost on every warm call.
- Ignoring API Gateway/CloudFront caching and hitting the backend for identical repeated GET requests.
- Using on-demand DynamoDB for steady, predictable heavy traffic where provisioned + auto scaling is cheaper.
What is the single most common fix for a slow Lambda function on the exam?
Increase the memory allocation - CPU and network scale proportionally with memory
tap to reveal
How do you eliminate Lambda cold starts for a latency-sensitive API?
Enable Provisioned Concurrency
tap to reveal
What Lambda feature caches an initialised execution environment to speed up cold starts?
Lambda SnapStart
tap to reveal
Where should you initialise a DynamoDB or S3 SDK client in a Lambda function?
Outside the handler, so it is reused across warm invocations instead of recreated each time
tap to reveal
What DynamoDB feature gives microsecond read latency via in-memory caching?
DAX - DynamoDB Accelerator
tap to reveal
When should you choose DynamoDB on-demand capacity over provisioned?
When traffic is unpredictable or spiky; provisioned with auto scaling is cheaper for steady predictable load
tap to reveal
What causes DynamoDB throttling even when provisioned capacity looks sufficient?
A hot partition key - uneven key distribution concentrates traffic on one partition
tap to reveal
What is the TTL range for API Gateway stage-level response caching?
0 to 3600 seconds, configurable per stage
tap to reveal
What AWS service decouples a bursty producer from a slower downstream consumer?
SQS - it buffers messages so consumers process at their own pace
tap to reveal
What is the first tool to reach for when diagnosing why a distributed request is slow?
AWS X-Ray - it traces the request across services to isolate the bottleneck segment
tap to reveal
How do you cut repeated identical GET requests hitting your backend origin?
Use CloudFront edge caching or API Gateway response caching with an appropriate TTL
tap to reveal
What DynamoDB API calls reduce round trips for multiple items?
BatchGetItem and BatchWriteItem
tap to reveal
What is a common Lambda packaging mistake that slows cold starts?
Bundling large, unused dependencies instead of trimming the package or using Lambda layers for shared code
tap to reveal
Why use Step Functions or async invocation instead of synchronous Lambda calls for long workflows?
It avoids blocking callers and timeouts on long-running processes, letting each step run and retry independently
tap to reveal