Back to Blog

Monitoring, Troubleshooting & Optimization for the AWS Developer Associate (DVA-C02): CloudWatch, X-Ray, CloudTrail & Caching

Master Domain 4 of the DVA-C02: CloudWatch metrics and logs, X-Ray tracing, CloudTrail auditing, ElastiCache and DAX caching, and the retry/throttling patterns AWS loves to test.

By Sailor Team , July 3, 2026

Most people preparing for the AWS Certified Developer – Associate (DVA-C02) exam pour their energy into Domain 1 (development) and Domain 2 (security), then run out of steam by the time they reach Domain 4: Troubleshooting and Optimization. That’s a mistake. Domain 4 is worth 18% of your score — roughly one in every five questions — and it’s one of the most learnable domains on the exam, because it’s built on a handful of services and a small set of repeatable patterns.

This guide covers Domain 4 the way the DVA-C02 actually tests it: from the developer’s seat, debugging a serverless application that’s throwing errors, tracing a slow API call, or deciding where to add a cache. You’ll leave knowing exactly when to reach for CloudWatch, X-Ray, CloudTrail, ElastiCache, and DAX — and how to recognize the discriminating detail in a scenario question that makes two answers look correct.

What Domain 4 Actually Covers

The DVA-C02 blueprint splits Domain 4 into three ideas:

  • Assist in root cause analysis — read logs and metrics, trace requests, and interpret errors.
  • Instrument code for observability — emit custom metrics, structured logs, and traces so problems are visible.
  • Optimize applications — caching, right-sizing, and reducing latency and cost.

In practice, those map to five services and one recurring pattern. Learn these and Domain 4 becomes a source of easy points.

ConcernPrimary AWS service
Metrics, alarms, dashboardsAmazon CloudWatch
Application and platform logsCloudWatch Logs
Distributed request tracingAWS X-Ray
Who called which API, whenAWS CloudTrail
In-memory cachingElastiCache / DAX
Handling transient failuresExponential backoff with jitter

Amazon CloudWatch: Metrics, Logs, and Alarms

CloudWatch is the backbone of AWS observability, and the exam expects you to know its three pillars cold.

Metrics and namespaces

A metric is a time-ordered set of data points (CPU utilization, invocation count, error count). Metrics live in namespaces (for example AWS/Lambda, AWS/EC2) and are identified by dimensions — name/value pairs like FunctionName=checkout.

Two facts the DVA-C02 likes to test:

  • Standard resolution is one data point per minute; high-resolution metrics go down to one second. If a scenario needs sub-minute granularity, the answer is a high-resolution custom metric.
  • EC2 does not send memory or disk-space metrics by default. Those are guest-OS metrics, so you must install the CloudWatch agent to collect them. “Why can’t I see memory usage?” almost always means “the agent isn’t installed.”

You publish a custom metric with a single API call:

aws cloudwatch put-metric-data \
  --namespace "MyApp/Orders" \
  --metric-name "OrdersProcessed" \
  --unit Count \
  --value 1 \
  --dimensions Environment=prod

For high-throughput code, don’t call PutMetricData on every event — that’s an API call (and cost) per data point. Instead use the Embedded Metric Format (EMF): write a specially structured JSON log line, and CloudWatch automatically extracts metrics from it asynchronously. This is the exam’s preferred pattern for emitting custom metrics from Lambda at scale.

CloudWatch Logs

Logs are organized as log events → log streams → log groups. Key testable details:

  • Retention is “never expire” by default. If a question mentions runaway log-storage cost, the fix is to set a retention policy on the log group.
  • Metric filters turn log patterns into metrics. Count the number of ERROR lines, or extract a latency value, then alarm on it. This is how you alert on something that isn’t a native metric.
  • CloudWatch Logs Insights is the query engine for ad-hoc log analysis — the answer whenever a scenario asks you to “search across log groups” or “find the slowest requests.”
  • Subscription filters stream log data in near real time to Lambda, Kinesis Data Streams, or Firehose for centralized processing.

Alarms

A CloudWatch alarm watches a single metric (or a metric-math expression) and transitions between OK, ALARM, and INSUFFICIENT_DATA. Alarms can trigger SNS notifications, Auto Scaling actions, or EC2 actions. For the exam, remember that alarms evaluate over periods and evaluation periods — an alarm that fires too often usually needs a longer period or more evaluation periods, not a different metric.

AWS X-Ray: Tracing Distributed Applications

When a request flows through API Gateway → Lambda → DynamoDB and comes back slow, metrics tell you that it’s slow but not where. That’s what X-Ray is for: distributed tracing that produces a visual service map and per-request latency breakdowns.

Core vocabulary:

  • Segment — data about the work done by one service (your Lambda function).
  • Subsegment — a finer-grained slice, such as a single downstream call (a DynamoDB GetItem).
  • Trace — the end-to-end path of one request across all segments.
  • Annotations vs metadata — this is the classic X-Ray exam trap. Annotations are indexed and filterable; metadata is not indexed. If you need to search or group traces by a value (say, customerTier), use an annotation. If you just want extra context attached to the trace, use metadata.

