All practice questions

1542 questions

Question 401Question

A developer is implementing a serverless worker application. An Amazon SQS standard queue triggers an AWS Lambda function to process inventory updates. The Lambda function has its timeout configured to 45 seconds45\text{ seconds}, and the SQS queue has a visibility timeout of 30 seconds30\text{ seconds}. During peak hours, the developer notices that some inventory updates are processed multiple times, resulting in incorrect stock counts in the database. Which configuration change will resolve this issue?

Show answer & explanation

Answer: Increase the Amazon SQS queue's visibility timeout to at least 270 seconds270\text{ seconds} to meet the recommended value of at least 6 times6\text{ times} the Lambda function's timeout.

Answer

Increase the Amazon SQS queue's visibility timeout to at least 270 seconds270\text{ seconds} to meet the recommended value of at least 6 times6\text{ times} the Lambda function's timeout.
The correct answer is to increase the Amazon SQS queue's visibility timeout to at least 270 seconds270\text{ seconds}. When an Amazon SQS queue is configured as an event source for an AWS Lambda function, the recommended visibility timeout is at least 6 times6\text{ times} the timeout of the Lambda function. Since the Lambda function timeout is 45 seconds45\text{ seconds}, the SQS queue's visibility timeout must be set to at least 270 seconds270\text{ seconds} (6×45 seconds6 \times 45\text{ seconds}). If the visibility timeout is shorter than the Lambda execution time, SQS may make the messages visible to other concurrent Lambda invocations while the original execution is still running, resulting in duplicate processing.

Step-by-Step Solution

1
Analyze the relationship between SQS visibility timeout and Lambda function timeout.
Identify that when using SQS as an event source, the SQS visibility timeout must be set to at least 6 times6\text{ times} the Lambda function's timeout.
This buffer prevents SQS from redelivering a message while the Lambda function is still actively processing the batch or performing retries.
2
Calculate the required minimum SQS visibility timeout based on the configuration.
Multiply the Lambda timeout of 45 seconds45\text{ seconds} by 66, yielding 270 seconds270\text{ seconds} (45 s×6=270 s45\text{ s} \times 6 = 270\text{ s}).
This determines the minimum safe duration during which the message remains invisible to other consumers.
3
Evaluate the proposed options against the calculated value.
Increasing the SQS queue's visibility timeout to at least 270 seconds270\text{ seconds} is the correct configuration change.
It aligns with the AWS-recommended architecture to eliminate duplicate processing caused by premature visibility timeout expiration.

Key Concept

SQS visibility timeout configuration when integrated as a Lambda event source
Estimated Time:1m 30s
Question 402Question

An image processing application uses an Amazon SQS standard queue to decouple a web front-end from EC2 worker instances. The worker instances retrieve messages from the queue, download a high-resolution image from Amazon S3, perform CPU-intensive image compression, and upload the processed image back to S3. Currently, the SQS queue's default visibility timeout is configured to 3030 seconds. However, for large images, the compression process can take up to 22 minutes (120120 seconds). As a result, other worker instances frequently retrieve the same image message while it is still being processed by the first worker, leading to duplicate processing. Which of the following actions should the developer take to resolve this issue? (Select TWO.)

Select all that apply

Show answer & explanation

Answer: Increase the default visibility timeout of the SQS queue to 150150 seconds.; Modify the worker application code to call the ChangeMessageVisibility API, extending the visibility timeout while the image is being processed.

Answer

Increase the default visibility timeout of the SQS queue to 150150 seconds, and modify the worker application code to call the ChangeMessageVisibility API to extend the visibility timeout while the image is being processed.
Increasing the default visibility timeout to 150150 seconds ensures the message remains hidden from other consumers for the duration of the 120120-second processing window. Alternatively, using the ChangeMessageVisibility API dynamically extends the visibility timeout during active processing, which is ideal for workloads with variable processing times. Both approaches prevent other workers from retrieving the message concurrently.

Step-by-Step Solution

1
Analyze the relationship between the processing duration and the queue's default visibility timeout.
The processing time (up to 120120 seconds) exceeds the default visibility timeout (3030 seconds), meaning the message becomes visible to other workers while processing is still ongoing.
To prevent duplicate processing, the visibility timeout must be longer than the maximum processing time.
2
Evaluate SQS queue configurations and API actions that can extend the visibility window.
Increasing the default visibility timeout on the queue (e.g., to 150150 seconds) or calling the ChangeMessageVisibility API during runtime can keep the message hidden.
These solutions directly keep the message invisible to other workers while the active worker completes the task.
3
Eliminate incorrect options that do not affect the post-retrieval visibility window.
DelaySeconds affects initial message ingestion delay, ReceiveMessageWaitTimeSeconds controls polling duration (max 2020 seconds), and DLQ configuration with maxReceiveCount of 11 prematurely discards messages.
These options represent common SQS configuration misconceptions and do not solve the processing timeout issue.

Key Concept

Amazon SQS Message Visibility Timeout management
Question 403Question

A developer is designing a subscription management system using Amazon DynamoDB. The table stores customer subscriptions with `SubscriptionID` as the partition key. Over 99%99\% of the subscriptions are in the "Active" status, while less than 1%1\% are in the "PendingCancellation" status. The developer needs to build a dashboard that lists all subscriptions in the "PendingCancellation" status. Which two actions should the developer take to retrieve this data in the most cost-effective and performant manner?

