AWS Developer Associate (DVA-C02) · 30% practice allocation

AWS DVA-C02: Development with AWS Services Practice Questions

5 free sample questions from the Development with AWS Services domain, with answers and explanations. The full DVA-C02 bank has 275 questions across 5 domains. Questions are scenario-based and written from the official AWS exam guide.

1.

A developer is optimizing an AWS Lambda function that queries Amazon DynamoDB for product catalog data. The data changes at most once per hour, but the Lambda function is invoked thousands of times per minute, causing high DynamoDB read costs. The developer wants to add an in-memory caching layer that requires minimal code changes and supports automatic cache invalidation based on TTL. Which service should the developer use?

  • A. Amazon ElastiCache for Redis, accessed directly from the Lambda function using the ElastiCache client library.
  • B. DynamoDB Accelerator (DAX), by replacing the DynamoDB client in the Lambda function with the DAX client.✓ Correct
  • C. Amazon CloudFront with a custom origin pointing to DynamoDB.
  • D. AWS AppSync with response caching enabled at the API level.
Explanation

DAX is a fully managed, DynamoDB-compatible in-memory cache that sits transparently between the application and DynamoDB. Switching from the standard DynamoDB SDK client to the DAX client is a minimal code change, and DAX automatically caches reads with a configurable TTL. When the TTL expires, DAX fetches fresh data from DynamoDB, providing automatic invalidation. ElastiCache for Redis requires the developer to write explicit cache-check, cache-populate, and TTL management logic, representing significantly more code changes, and it also requires VPC configuration for Lambda. CloudFront cannot directly query DynamoDB; it caches HTTP responses from origins and is not applicable here. AWS AppSync is a GraphQL API service and is not designed to cache DynamoDB reads invoked directly by a Lambda function.

2.

A developer is optimizing an Amazon API Gateway REST API that backs a high-traffic product search endpoint. The search results for any given query are identical for all users and change only when the product catalog is updated (roughly every 30 minutes). API Gateway response caching is enabled on the stage. A product manager reports that after a catalog update, users still see stale results for up to 30 minutes. The developer needs to ensure that cache entries are invalidated immediately after each catalog update. Which approach should the developer implement?

  • A. Enable per-key cache invalidation by having clients send the Cache-Control: max-age=0 header, and make the invalidation request after each catalog update from the backend pipeline.
  • B. Reduce the cache TTL on the API Gateway stage to 60 seconds so stale results expire quickly.
  • C. Programmatically flush the entire stage cache using the API Gateway FlushStageCache API action after each catalog update pipeline completes.✓ Correct
  • D. Call the API Gateway CreateDeployment API after each catalog update to redeploy the stage, which flushes the cache.
Explanation

The FlushStageCache API action (available via the AWS SDK or CLI as flush-stage-cache) immediately invalidates all cached responses for a given API Gateway stage. Calling this at the end of the catalog update pipeline ensures users receive fresh results right away. Reducing the TTL to 60 seconds would improve freshness slightly but does not solve the problem: updates could still be stale for up to 60 seconds and the average hit rate drops significantly, increasing Lambda invocation costs. Redeploying the stage with CreateDeployment does not flush the response cache; it creates a new deployment snapshot but cache entries persist. Per-key cache invalidation via Cache-Control: max-age=0 allows individual clients to bypass cache, but the backend pipeline cannot realistically issue a request on behalf of all users, and this approach requires the caller to have the execute-api:InvalidateCache permission — it is a client-side bypass, not a server-side flush.

3.

A developer is building an AWS Lambda function using a container image rather than a ZIP deployment package. The container image is 3 GB. The developer is concerned about cold start latency. Which TWO actions will MOST effectively reduce cold start latency for this function? (Select TWO)

  • A. Store the container image in an Amazon ECR repository in the same AWS Region as the Lambda function.
  • B. Enable Lambda Provisioned Concurrency for the function to pre-warm execution environments.✓ Correct
  • C. Reduce the container image size by using a minimal base image and multi-stage Docker builds to remove unused dependencies.✓ Correct
  • D. Enable Lambda SnapStart on the function.
  • E. Increase the Lambda function's memory allocation to the maximum (10,240 MB) to speed up image pulling.
  • F. Switch the function runtime to a compiled language (Go or Rust) to reduce initialisation time.
Explanation

Provisioned Concurrency pre-initialises execution environments so there is no cold start at all for the provisioned instances; this is the most direct solution. Reducing the container image size directly reduces the time Lambda spends pulling and extracting the image during a cold start, which is the dominant factor for large container-based functions. — Increasing memory allocation speeds up CPU-bound initialisation code slightly but does not significantly reduce image-pull time; the main bottleneck for a 3 GB image is I/O, not CPU. — The image should already be in the same region; this is a prerequisite, not an optimization. — Switching languages reduces handler init time but does not address the 3 GB image pull, which is the primary cold start driver for container images. — Lambda SnapStart is currently only available for Java runtimes (on supported Java versions), not for container image deployments.

4.

A developer is building a real-time stock-ticker dashboard. The frontend must receive price updates pushed from the server as they happen, without the client polling. The updates are unidirectional—only the server sends data to the client. Which AWS service and protocol combination is the SIMPLEST and MOST cost-effective choice?

  • A. Amazon API Gateway WebSocket API — clients maintain a persistent two-way connection.✓ Correct
  • B. Amazon API Gateway REST API with client polling every second using a caching TTL of 1 second.
  • C. Amazon API Gateway HTTP API with server-sent events (SSE) using a long-running Lambda integration.
  • D. AWS AppSync with real-time GraphQL subscriptions backed by AWS IoT.
Explanation

API Gateway WebSocket APIs support persistent, bidirectional connections and are well-suited for server-push scenarios. The server can push updates to connected clients at any time via the @connections callback URL. This is natively supported, simple to configure, and cost-effective at scale. — HTTP API with SSE is conceptually valid but Lambda has a maximum execution timeout of 15 minutes, making truly long-lived SSE connections impractical without a workaround. — AppSync subscriptions backed by IoT add unnecessary complexity and cost for a simple server-push use case. — Polling every second is neither push-based nor cost-effective; it generates high request volume and adds latency.

5.

A developer is designing an Amazon DynamoDB table to store IoT sensor readings. Each device publishes readings every second. The access pattern requires fetching all readings for a specific device within a given time range, sorted by timestamp. Which combination of primary key attributes should the developer choose?

  • A. Partition key: device_id; Sort key: timestamp.✓ Correct
  • B. Partition key: sensor_type; Sort key: device_id.
  • C. Partition key: timestamp; Sort key: device_id.
  • D. Partition key: reading_id (UUID); no sort key.
Explanation

Using device_id as the partition key co-locates all readings for a device on the same partition, and using timestamp as the sort key enables efficient range queries (e.g., between two timestamps) sorted in order — exactly matching the access pattern. Using a UUID as the partition key with no sort key prevents range queries and scatters items randomly. Using timestamp as the partition key causes hot-partition issues because many writes occur at the same second, and range queries by device become full scans. Using sensor_type as the partition key mixes readings from many devices, making device-specific queries very inefficient.

Test yourself across every DVA-C02 domain

The free DVA-C02 practice test mixes about 20 questions weighted like the exam. The full 275-question bank adds instant grading, flashcards and a timed mock exam.

Study this domain

Development with AWS Services study guide (DVA-C02) →

Other DVA-C02 domains

← All AWS Developer Associate study resources