Enabling X-Ray is mostly configuration, not code rewrites:

  • On Lambda, turn on active tracing in the function config and grant the AWSXRayDaemonWriteAccess permissions; Lambda runs the X-Ray daemon for you.
  • On EC2/ECS, you run the X-Ray daemon yourself, and the SDK sends segments to it over UDP on port 2000.
  • Sampling rules control cost — by default X-Ray records the first request each second plus a percentage of the rest, so you get representative traces without tracing 100% of traffic.
from aws_xray_sdk.core import xray_recorder

@xray_recorder.capture('process_order')
def process_order(order_id):
    # Indexed — you can filter traces by this in the console
    xray_recorder.current_subsegment().put_annotation('order_id', order_id)
    # Not indexed — context only
    xray_recorder.current_subsegment().put_metadata('payload', order_payload)

CloudTrail vs. CloudWatch: The Most Common Trap

If Domain 4 has one guaranteed question, it’s the CloudTrail-versus-CloudWatch distinction. They sound similar and both “log things,” so AWS uses them as distractors constantly.

CloudWatchCloudTrail
Answers the question”Is my application healthy / performant?""Who did what, when, from where?”
Data typeMetrics, logs, alarmsAPI call audit records
Typical usePerformance monitoring, alertingSecurity auditing, compliance, forensics
Example eventLambda error rate spikediam:CreateUser was called by Alice

The mental shortcut: CloudWatch is for operational health, CloudTrail is for auditing API activity. If the scenario asks “who deleted this resource” or “trace an unexpected configuration change,” the answer is CloudTrail. If it asks “why is latency high” or “alert me when errors spike,” the answer is CloudWatch. CloudTrail also distinguishes management events (control-plane operations like creating a bucket) from data events (high-volume operations like S3 object-level GetObject), which are disabled by default because of their volume.

Optimization: Caching Is King

The “Optimization” half of Domain 4 is mostly about caching — putting data closer to the consumer to cut latency and reduce load on your backend. Know the four main options and when each applies.

Amazon ElastiCache

ElastiCache is a managed in-memory cache with two engines:

  • Redis — richer data structures, replication, persistence, pub/sub, and Multi-AZ failover. Choose it when you need durability, sorting, or advanced structures.
  • Memcached — simple, multi-threaded, horizontally scalable. Choose it for a plain, high-throughput cache with no persistence needs.

The two caching strategies are frequently tested:

  • Lazy loading (cache-aside) — the app checks the cache first; on a miss it reads the database and writes the result back. Only requested data is cached, but the first read of any item is always a miss, and data can go stale.
  • Write-through — every write to the database also writes to the cache. Data is always fresh, but you cache data that may never be read, and writes are slower.

The balancing act — stale reads with lazy loading, wasted memory with write-through — is solved with a TTL so cached items eventually expire and refresh.

# Lazy loading pseudocode
value = cache.get(key)
if value is None:            # cache miss
    value = db.query(key)
    cache.set(key, value, ttl=300)
return value

DAX, CloudFront, and API Gateway caching

  • DynamoDB Accelerator (DAX) is a DynamoDB-specific, in-memory cache delivering microsecond reads. It’s API-compatible with DynamoDB, so you point your client at DAX with minimal code change. When a question says “read-heavy DynamoDB workload needing microsecond latency,” the answer is DAX — not ElastiCache.
  • CloudFront caches content at edge locations close to users. It’s the answer for reducing latency on static assets and cacheable API responses for a global audience.
  • API Gateway caching stores endpoint responses so repeated requests skip the backend integration entirely — a quick win for read-heavy, slowly-changing endpoints.

Handling Failures: Retries, Throttling, and Backoff

AWS APIs return transient errors, and Domain 4 wants to see that you handle them like a professional rather than hammering the service.

  • Throttling surfaces as HTTP 429 TooManyRequests, or service-specific errors like DynamoDB’s ProvisionedThroughputExceededException. The wrong answer is “increase capacity” as a reflex; the right answer usually involves retrying with exponential backoff and jitter.
  • Exponential backoff increases the wait between retries (1s, 2s, 4s, 8s…). Jitter adds randomness so many clients don’t retry in lockstep and cause a thundering herd. The AWS SDKs implement this automatically, but the exam expects you to name the pattern.
  • For asynchronous work, unprocessable messages should land in a dead-letter queue (DLQ) — for SQS, Lambda async invocations, and event source mappings — so failures are captured for inspection instead of silently lost.
import random, time

def call_with_backoff(fn, max_retries=5):
    for attempt in range(max_retries):
        try:
            return fn()
        except ThrottlingError:
            if attempt == max_retries - 1:
                raise
            sleep = (2 ** attempt) + random.uniform(0, 1)  # backoff + jitter
            time.sleep(sleep)

Optimizing Lambda Specifically