Select all that apply

Show answer & explanation

Answer: Create a Global Secondary Index (GSI) with a sparse attribute (such as `CancellationDate`, which is only populated on subscriptions with a pending cancellation status) as the partition key.; Use the `Query` API operation to retrieve the subscriptions from the global secondary index.

Answer

Create a Global Secondary Index (GSI) with a sparse attribute as the partition key and use the Query API operation to retrieve the subscriptions from the index.
The correct approach is to create a Global Secondary Index (GSI) with a sparse attribute (like a cancellation date that is only present for subscriptions pending cancellation) as the partition key, and then use the Query API on this index. In DynamoDB, an item is only written to a GSI if the GSI's partition key attribute is present in that item. Since only 1%1\% of subscriptions have this attribute, the index size remains very small, saving storage and write costs. Querying this GSI directly retrieves only the matching items, making the operation extremely efficient.

Step-by-Step Solution

1
Analyze the distribution of data and access patterns.
Since only less than 1%1\% of the data is in the target 'PendingCancellation' status, performing queries or scans on the main table is inefficient.
Scanning the main table requires reading all items, which is expensive and slow.
2
Design a sparse index strategy to filter data at the database level.
Creating a Global Secondary Index (GSI) with a partition key attribute that is only populated for the target status (a sparse attribute) ensures that the GSI only contains the relevant items.
This avoids indexing the 99%99\% active subscriptions, reducing GSI storage and write costs.
3
Select the correct API operation to retrieve the indexed items.
Using the Query API operation on the GSI's partition key retrieves only the target items directly.
Query operations are highly efficient and only consume Read Capacity Units (RCUs) proportional to the returned items.

Key Concept

Optimizing DynamoDB data retrieval for sparse attributes using Global Secondary Indexes (GSIs) and the Query API rather than Table Scans.
Question 404Question

A developer is testing a Node.js-based AWS Lambda function that processes incoming telemetry data. To analyze cold starts and container lifetime, the developer declares a variable outside the handler function to count the number of times the container has processed an event:

javascript
let localEventCount = 0;

exports.handler = async (event) => {
localEventCount++;
console.log("Events processed: " + localEventCount);
};

During a load test with high concurrent traffic, the developer notices that some log entries show sequential numbers (e.g., 1,2,31, 2, 3), while other concurrent logs show a value of 11 at the same timestamp.

Which of the following statements explains this behavior?

Show answer & explanation

Answer: AWS Lambda spins up separate, concurrent execution environments to handle concurrent requests. The global variable is only persistent within a specific execution environment, meaning concurrent invocations will increment independent counters.

Answer

AWS Lambda spins up separate, concurrent execution environments to handle concurrent requests. The global variable is only persistent within a specific execution environment, meaning concurrent invocations will increment independent counters.
The correct answer is correct because AWS Lambda initializes multiple independent execution environments (containers) to handle concurrent events. Since variables declared outside the handler function are local to the execution environment, they are only shared during sequential invocations on the same container. Under concurrent load, different containers execute concurrently, each maintaining its own independent instance of the global variable.

Step-by-Step Solution

1
Analyze how variables declared outside the Lambda handler function are scoped and maintained.
Variables declared outside the handler are initialized when the Lambda execution environment is first created (cold start) and persist across subsequent invocations that reuse the same environment (warm starts).
This establishes the basic execution context lifecycle behavior of AWS Lambda.
2
Evaluate the behavior of the system under concurrent load.
To process concurrent requests, AWS Lambda spins up multiple independent execution environments. Each environment runs in isolation with its own memory space and copy of the global variable.
This explains why concurrent requests might see independent event counts starting from 11.
3
Differentiate between variable persistence within a single container and synchronization across containers.
AWS Lambda does not synchronize memory state or global variables across separate execution environments.
This identifies the root cause of the behavior: sequential requests on the same environment see incrementing counts, while parallel requests on new environments start at 11.

Key Concept

AWS Lambda Execution Context Reuse and Concurrency Dynamics
Question 405Question

A developer is designing a classroom reservation system. The reservation records are stored in an Amazon DynamoDB table. The application needs to support queries to retrieve reservations for a specific classroom by date. To optimize performance and control cost, the developer must select the appropriate key schema and query strategy.

Which design option represents the most efficient and standard-compliant configuration for this requirement?

Show answer & explanation

Answer: Design the table with ClassroomID as the partition key and ReservationDate as the sort key, and invoke the Query action with a key condition expression while authenticating via the default credential provider chain.

Answer

Design the table with ClassroomID as the partition key and ReservationDate as the sort key, and invoke the Query action with a key condition expression while authenticating via the default credential provider chain.
Designing the table with ClassroomID as the partition key and ReservationDate as the sort key allows the application to perform highly efficient Query operations. Querying with a key condition expression avoids scanning the entire table, minimizing consumed Read Capacity Units (RCUs) and latency. Authenticating via the default credential provider chain is the AWS-recommended security best practice as it avoids hardcoding credentials.

Step-by-Step Solution

