DVA-C03 · Domain 4: Troubleshooting and Optimization · 22% of the exam
Task 4.3: Optimize applications by using AWS services and features.
Making it faster and cheaper with evidence: provisioned concurrency, scaling, thread and connection pools, memory and compute sizing, SQS and SNS messaging, caching with ElastiCache, DAX and CloudFront, finding bottlenecks with CloudWatch, and AI tools that point out optimizations.
Study it
Concurrency: provisioned concurrency, scaling and connection pools
Try each one before opening the answer. Every option is explained, with the AWS documentation page that proves it.
Question 1 · choose 1
An image-resizing AWS Lambda function is configured with 512 MB of memory. Its REPORT log lines show about 4 seconds of duration and about 180 MB of maximum memory used, and profiling shows that the time is spent on CPU-bound image processing. The team wants shorter durations at the lowest cost that the data supports. What should the developer do?
AKeep 512 MB, because the function uses only 180 MB of its memory
BMeasure several memory sizes, such as with Lambda Power Tuning, and pick the best
CAdd provisioned concurrency so that each invocation starts on a warm environment
DRaise the function's ephemeral storage in /tmp to 10,240 MB
Show the answer and why
AKeep 512 MB, because the function uses only 180 MB of its memory
Incorrect
Max Memory Used shows memory is not the limit, but CPU scales with the memory setting, so a CPU-bound function can still get faster with more.
BMeasure several memory sizes, such as with Lambda Power Tuning, and pick the best
Correct
More memory brings an equivalent increase in CPU. Performance testing across memory sizes, which AWS suggests doing with Lambda Power Tuning, finds the setting with the best duration and cost.
CAdd provisioned concurrency so that each invocation starts on a warm environment
Incorrect
Provisioned concurrency cuts initialization latency. It does not add CPU to the work done inside the handler.
DRaise the function's ephemeral storage in /tmp to 10,240 MB
Incorrect
Ephemeral storage is disk space in /tmp. It does not change the CPU available to the function.
For Lambda, memory is the CPU knob; measure several settings instead of guessing, and use Max Memory Used and duration to judge them.
Publishers send order events to an Amazon SNS topic as JSON message bodies that contain a region field. They set no message attributes, and their code cannot change soon. An Amazon SQS queue subscribed to the topic feeds a service that handles only orders whose region is eu; it receives every message and discards about 90 percent of them. How should the developer reduce the wasted messages?
AAdd a filter policy on the subscription that matches a region message attribute
BTurn on raw message delivery for the SQS subscription
CSet the filter policy scope to MessageBody and match region equal to eu
DConvert the topic and the queue to FIFO so that messages arrive in order
Show the answer and why
AAdd a filter policy on the subscription that matches a region message attribute
Incorrect
The default filter policy scope is message attributes, and these messages carry none, so the subscription would receive nothing.
BTurn on raw message delivery for the SQS subscription
Incorrect
Raw message delivery strips the SNS metadata from each message. Every message is still delivered to the queue.
CSet the filter policy scope to MessageBody and match region equal to eu
Correct
With the MessageBody scope, SNS compares the filter policy with the message body, so only matching messages reach this subscription.
DConvert the topic and the queue to FIFO so that messages arrive in order
Incorrect
FIFO topics add ordering and deduplication. They do not reduce which messages a subscriber receives.
Subscription filter policies move filtering into SNS; set the scope to MessageBody when the deciding field is in the payload.
An Amazon CloudFront distribution caches product pages from an origin that picks the page language from the viewer's Accept-Language header. Some users receive pages in the wrong language: CloudFront serves whichever language version was cached first for that URL. The developer must fix this while keeping the cache hit ratio as high as possible. What should the developer do?
AAdd Accept-Language to an origin request policy for the cache behavior
BUse legacy cache settings that forward all headers to the origin
CCreate an invalidation for /* after every deployment of the site
DInclude the Accept-Language header in the cache key with a cache policy
Show the answer and why
AAdd Accept-Language to an origin request policy for the cache behavior
Incorrect
An origin request policy sends the header to the origin without adding it to the cache key, so one cached version per URL is still served to everyone.
BUse legacy cache settings that forward all headers to the origin
Incorrect
With legacy settings that forward all headers, CloudFront does not cache the objects and sends every request to the origin.
CCreate an invalidation for /* after every deployment of the site
Incorrect
An invalidation removes cached files before they expire. The next request in any language would again fill the cache for every viewer.
DInclude the Accept-Language header in the cache key with a cache policy
Correct
Values in the cache key decide which cached object a request matches, so each language gets its own cached copy, and only the one header is added.
Put exactly what changes the response into the cache key (here one header); send other values to the origin with an origin request policy.
After a release, the p99 latency of an AWS Lambda function doubled. To find the bottleneck, the team wants to see, per request, how much time goes to the function's own code compared with its calls to Amazon DynamoDB and to a partner HTTP API, and also how the function's CPU time and memory use per invocation have changed. Which TWO should the developer turn on? (Choose TWO.)
AX-Ray active tracing with OpenTelemetry instrumentation
BCloudWatch Lambda Insights for the function
CAn AWS CloudTrail trail that records the function's invocations
DAmazon Inspector scanning for the function and its layers
EAWS Config recording for the function's configuration
Show the answer and why
AX-Ray active tracing with OpenTelemetry instrumentation
Correct
Active tracing creates trace segments for invocations, and instrumented AWS SDK and HTTP client calls are recorded as spans that X-Ray shows as subsegments with their own timing.
BCloudWatch Lambda Insights for the function
Correct
Lambda Insights collects system-level metrics such as CPU time and memory, plus diagnostic information such as cold starts, for each invocation.
CAn AWS CloudTrail trail that records the function's invocations
Incorrect
CloudTrail records actions as events for auditing and governance. It does not break a request's time into its parts.
DAmazon Inspector scanning for the function and its layers
Incorrect
Inspector assesses functions and layers for security vulnerabilities. It does not measure latency or resource use.
EAWS Config recording for the function's configuration
Incorrect
AWS Config shows how resource configurations change over time. It does not show where request time is spent.
Traces show where time goes across calls; Lambda Insights shows how the function's CPU and memory behave. Together they locate a regression.
An IoT backend runs an AWS Step Functions Standard workflow for every incoming sensor message, millions per day. Each run has three short steps and finishes in under a second, and at-least-once processing is acceptable. Step Functions charges have become the largest part of the bill. What should the developer change?
AUse an Express workflow for this high-volume processing
BAdd Wait states between the steps to slow the workflow down
CTurn on AWS X-Ray tracing for the state machine
DSplit the workflow into three Standard workflows, one per step
Show the answer and why
AUse an Express workflow for this high-volume processing
Correct
Express workflows are meant for high-volume, event-processing workloads such as IoT data ingestion, with runs of up to five minutes.
BAdd Wait states between the steps to slow the workflow down
Incorrect
Waiting adds time to each run and does not lower the cost of the work.
CTurn on AWS X-Ray tracing for the state machine
Incorrect
Tracing helps analyze runs; it does not change what they cost.
DSplit the workflow into three Standard workflows, one per step
Incorrect
More Standard workflows add state transitions instead of removing them.
Choose Express workflows for short, high-rate event processing and Standard workflows for long-running, exactly-once orchestration.
A product listing page reads items from a DynamoDB table with GetItem and ConsistentRead set to true. Product data changes rarely, and showing data that is a second old is acceptable. Read costs are high. What change cuts read capacity use for these reads with no other code changes?
AUse transactional reads with TransactGetItems
BUse eventually consistent reads by leaving ConsistentRead false
CRead the items with a Scan and a filter instead
DStore each item twice so that reads can alternate between copies
Show the answer and why
AUse transactional reads with TransactGetItems
Incorrect
Transactional reads use two read units per 4 KB, more than strongly consistent reads.
BUse eventually consistent reads by leaving ConsistentRead false
Correct
An eventually consistent read of an item up to 4 KB uses half a read unit, half of a strongly consistent read.
CRead the items with a Scan and a filter instead
Incorrect
A Scan reads many more items than needed, which uses more capacity.
DStore each item twice so that reads can alternate between copies
Incorrect
Duplicate items double writes and storage, and each read still costs the same.
When stale-by-a-moment data is acceptable, eventually consistent reads halve read capacity use.
A machine learning preprocessing job on EC2 instances in one Availability Zone reads and writes millions of small temporary files in Amazon S3, and request latency now limits the job's speed. The files can be recreated if lost. Which storage option gives the lowest latency for this job?
AS3 Standard with S3 Transfer Acceleration turned on for the bucket
BS3 Intelligent-Tiering
CS3 Express One Zone, in the instances' Availability Zone
DS3 Standard-Infrequent Access
Show the answer and why
AS3 Standard with S3 Transfer Acceleration turned on for the bucket
Incorrect
Transfer Acceleration speeds up long-distance transfers, not requests from compute in the same Region.
BS3 Intelligent-Tiering
Incorrect
Intelligent-Tiering optimizes storage cost for changing access patterns, not request latency.
CS3 Express One Zone, in the instances' Availability Zone
Correct
S3 Express One Zone delivers consistent single-digit millisecond access and can be co-located with compute in one Availability Zone.
DS3 Standard-Infrequent Access
Incorrect
Standard-IA is for infrequently accessed data and adds retrieval charges for these frequent reads.
For latency-sensitive, frequently accessed data near compute, S3 Express One Zone gives the fastest access, with single-zone resilience.
A nightly Amazon ECS job on AWS Fargate re-renders thumbnails. Each task checkpoints its progress, so an interrupted task can simply be started again. The team wants to lower the job's compute cost without managing EC2 instances. What should the developer use?
AFargate with larger task sizes so that the job finishes sooner
BFargate Spot through a capacity provider for the job's tasks
CA self-managed EC2 Auto Scaling group for the cluster
DProvisioned concurrency on a Lambda function that starts the tasks
Show the answer and why
AFargate with larger task sizes so that the job finishes sooner
Incorrect
Larger tasks cost more per hour and may not reduce the total cost of the job.
BFargate Spot through a capacity provider for the job's tasks
Correct
Fargate Spot runs interruption-tolerant tasks at a discount on spare capacity, with a two-minute warning before interruption.
CA self-managed EC2 Auto Scaling group for the cluster
Incorrect
This means managing EC2 instances, which the team wants to avoid.
DProvisioned concurrency on a Lambda function that starts the tasks
Incorrect
This adds Lambda cost and does not change the price of the Fargate tasks.
Interruption-tolerant container workloads can run on Fargate Spot for lower cost.
An Amazon API Gateway REST API returns large JSON responses to mobile clients on slow networks. The clients already send an Accept-Encoding header that allows gzip. The developer wants smaller responses without changing the backend. What should the developer configure?
ATurn on stage caching with a longer TTL
BTurn on payload compression with a minimum compression size
CSwitch the API to an edge-optimized endpoint served through CloudFront
DRaise the stage's throttling limits
Show the answer and why
ATurn on stage caching with a longer TTL
Incorrect
Caching avoids backend calls but does not make the responses smaller.
BTurn on payload compression with a minimum compression size
Correct
API Gateway can compress response payloads for clients that accept a supported content coding once compression is enabled on the API.
CSwitch the API to an edge-optimized endpoint served through CloudFront
Incorrect
The endpoint type changes routing; it does not compress payloads.
DRaise the stage's throttling limits
Incorrect
Throttling controls request rates, not response size.
Enable compression on REST APIs to shrink large responses for clients that accept it.