Because the DVA-C02 is serverless-heavy, Lambda-specific optimization shows up often:

  • Memory is the tuning dial. Lambda allocates CPU proportionally to memory, so raising memory can make a function run faster and sometimes cheaper. Right-sizing memory is a core optimization answer.
  • Cold starts hurt latency-sensitive functions. Use provisioned concurrency to keep execution environments warm; use SnapStart (for supported runtimes) to reduce initialization time.
  • Reserved concurrency both guarantees capacity for a critical function and caps it so it can’t exhaust the account’s concurrency pool.
  • Initialize SDK clients and database connections outside the handler so they’re reused across invocations instead of rebuilt every time.

Symptom-to-Solution Cheat Sheet

When a scenario question lands, match the symptom to the tool:

Scenario clueReach for
”Find who deleted the resource”CloudTrail
”Alert when error rate spikes”CloudWatch alarm on a metric
”Which downstream call is slow?”X-Ray service map / subsegments
”Search/filter traces by a field”X-Ray annotation (indexed)
“Count ERROR lines in logs”CloudWatch Logs metric filter
”Ad-hoc query across log groups”CloudWatch Logs Insights
”No memory metric for EC2”Install the CloudWatch agent
”Microsecond DynamoDB reads”DAX
”Global static content latency”CloudFront
”Read-heavy relational DB load”ElastiCache
”Throttling / 429 errors”Exponential backoff + jitter
”Reduce cold-start latency”Provisioned concurrency / SnapStart

How to Turn This Into a Passing Score

Domain 4 rewards recognition speed. The concepts here are finite, but the DVA-C02 phrases questions so two answers look plausible — CloudWatch vs. CloudTrail, ElastiCache vs. DAX, annotation vs. metadata — and only repeated exposure trains you to spot the deciding word. Reading why each wrong option is wrong is where the real learning happens.

The AWS Developer Associate (DVA-C02) Mock Exam Bundle is built for exactly that kind of practice. It runs full-length, domain-weighted exams in your browser, and every question ships with a detailed explanation that walks through the reasoning — why DAX beats ElastiCache for a DynamoDB workload, why a metric filter is the right way to alert on a log pattern — so you internalize the patterns instead of memorizing answers.

Pair this guide with our broader DVA-C02 exam guide for the full domain breakdown, the 8-week study plan to structure your prep, and the serverless guide and DynamoDB deep dive — since most Domain 4 questions build on the services those articles cover. When you’re ready to test yourself, work through a set of practice questions.

Frequently Asked Questions

How much of the DVA-C02 is Domain 4?

Domain 4, “Troubleshooting and Optimization,” is 18% of the scored content — the smallest of the four domains, but still roughly one question in five. Because it draws on a compact set of services, it offers a high return on study time.

What’s the difference between CloudWatch and CloudTrail on the exam?

CloudWatch monitors operational health (metrics, logs, alarms) — use it to answer “is my app healthy or fast?” CloudTrail records API activity for auditing — use it to answer “who did what, and when?” If a question is about a security or configuration change, it’s CloudTrail; if it’s about performance or errors, it’s CloudWatch.

When should I use X-Ray annotations vs. metadata?

Use annotations when you need to search, filter, or group traces by a value — annotations are indexed. Use metadata for extra context that you only need to read after opening a trace; metadata is not indexed and can’t be used to filter.

Is DAX just ElastiCache for DynamoDB?

Not quite. DAX is purpose-built for DynamoDB, API-compatible with it, and delivers microsecond read latency with minimal code change. ElastiCache is a general-purpose cache requiring you to manage the cache-population logic yourself. For a read-heavy DynamoDB workload, DAX is almost always the intended answer.

Why can’t I see EC2 memory usage in CloudWatch?

By default, EC2 sends only hypervisor-visible metrics like CPU, network, and disk I/O — not guest-OS metrics such as memory or disk-space utilization. To collect those, install and configure the CloudWatch agent on the instance.

What’s the right way to handle throttling errors?

Retry with exponential backoff and jitter. Backoff spaces out retries so you stop overwhelming the service; jitter adds randomness so many clients don’t retry simultaneously. The AWS SDKs do this automatically, but you should recognize the pattern by name and know that blindly increasing capacity is usually the wrong first move.

Key Takeaways

  • Domain 4 is 18% of the DVA-C02 and highly learnable — a small set of services and one retry pattern.
  • CloudWatch = health (metrics, logs, alarms); CloudTrail = audit (who called which API). Don’t confuse them.
  • Use EMF to emit custom metrics from high-throughput code, metric filters to alarm on log patterns, and Logs Insights for ad-hoc queries.
  • X-Ray annotations are indexed and filterable; metadata is not. Turn on active tracing for Lambda.
  • Match the cache to the need: DAX for DynamoDB microsecond reads, ElastiCache for relational load, CloudFront for edge, API Gateway caching for endpoints.
  • Handle transient failures with exponential backoff + jitter and route unprocessable messages to a DLQ.
  • Tune Lambda with the memory dial, provisioned concurrency for cold starts, and out-of-handler initialization.

Nail Domain 4 and you convert one of the exam’s most overlooked sections into reliable points. Combine this conceptual depth with realistic, explanation-rich mock exams, and you’ll walk into the DVA-C02 ready to diagnose any scenario they hand you.

Limited Time Offer: Get 80% off all Mock Exam Bundles | Sale ends in 7 days. Start learning today.

Claim Now