1
Analyze the query pattern to determine the partition key and sort key.
The application retrieves reservations for a specific classroom by date, which maps to ClassroomID as the partition key (equality comparison) and ReservationDate as the sort key (comparison/range filter).
This key schema enables targeted lookups instead of scanning the entire database.
2
Evaluate the read API options (Query vs Scan).
Query retrieves only the items that match the key condition, whereas Scan reads every item in the table.
Query is much more cost-effective and performs faster than Scan.
3
Determine the secure authentication method for the AWS SDK client.
The default credential provider chain automatically retrieves credentials from the environment, ECS task role, or EC2 instance profile, avoiding hardcoded keys.
This follows AWS security best practices and prevents credential exposure.

Key Concept

Selecting the correct DynamoDB key schema and read API operation (Query vs Scan) while maintaining secure AWS SDK authentication.
Question 406Question

A developer is designing a backend for a retail checkout system. Order placement events must be processed in the exact sequence they are submitted for each customer. Additionally, the system must filter out duplicate checkout submissions if a customer accidentally clicks the "Submit Order" button multiple times within a 55-minute window. Which SQS FIFO queue configuration and message attributes should the developer use to meet these requirements?

Show answer & explanation

Answer: Use an SQS FIFO queue. Set the MessageGroupId to the customer ID to ensure sequential processing per customer, and set the MessageDeduplicationId to a unique transaction ID to prevent duplicate order processing within the 55-minute deduplication window.

Answer

Use an SQS FIFO queue, setting the MessageGroupId to the customer ID to maintain ordering per customer, and setting the MessageDeduplicationId to a unique transaction ID to prevent duplicates within the 5-minute window.
Amazon SQS FIFO queues ensure that messages are processed exactly once and in the order they are sent. By setting the MessageGroupId to the customer ID, ordering is guaranteed specifically for each customer, allowing concurrent processing for different customers. Setting the MessageDeduplicationId to a unique transaction ID ensures that any retry containing the same ID within the 55-minute deduplication window is automatically discarded by SQS.

Step-by-Step Solution

1
Determine the required queue type to handle ordering and deduplication.
Amazon SQS FIFO queue is selected.
Standard queues do not guarantee message ordering or deduplication, whereas FIFO queues guarantee first-in-first-out delivery and exactly-once processing.
2
Configure the grouping strategy to ensure messages are ordered per customer.
Set the MessageGroupId message attribute to the customer ID.
SQS FIFO queues group messages by MessageGroupId. Messages within the same group are processed in strict sequential order, allowing parallel processing across different groups.
3
Configure the deduplication strategy to filter out retries within a 55-minute window.
Set the MessageDeduplicationId message attribute to a unique transaction ID.
Amazon SQS FIFO queues use the MessageDeduplicationId to identify and discard duplicate messages sent within a 55-minute deduplication window.

Key Concept

Amazon SQS FIFO queue deduplication and ordering mechanics
Estimated Time:1m 30s
Question 407Question

A serverless application contains multiple AWS Lambda functions. During peak traffic periods, a background data-processing function triggered by Amazon S3 events scales rapidly and consumes all of the available execution concurrency in the AWS Region. This causes customer-facing Lambda functions integrated with Amazon API Gateway to fail with throttling errors. Which configuration should a developer apply to prevent the background function from exhausting the available regional concurrency?

Show answer & explanation

Answer: Configure a reserved concurrency limit on the background data-processing Lambda function.

Answer

Configure a reserved concurrency limit on the background data-processing Lambda function.
The correct answer is to configure a reserved concurrency limit on the background data-processing Lambda function. Setting a reserved concurrency limit on a Lambda function acts as a maximum concurrency cap (preventing it from scaling beyond that number and exhausting the region's shared unreserved pool) and also guarantees that the specified concurrency is dedicated to that function.

Step-by-Step Solution

1
Analyze the cause of the throttling error.
The background data-processing Lambda function is scaling excessively and consuming all regional unreserved concurrency, leaving no execution capacity for other functions.
AWS Lambda pools concurrency region-wide by default, meaning a high-scale function can starve other functions of execution slots.
2
Evaluate options for limiting concurrency consumption of a specific function.
Reserved concurrency allows developers to define a hard limit on the concurrency of a specific Lambda function.
By setting a reserved concurrency limit, the function cannot scale past that limit, thereby protecting the shared unreserved concurrency pool.
3
Differentiate reserved concurrency from provisioned concurrency.
Reserved concurrency acts as a ceiling to limit scale-out, whereas provisioned concurrency keeps environments warm and ready for expected load but does not cap execution growth.
Choosing reserved concurrency directly solves the problem of background function over-scaling.

Key Concept

Managing concurrency in AWS Lambda to prevent account-level resource starvation.
Question 408Question

A developer is building a personal finance application that tracks user transactions. The transactions are stored in an Amazon DynamoDB table with AccountID as the partition key and TransactionTimestamp as the sort key. A dashboard needs to display all transactions for a specific account that are categorized as 'Entertainment' to analyze spending habits. The developer wants to retrieve this data with the lowest latency and minimal Read Capacity Unit (RCU) consumption. Which two strategies should the developer implement to meet these requirements? (Choose two.)

Select all that apply

Show answer & explanation

Answer: Create a Global Secondary Index (GSI) with AccountID as the partition key and Category as the sort key, then use the Query API on the GSI.; Configure the GSI projection to include only the required attributes needed for the dashboard, such as TransactionTimestamp and Amount.

Answer

To optimize the data retrieval, the developer should create a Global Secondary Index (GSI) with AccountID as the partition key and Category as the sort key, querying this index directly. Furthermore, the GSI should project only the required attributes needed for the dashboard instead of all attributes to minimize RCU consumption.
To achieve the lowest latency and minimal RCU consumption, the developer should create a Global Secondary Index (GSI) with AccountID as the partition key and Category as the sort key. This allows the application to run targeted Query operations directly on the index instead of scanning. To optimize performance and cost further, the GSI projection should be limited to only the required attributes needed for the dashboard, which minimizes the amount of data transferred and read capacity consumed.

Step-by-Step Solution

1
Evaluate the query patterns on the base table.
The base table's primary key structure (AccountID + TransactionTimestamp) does not allow efficient filtering by Category.
Querying by a non-key attribute like Category on the base table would require scanning the entire table or partition, which is inefficient.
2
Design a secondary index to support the query pattern.
A Global Secondary Index (GSI) is created with AccountID as the partition key and Category as the sort key.
This allows the application to perform high-performance Query operations directly on the specific partition and sort key.
3
Optimize the index projection settings.
A projection type of INCLUDE or KEYS_ONLY is selected to only project the attributes needed by the dashboard (e.g., TransactionTimestamp and Amount).
Projecting fewer attributes keeps the GSI size small and minimizes RCU usage during queries.

Key Concept

Optimizing DynamoDB queries and read throughput using Global Secondary Indexes (GSIs) and projection attributes.
Question 409Question

A developer is designing a messaging architecture for an online medical clinic's appointment scheduling platform. When a patient schedules or updates an appointment, the system must broadcast this event to two downstream services:

1. A reminder service that sends SMS and email notifications to patients. This service does not require messages to be processed in order.
2. A calendar synchronization service that must process events in the exact chronological order they occurred to prevent scheduling conflicts.

Which combination of actions should the developer take to implement this architecture? (Select TWO.)

Select all that apply

Show answer & explanation

Answer: Publish the appointment events to an Amazon SNS FIFO topic.; Subscribe an Amazon SQS FIFO queue for the calendar synchronization service and a standard Amazon SQS queue for the reminder service to the Amazon SNS FIFO topic.

Answer

To implement this architecture, the developer should publish the appointment events to an Amazon SNS FIFO topic, and subscribe an Amazon SQS FIFO queue for the calendar synchronization service and a standard Amazon SQS queue for the reminder service to the SNS topic.
The correct solution involves publishing events to an Amazon SNS FIFO topic and subscribing both an Amazon SQS FIFO queue (for the calendar service) and a standard Amazon SQS queue (for the reminder service). SNS FIFO topics preserve message ordering and support fanout to both SQS FIFO queues (which guarantee order) and standard SQS queues (which handle unordered delivery).

Step-by-Step Solution

1
Determine the topic type needed to support ordered delivery to downstream consumers.
Identify that an Amazon SNS FIFO topic is required because standard SNS topics do not support FIFO ordering or subscription of SQS FIFO queues.
An SNS FIFO topic ensures message ordering is preserved from the publisher and allows delivery to SQS FIFO queues.
2
Determine the queue types needed for each downstream service based on their ordering requirements.
Select an SQS FIFO queue for the calendar synchronization service (which requires strict chronological ordering) and a standard SQS queue for the reminder service (which does not require ordering).
SQS FIFO queues guarantee exactly-once processing and ordering, while standard SQS queues provide higher throughput for unordered tasks.
3
Subscribe both queues to the SNS FIFO topic.
Both the SQS FIFO queue and the standard SQS queue are successfully subscribed to the SNS FIFO topic.
Amazon SNS FIFO topics are fully compatible with both SQS FIFO and standard SQS queue subscriptions, enabling a fanout architecture that services both ordered and unordered consumers.

Key Concept

Amazon SNS FIFO and SQS FIFO integration (Fanout pattern)
Question 410Question

A developer is building a serverless order-processing application. An AWS Lambda function is triggered by an Amazon SQS queue. The function must connect to an Amazon RDS PostgreSQL database located in a private VPC subnet to retrieve customer data, and call a third-party payment gateway API over the internet to authorize transactions. The developer also wants to minimize connection latency to the database. Which combination of configurations must the developer implement to meet these requirements? (Select two.)

Select all that apply

Show answer & explanation

Answer: Deploy the Lambda function in the private subnets of the VPC and configure a NAT Gateway in a public subnet with appropriate route tables to allow outbound internet traffic.; Instantiate the database client connection pool outside of the Lambda handler function.

Answer

To meet the requirements, the developer must deploy the Lambda function in private subnets using a NAT Gateway in a public subnet for outbound internet connectivity, and instantiate the database connection client outside of the handler function to reuse connections.
Deploying the Lambda function in private subnets with a NAT Gateway in the public subnet allows both outbound internet access for API calls and secure local access to the private RDS database. Initializing the database connection pool outside the handler ensures that the connections are reused across events due to execution context recycling, optimizing latency.

Step-by-Step Solution

1
Configure the Lambda function VPC settings.
The Lambda function is placed in the private subnets of the VPC.
This allows the Lambda function to have network access to the RDS database residing in the private subnet.
2
Set up a NAT Gateway in the public subnet.
Outbound route tables in the private subnets point to the NAT Gateway.
This enables the Lambda function in the private subnet to securely reach the third-party payment gateway over the internet.
3
Declare and initialize the database connection client outside the event handler function.
The database connection pool persists in the global execution context across subsequent invocations.
This reduces connection setup time and latency by reusing existing connections instead of establishing a new one for every event.

Key Concept

AWS Lambda VPC networking and execution context reuse
Question 411Question

A developer is building a document management system for a consulting firm where client engagement files are stored in an Amazon DynamoDB table. The table is structured with `EngagementID` as the partition key and `FileID` as the sort key. The table size is approximately 50 GB50\text{ GB}. The developer needs to implement a feature that retrieves all files for a specific engagement that have a status of 'NeedsReview'. Which approach represents the most performant and cost-effective method to retrieve these records?

Show answer & explanation

Answer: Perform a Query operation specifying the EngagementID in the KeyConditionExpression and a FilterExpression for the Status attribute.

Answer

Perform a Query operation specifying the EngagementID in the KeyConditionExpression and a FilterExpression for the Status attribute.
The correct approach uses the Query API operation. Because the partition key (EngagementID) is known, Query restricts the search to only the partition containing the target files, drastically reducing the number of Read Capacity Units (RCUs) consumed. Applying a FilterExpression further narrows down the returned items to only those with the status 'NeedsReview' without scanning the rest of the table.

Step-by-Step Solution

1
Identify the primary key structure of the table.
The table has a composite primary key consisting of EngagementID as the partition key and FileID as the sort key.
Knowing the primary key structure helps determine if a Query operation can be performed instead of a Scan.
2
Determine the query path for retrieving a specific engagement's files.
Since the partition key (EngagementID) is known, a Query operation can target a specific partition directly.
Using Query is much more efficient than Scan because DynamoDB only reads items that match the specified partition key value.
3
Apply filtering for the status attribute.
Use a FilterExpression to evaluate the Status attribute, ensuring only files with 'NeedsReview' are returned to the client.
This reduces the payload size sent over the network, while KeyConditionExpression keeps the read operations localized to the partition.

Key Concept

Using Query instead of Scan operations to retrieve items from a specific partition in Amazon DynamoDB to optimize read performance and cost.
Estimated Time:1m 30s
Question 412Question

A developer is designing a serverless notification architecture for an e-commerce platform. When an order is placed, details must be sent to three downstream systems: fulfillment (which only processes 'Express' orders), marketing (which tracks all orders), and analytics (which only processes orders with a value of $100 or more). The developer wants to minimize costs and operational overhead, and avoid having downstream systems filter out irrelevant messages. Which architecture should the developer implement?

Show answer & explanation

Answer: Publish messages to a single Amazon SNS topic. Create three Amazon SQS queues, one for each downstream system, and subscribe them to the SNS topic. Apply SNS subscription filter policies on the fulfillment and analytics queue subscriptions to filter by message attributes, and leave the marketing subscription unfiltered.

Answer

Publish messages to a single Amazon SNS topic, subscribe three Amazon SQS queues to it, and apply SNS subscription filter policies to route specific messages to the fulfillment and analytics queues while leaving the marketing queue unfiltered.
The correct architecture uses the Amazon SNS fanout pattern combined with subscription filter policies. By publishing all events to a single SNS topic and subscribing separate SQS queues for each downstream service, you achieve complete decoupling. Applying SNS subscription filter policies directly on the subscriptions ensures that only matching messages are sent to the fulfillment and analytics SQS queues, eliminating the need for consumer-side filtering. This minimizes SQS request costs and operational overhead.

Step-by-Step Solution

1
Identify the routing requirements for the messages (one consumer needs all messages, while the other two need specific subsets based on string and numeric attributes).
Determined that a fanout pattern is required to deliver messages to multiple independent destinations.
This establishes that a single queue cannot be shared directly, as consumers would compete for messages rather than receiving clones of the messages.
2
Analyze how to filter messages before they reach the consumer systems to meet the cost and overhead minimization requirements.
Selected SNS subscription filter policies, which natively support string matching (for Express shipping) and numeric range matching (for order value >= 100).
SNS subscription filter policies prevent unwanted messages from being delivered to SQS queues, reducing SQS request and storage costs.
3
Integrate SQS queues as the endpoints for the SNS subscriptions to ensure durability and decouple the consumer processing from the message publisher.
Created three SQS queues subscribed to the SNS topic, with filter policies applied directly at the subscription level.
This architecture ensures messages are safely buffered and only matching messages are processed by each consumer system.

Key Concept

Message routing and fanout using Amazon SNS subscription filter policies and Amazon SQS queues

Alternative Method

An alternative approach is to use Amazon EventBridge, which natively supports content-based filtering. However, for standard high-throughput messaging patterns involving simple SQS integration, the SNS-to-SQS fanout with subscription filter policies is the standard, cost-effective, and highly scalable pattern tested on the AWS Certified Developer exam.
Estimated Time:2m 0s
Question 413Question

A developer is building a serverless backend using AWS Lambda that queries an Amazon RDS database. To optimize performance and reduce database connection overhead, the developer wants to implement execution context reuse. The Lambda function also needs to retrieve database credentials securely from AWS Systems Manager Parameter Store.

Which two actions should the developer take to meet these performance and security requirements? (Select two.)

Select all that apply

Show answer & explanation

Answer: Initialize the database connection pool outside of the Lambda handler function to reuse connections across subsequent invocations.; Retrieve the database credentials from Parameter Store outside of the Lambda handler function, caching the values and implementing a refresh mechanism.

Answer

The developer should initialize the database connection pool outside the Lambda handler function to leverage execution context reuse, and fetch the database credentials from Parameter Store outside the handler, caching them with a mechanism to refresh the credentials before expiration.
To optimize performance, initialization logic such as database connection pools and credential retrieval should be executed outside the handler function. During subsequent warm invocations, the Lambda service reuses the same execution environment, allowing global variables and open network connections to remain active. Retrieving and caching credentials outside the handler reduces API overhead, while introducing a refresh mechanism ensures rotated credentials are eventually updated without manual restarts.

Step-by-Step Solution

1
Move resource-heavy initialization logic (such as database connection pools) outside the Lambda handler function.
Database connections are created once during the environment initialization and reused across subsequent warm invocations, reducing connection setup latency.
Execution environments are kept active by Lambda for subsequent requests. Anything declared in global scope remains warm.
2
Retrieve database credentials from Systems Manager Parameter Store outside the handler function.
Credentials are fetched once when the container initializes instead of on every invocation.
This reduces Parameter Store API request volume and lowers execution latency for subsequent invocations.
3
Implement a local cache with a Time-To-Live (TTL) or refresh check for the retrieved credentials.
The Lambda function can adapt to rotated credentials without requiring a cold start.
If secrets are cached indefinitely, credential rotation in the backend would lead to database connection failures until the container is recycled.

Key Concept

Optimizing AWS Lambda performance and security via execution context reuse and static initialization.
Question 414Question

A developer is designing an AWS Lambda function that processes customer orders. The function must retrieve configuration parameters from an Amazon ElastiCache for Redis cluster located in the private subnets of a custom VPC. Additionally, for each processed order, the Lambda function must send a confirmation message to a third-party billing API on the public internet. Which configuration will allow the Lambda function to connect to the ElastiCache cluster and successfully call the third-party billing API?

Show answer & explanation

Answer: Configure the Lambda function to run inside the VPC by associating it with the private subnets where the ElastiCache cluster is located. Route the outbound internet traffic from these private subnets through a NAT gateway configured in a public subnet.

Answer

Configure the Lambda function to run inside the VPC by associating it with the private subnets where the ElastiCache cluster is located, and route outbound internet traffic through a NAT gateway in a public subnet.
The correct option outlines the standard and recommended architectural pattern for VPC-enabled Lambda functions requiring internet access. Associating the function with the private subnets puts it in the same network space as the ElastiCache cluster, while routing subnet traffic through a NAT gateway in a public subnet allows the function to access public endpoints.

Step-by-Step Solution

1
Determine the network requirements for the two target resources.
The ElastiCache cluster is inside a private VPC subnet and is not publicly accessible. The third-party API is on the public internet.
This establishes that the Lambda function must have network access to both a private VPC network and the public internet.
2
Configure the Lambda function's VPC attachment.
Associate the Lambda function with the private subnets of the VPC where the ElastiCache cluster is located.
This places the Lambda function in the same network topology, enabling it to communicate with the Redis cluster via internal IP addresses.
3
Configure internet egress for the private subnets.
Route the 0.0.0.0/0 traffic from the private subnets to a NAT gateway located in a public subnet of the VPC.
Because Lambda ENIs inside a VPC do not receive public IP addresses, they cannot route traffic directly to an Internet Gateway. A NAT gateway allows resources in private subnets to make outbound connections to the internet.

Key Concept

AWS Lambda VPC networking and internet access for private subnet resources.
Question 415Question

A developer is building a backend service for a food delivery application. The service needs to store and query customer order history in an Amazon DynamoDB table. The table is structured with `CustomerId` as the partition key and `OrderTimestamp` as the sort key. The developer also needs to perform bulk updates of restaurant menus daily, uploading up to 2,0002,000 menu items. The developer wants to optimize application performance, minimize DynamoDB capacity consumption, and ensure secure credential management.

Which two strategies should the developer implement? (Select two.)

Select all that apply

Show answer & explanation

Answer: Use the `Query` API operation with the `CustomerId` and a key condition expression on `OrderTimestamp` to retrieve a customer's order history.; Use the `BatchWriteItem` API operation to perform the bulk menu updates, grouping the write requests in batches of up to 2525 items.

Answer

The developer should use the Query API operation to retrieve a customer's order history and the BatchWriteItem API operation to perform the bulk menu updates.
The correct strategies are to use the Query API for order retrieval and the BatchWriteItem API for bulk menu updates. Using Query targets the specific partition key directly, optimizing read performance. Using BatchWriteItem bundles multiple write requests into a single network round trip, reducing API overhead.

Step-by-Step Solution

1
Determine the most efficient retrieval method for order history using the known schema.
Since CustomerId is the partition key and OrderTimestamp is the sort key, a Query operation can target a specific CustomerId partition directly.
Querying is more efficient than scanning because it only reads the partition of interest, saving Read Capacity Units (RCUs) and lowering latency.
2
Select the appropriate API for bulk writing menu items.
The BatchWriteItem API is selected to group up to 2525 PutItem or DeleteItem requests.
This minimizes the number of HTTPS requests, reduces overhead, and optimizes Write Capacity Unit (WCU) consumption during batch uploads.
3
Address credential security and potential throttling errors during writes.
Use IAM roles and the default credential provider chain instead of hardcoded keys, and analyze partition key distribution if write exceptions occur.
Hardcoding keys is insecure, and partition throttling must be solved by distributing keys evenly rather than globally increasing provisioned throughput.

Key Concept

Efficient DynamoDB retrieval using Query rather than Scan, batching writes using BatchWriteItem, and adhering to AWS credential and partition scaling best practices.
Question 416Question

A developer is configuring an Amazon SQS event source mapping for an AWS Lambda function that processes customer feedback messages. The SQS queue visibility timeout is configured to 3030 seconds. To optimize message processing, the developer wants to process messages in batches of up to 1010, handle partial batch failures gracefully so that only failed messages are retried, and prevent message processing from timing out before the visibility window expires. Which combination of configurations will achieve these goals? (Select two.)

Select all that apply

Show answer & explanation

Answer: Configure the Lambda function's timeout to 55 seconds, ensuring the SQS queue visibility timeout is at least 66 times the function's timeout.; Configure the event source mapping to include ReportBatchItemFailures in the function response types, and return a list of failed message IDs in the response payload.

Answer

Configure the Lambda function's timeout to 55 seconds, ensuring the SQS queue visibility timeout is at least 66 times the function's timeout, and configure the event source mapping to include ReportBatchItemFailures in the function response types, and return a list of failed message IDs in the response payload.
To handle partial batch failures in Amazon SQS event source mappings without reprocessing successful messages, developers should enable ReportBatchItemFailures in the FunctionResponseTypes of the event source mapping. The Lambda function must then return a JSON response containing a batchItemFailures list with the identifiers of the failed messages. Additionally, to prevent message processing from timing out and causing duplicate delivery before SQS visibility expires, the visibility timeout of the SQS queue must be configured to at least 66 times the Lambda function's timeout. Since the SQS queue's visibility timeout is 3030 seconds, the Lambda function's timeout should be configured to 55 seconds or less.

Step-by-Step Solution

1
Analyze the relationship between SQS visibility timeout and Lambda function timeout.
Determine that the SQS visibility timeout must be at least 66 times the Lambda timeout (306×Lambda Timeout30 \ge 6 \times \text{Lambda Timeout}).
To prevent duplicate processing caused by the SQS visibility window expiring while the Lambda function is still running.
2
Calculate the maximum allowed Lambda function timeout.
The Lambda function timeout should be configured to 55 seconds or less (30/6=530 / 6 = 5).
Ensures the Lambda function's timeout satisfies the 66 times visibility timeout requirement.
3
Configure partial batch processing for the SQS event source mapping.
Enable ReportBatchItemFailures in the event source mapping and structure the Lambda function to return failed message IDs in a batchItemFailures list.
Allows SQS to delete successful messages automatically and only retry failed messages from the batch.

Key Concept

Integrating AWS Lambda with Amazon SQS involves configuring the function timeout relative to SQS visibility timeout to prevent duplicate processing, and utilizing ReportBatchItemFailures to handle partial batch processing errors efficiently.
Question 417Question

A developer is building a warehouse inventory management application that uses an Amazon DynamoDB table. The table's partition key is WarehouseIDWarehouseID and the sort key is ItemIDItemID. The developer needs to retrieve all items belonging to a specific warehouse where the StockCountStockCount attribute is less than 1010. The table contains millions of items, but each individual warehouse has at most a few thousand items. Which approach should the developer use to retrieve the required items with the lowest latency and the most efficient Read Capacity Unit (RCURCU) consumption?

Show answer & explanation

Answer: Perform a `Query` operation specifying the WarehouseIDWarehouseID in the `KeyConditionExpression` and filtering the results using a `FilterExpression` for StockCountStockCount.

Answer

Perform a Query operation specifying the WarehouseID in the KeyConditionExpression and filtering the results using a FilterExpression for StockCount.
The correct option is to perform a Query operation specifying the partition key (WarehouseIDWarehouseID) in the `KeyConditionExpression` and using a `FilterExpression` for the non-key attribute (StockCountStockCount). In DynamoDB, Query operations are optimized to search within a single partition key, avoiding full table scans and reducing both latency and Read Capacity Unit (RCU) consumption. The FilterExpression acts on the retrieved partition items before they are returned to the application, ensuring that only relevant items are sent over the network.

Step-by-Step Solution

1
Analyze the table primary key structure and access pattern requirements.
The table has a composite primary key consisting of a partition key (WarehouseIDWarehouseID) and a sort key (ItemIDItemID). The query requires filtering by the partition key (WarehouseIDWarehouseID) and a non-key attribute (StockCountStockCount).
Identifying the partition key helps determine if a Query operation is possible, as a Query requires a specific partition key value.
2
Compare the efficiency of Query versus Scan operations.
A Query operation only reads items that match the specified partition key (WarehouseIDWarehouseID). A Scan operation reads every item in the entire table. Since we only want items for a specific warehouse, Query is much more efficient than Scan.
Using Query instead of Scan avoids reading millions of unrelated items, saving latency and RCU.
3
Determine the correct expressions to use in the Query operation.
Specify the partition key value in the `KeyConditionExpression` and specify the non-key attribute filter (StockCount<10StockCount < 10) in the `FilterExpression`.
The `KeyConditionExpression` is used to find the matching partition key, and the `FilterExpression` is used to filter the resulting items before they are returned to the application.

Key Concept

Choosing Query over Scan for partition key queries and filtering results using FilterExpressions to optimize performance and cost.
Question 418Question

A developer is building a serverless application where an Amazon S3 bucket triggers an AWS Lambda function asynchronously when new files are uploaded. The Lambda function processes each file and performs data extraction. Under heavy load, some files fail to process. The developer wants to ensure that any failed event payload is automatically sent to an Amazon SQS queue for manual analysis, rather than being discarded. Which of the following is the AWS-recommended method to achieve this?

Show answer & explanation

Answer: Configure an On-Failure Lambda Destination for the function and specify the SQS queue as the destination.

Answer

Configure an On-Failure Lambda Destination for the function and specify the SQS queue as the destination.
The correct approach is to configure an On-Failure Lambda Destination. For asynchronous invocations, Lambda can route execution records to external services like SQS on failure. This handles all execution errors, including application-level errors, timeouts, and out-of-memory crashes.

Step-by-Step Solution

1
Identify the invocation model of the Lambda function.
The function is triggered by S3, which executes Lambda asynchronously.
Asynchronous invocations support Lambda Destinations for routing successful or failed execution results.
2
Select the appropriate target for capturing failed executions.
Choose the SQS queue as the destination for the On-Failure condition.
An On-Failure destination automatically intercepts and forwards the event payload when the Lambda execution fails, including timeouts.
3
Configure the necessary IAM permissions.
Grant the Lambda execution role permission to write to the SQS queue.
Lambda requires the `sqs:SendMessage` permission to deliver the failure payload to the destination queue.

Key Concept

AWS Lambda Asynchronous Invocation Destinations
Question 419Question

A developer is building a fitness tracking application that logs daily workout sessions for users. The application needs to import a batch of 4040 workout records into an Amazon DynamoDB table. If some records fail to write due to transient issues or throughput throttling, the application must identify and retry writing only those failed records. Which approach should the developer implement to accomplish this requirement with the least operational overhead?

Show answer & explanation

Answer: Use the BatchWriteItem API operation, inspect the UnprocessedItems parameter in the response, and retry only the failed write requests.

Answer

Use the BatchWriteItem API operation, inspect the UnprocessedItems parameter in the response, and retry only the failed write requests.
The correct approach is to use BatchWriteItem, which can put or delete multiple items in a single call. If some operations fail, DynamoDB does not fail the entire batch; instead, it returns the failed items in the UnprocessedItems parameter. The developer can then code the application to retry only these specific items, which is highly efficient and minimizes operational overhead.

Step-by-Step Solution

1
Select the appropriate batch writing API.
The BatchWriteItem API operation allows batching up to 2525 Put or Delete requests in a single call.
Using BatchWriteItem reduces the number of network round trips compared to individual PutItem requests.
2
Handle partial failures in the batch response.
Inspect the UnprocessedItems element returned in the BatchWriteItem response.
If some writes fail due to temporary throttling or limits, DynamoDB returns them in UnprocessedItems rather than failing the entire request.
3
Implement a retry mechanism.
Only retry the items specified in the UnprocessedItems parameter, preferably using exponential backoff.
This avoids resubmitting successfully written items, minimizing read/write capacity consumption and operational overhead.

Key Concept

Handling partial failures and unprocessed items in DynamoDB BatchWriteItem operations
Estimated Time:1m 30s
Question 420Question

A healthcare monitoring application ingests real-time vital signs from patient wearable devices into an Amazon Kinesis Data Stream. During peak clinical hours, the producer applications report frequent ProvisionedThroughputExceededException errors. Upon analysis, the developer finds that the aggregate write throughput is significantly below the stream's provisioned limit, but a subset of shards is heavily throttled. The application uses the device manufacturer name as the partition key.

Which action should the developer take to resolve the write throttling?

Show answer & explanation

Answer: Change the partition key to a unique identifier such as the patient's device ID.

Answer

Change the partition key to a unique identifier such as the patient's device ID.
Changing the partition key to a unique identifier, such as the patient's device ID, ensures high entropy. Kinesis uses the partition key hash value to determine which shard receives a data record. A high-cardinality key distributes the records evenly across all shards, resolving the hot shard problem and preventing write throttling.

Step-by-Step Solution

1
Analyze the cause of the ProvisionedThroughputExceededException.
Identify that a subset of shards is throttled while aggregate throughput is under limits, indicating a hot shard issue.
Throttling on specific shards while overall throughput is low points to uneven data distribution.
2
Examine the current partition key choice.
The current key is the device manufacturer name, which has low entropy (few unique values) and causes data to cluster onto a small number of shards.
A low-cardinality partition key leads to unbalanced shard allocation.
3
Select a high-entropy alternative partition key.
Choosing the patient's device ID provides a large number of unique values, distributing records uniformly across all shards.
High-entropy partition keys ensure even distribution of writes across all shards, eliminating hot shards.

Key Concept

Selecting an appropriate Kinesis partition key with high cardinality/entropy to avoid hot shards.
Estimated Time:1m 30s
PreviousPage 21 / 78Next
All practice questions — AWS Certified Developer - Associate | Examkin