Troubleshooting and Optimization

271 soru

Soru 241Soru

A developer is configuring an Amazon CloudWatch Logs subscription filter to stream logs from an application to an Amazon Kinesis Data Stream. The application logs are structured JSON documents that contain a root-level key `statusCode` and a nested object `errorInfo` with a key `severity`. The developer wants the subscription filter to select only log events where `statusCode` is 500 and `severity` is 'CRITICAL'. Which filter pattern must the developer use?

Cevabı ve açıklamayı göster

Cevap: { .statusCode = 500 && .errorInfo.severity = "CRITICAL" }

Cevap

The correct filter pattern is `{ .statusCode = 500 && .errorInfo.severity = "CRITICAL" }`.
The correct pattern `{ .statusCode = 500 && .errorInfo.severity = "CRITICAL" }` properly follows the CloudWatch Logs filter pattern syntax for JSON logs. It uses curly braces, dot notation for nested JSON properties, a single `=` for comparison, and `&&` for a logical AND relationship.

Adım Adım Çözüm

1
Identify the format of the log events.
The log events are structured JSON documents.
This determines that the pattern must use curly braces `{ }` and JSONPath-like notation starting with `$.`.
2
Apply the correct comparison and logical operators for CloudWatch filter patterns.
Use `=` for equality and `&&` for the logical AND operation.
CloudWatch JSON filter patterns do not use `==` or keyword operators like `AND`.
3
Construct the path to the nested property.
`$.errorInfo.severity` is used to target the `severity` field inside the nested `errorInfo` object.
JSONPath syntax allows nested fields to be traversed using dot notation.

Anahtar Kavram

CloudWatch Logs Filter Pattern Syntax for JSON Log Events
Soru 242Soru

A web application hosted on `https://manager.fleet-operations.com` sends an HTTP `POST` request to an Amazon API Gateway REST API. The API is integrated with a backend AWS Lambda function using a Lambda Proxy integration. Although the developer enabled CORS on the API Gateway resource, the browser console displays a CORS preflight blocked error and a `502 Bad Gateway` status. Which two actions must the developer take to resolve these errors?

Geçerli olan tümünü seçin

Cevabı ve açıklamayı göster

Cevap: Modify the Lambda function response to include the 'Access-Control-Allow-Origin' header with the value 'https://manager.fleet-operations.com'.; Ensure the Lambda function returns a structured JSON object containing the 'statusCode', 'headers', and 'body' fields.

Cevap

To resolve the CORS and 502 Bad Gateway errors, the developer must modify the Lambda function response to include the 'Access-Control-Allow-Origin' header with the value 'https://manager.fleet-operations.com', and ensure the Lambda function returns a structured JSON object containing the 'statusCode', 'headers', and 'body' fields.
The correct options are to modify the Lambda function response to include the 'Access-Control-Allow-Origin' header with the client's origin, and ensure the Lambda function returns a structured JSON object containing 'statusCode', 'headers', and 'body'. In a Lambda Proxy integration, the backend Lambda function is responsible for both the formatting of the response payload (which prevents the 502 Bad Gateway error) and returning the necessary CORS headers.

Adım Adım Çözüm

1
Analyze the error context and integration type.
Identify that the API uses Lambda Proxy integration and returns both a 502 Bad Gateway error and a CORS preflight blocked error.
With Lambda Proxy integration, API Gateway expects a structured JSON output from Lambda, and does not automatically inject CORS headers into the backend response.
2
Fix the response payload format of the Lambda function.
Format the Lambda function's return value as a JSON object containing 'statusCode', 'headers', and 'body'.
This resolves the 502 Bad Gateway error, which is caused by a malformed response that API Gateway cannot parse.
3
Add the required CORS headers to the Lambda response.
Include 'Access-Control-Allow-Origin': 'https://manager.fleet-operations.com' within the 'headers' object of the Lambda response.
This resolves the CORS preflight blocked error for the actual POST request, as the proxy integration passes backend headers directly to the client.

Anahtar Kavram

CORS and Response Formatting in API Gateway Lambda Proxy Integrations
Soru 243Soru

A legacy web application deployed on an Amazon EC2 instance writes log events in a space-delimited format to `/var/log/web-app/access.log`. The fields in the log are ordered as: `ip`, `user`, `date`, `request`, `status_code`, and `bytes`. A developer installs the unified CloudWatch agent on the instance to stream these logs to Amazon CloudWatch Logs and configures a metric filter to count the occurrences of HTTP 5xx server errors. However, after starting the agent, no log events appear in the CloudWatch Logs console. In addition, during testing, the metric filter fails to match any log events representing server errors. Which two actions should the developer take to resolve these issues? (Select TWO.)

Geçerli olan tümünü seçin

Cevabı ve açıklamayı göster

Cevap: Ensure the IAM role attached to the EC2 instance profile contains permissions to perform `logs:CreateLogStream` and `logs:PutLogEvents` operations.; Update the metric filter pattern to `[ip, user, date, request, status_code >= 500 && status_code < 600, bytes]` to match status codes in the 5xx range.

Cevap

Ensure the IAM role attached to the EC2 instance profile contains permissions to perform `logs:CreateLogStream` and `logs:PutLogEvents` operations, and update the metric filter pattern to `[ip, user, date, request, status_code >= 500 && status_code < 600, bytes]`.
To resolve the log streaming issue, the EC2 instance profile's IAM role must have the necessary permissions (`logs:CreateLogStream` and `logs:PutLogEvents`) to interact with CloudWatch Logs. To resolve the metric filter issue for space-delimited log files, the filter must use valid bracket syntax and standard numeric comparison operators (`status_code >= 500 && status_code < 600`) to correctly capture the 5xx HTTP status code range.

Adım Adım Çözüm

1
Diagnose why logs are not appearing in CloudWatch Logs by checking IAM permissions.
The CloudWatch agent requires explicit write permissions via the EC2 instance profile. Granting `logs:CreateLogStream` and `logs:PutLogEvents` enables log streaming.
Without these permissions, the agent cannot authenticate or write logs to the CloudWatch API.
2
Analyze the log format and construct a valid metric filter pattern for space-delimited logs.
The correct filter pattern is `[ip, user, date, request, status_code >= 500 && status_code < 600, bytes]`.
Space-delimited filters require brackets mapping to the fields, and numeric ranges must be specified with logical AND (`&&`) rather than wildcards (`*`).

Anahtar Kavram

CloudWatch Agent IAM Permissions and Space-Delimited Metric Filter Syntax
Tahmini Süre:2m 0s
Soru 244Soru

A Svelte single-page application hosted on `https://dashboard.analytics-core.org` sends an HTTP `POST` request to an Amazon API Gateway REST API. The API is configured to use a Lambda proxy integration with a backend AWS Lambda function. When the application executes the request, the web browser console displays a `502 Bad Gateway` error, followed by a CORS error stating that the `Access-Control-Allow-Origin` header is missing. The developer confirms that CORS has already been enabled on the API Gateway resource for all methods. What must the developer do to resolve this error?

Cevabı ve açıklamayı göster

Cevap: Modify the backend Lambda function to return a JSON response containing the `statusCode`, `headers`, and `body` fields, ensuring that the `headers` map includes `Access-Control-Allow-Origin` set to the application's domain.

Cevap

Modify the backend Lambda function to return a JSON response containing the `statusCode`, `headers`, and `body` fields, ensuring that the `headers` map includes `Access-Control-Allow-Origin` set to the application's domain.
The correct response resolves the root cause by ensuring the Lambda function returns the response in the exact format required by the Lambda proxy integration. Specifically, the function must return a JSON object with `statusCode`, `headers`, and `body` fields, and the `headers` field must contain the `Access-Control-Allow-Origin` header. Because the browser receives a 502 Bad Gateway when the response is malformed, it also fails the CORS preflight check since the CORS headers are not present in the error response.

Adım Adım Çözüm

1
Analyze the error response and integration type.
The application receives a `502 Bad Gateway` and a missing `Access-Control-Allow-Origin` header, which is indicative of a malformed integration response in a Lambda proxy integration.
In Lambda proxy integrations, API Gateway expects the backend Lambda function to return a specific JSON format containing `statusCode`, `headers`, and `body`.
2
Verify backend response structure.
If the Lambda function returns a flat string or an arbitrary JSON structure, API Gateway fails to parse the response, resulting in a `502 Bad Gateway` status code.
Because API Gateway fails with a 502 error before processing the method's headers, the CORS headers set at the resource level are not sent to the client, triggering a secondary CORS error in the browser.
3
Format the Lambda response output.
The Lambda function is modified to return an object with a `statusCode` (e.g., 200), a `body` containing the JSON payload, and a `headers` object containing the `Access-Control-Allow-Origin` header set to the client's origin.
This satisfies both the API Gateway proxy format requirements and the browser's CORS policy checks.

Anahtar Kavram

CORS handling in API Gateway Lambda Proxy Integrations
Soru 245Soru

A developer is setting up a new AWS CodeBuild project to compile an application. The developer creates an IAM role named CodeBuildServiceRole to serve as the service role for the project and attaches policies allowing access to Amazon S3 and Amazon CloudWatch Logs. However, when the developer attempts to start the build run, it fails immediately with the following error:

CodeBuild is not authorized to perform: sts:AssumeRole on arn:aws:iam::123456789012:role/CodeBuildServiceRole

What action should the developer take to resolve this authorization failure?

Cevabı ve açıklamayı göster

Cevap: Update the trust policy of CodeBuildServiceRole to allow the codebuild.amazonaws.com service principal to perform the sts:AssumeRole action.

Cevap

Update the trust policy of the IAM service role to allow the CodeBuild service principal (codebuild.amazonaws.com) to assume the role.
The error indicates that the AWS CodeBuild service itself is not authorized to assume the role specified. For an AWS service to assume an IAM role, the role's trust policy (trust relationship) must explicitly grant 'sts:AssumeRole' permission to the service principal, in this case, 'codebuild.amazonaws.com'. Updating the trust policy resolves this failure.

Adım Adım Çözüm

1
Analyze the error message.
The error shows that the CodeBuild service principal is unable to assume the specified service role (sts:AssumeRole fails).
Before CodeBuild can execute, it needs to assume the role to inherit its permissions.
2
Inspect the trust relationship of the IAM role.
Identify that the trust policy is either missing or does not specify codebuild.amazonaws.com as a trusted entity.
The trust policy is what establishes trust between the IAM role and the AWS service principal.
3
Update the trust policy document.
Add a trust statement allowing the 'sts:AssumeRole' action to the 'codebuild.amazonaws.com' principal.
This grants CodeBuild the authority to assume the role successfully.

Anahtar Kavram

IAM Service Role Trust Policies
Soru 246Soru

A telemetry ingestion application named ThermoSense logs sensor status updates to an Amazon DynamoDB table. The table is configured with provisioned write capacity and uses SensorModel as the partition key. During a firmware update deployment, the application encounters multiple ProvisionedThroughputExceededException errors. CloudWatch metrics indicate that a specific, widely deployed sensor model is generating a high volume of writes, resulting in a hot partition. Which TWO actions should the developer take to resolve the write throttling and ensure even load distribution across partitions? (Select TWO.)

Geçerli olan tümünü seçin

Cevabı ve açıklamayı göster

Cevap: Modify the application logic to append a random numeric suffix to the partition key value before writing the items.; Configure the AWS SDK client to use exponential backoff and jitter for request retries.

Cevap

To resolve the throttling and key distribution issues, the developer should modify the application logic to append a random numeric suffix to the partition key value and configure the AWS SDK client to use exponential backoff and jitter for request retries.
The correct strategy combines database-level partition sharding and application-level retry patterns. Appending a random numeric suffix to the partition key distributes the write load across multiple database partitions, effectively dispersing the hot key bottleneck. Configuring the AWS SDK client to use exponential backoff and jitter ensures that the client application handles transient ProvisionedThroughputExceededException errors gracefully without overwhelming the database with immediate retries.

Adım Adım Çözüm

1
Analyze the cause of the throttling.
The CloudWatch metrics reveal that the ProvisionedThroughputExceededException is caused by a hot partition key because a single SensorModel partition is receiving an unevenly high volume of writes.
Before applying a fix, the developer must determine whether the throughput exhaustion is due to overall table limits or an uneven partition key distribution.
2
Implement partition key sharding (suffixing).
By appending a random numeric suffix to the hot partition key value, writes are distributed across multiple distinct partitions.
This resolves the hot key issue by spreading the write load more evenly across DynamoDB's physical partition structure.
3
Configure client-side error handling.
The AWS SDK is configured to handle transient throttling errors by retrying failed writes using exponential backoff and randomized jitter.
This prevents retry storms and ensures that the client application gracefully recovers when throughput limits are temporarily reached.

Anahtar Kavram

Resolving DynamoDB hot partition key bottlenecks using write sharding (random suffixing) combined with client-side retry logic (exponential backoff and jitter).
Tahmini Süre:2m 0s
Soru 247Soru

A React Native mobile application sends an HTTP POST request to an Amazon API Gateway REST API endpoint to update a user's profile. The API uses a Lambda proxy integration with an AWS Lambda function. Users report receiving a 502 Bad Gateway error when saving their profile updates. The developer checks the CloudWatch logs for the Lambda function and confirms it executes successfully, returning the following output:

{
"message": "Profile updated successfully",
"status": "success"
}

Which of the following explains why the application receives the 502 Bad Gateway error and identifies the correct solution?

Cevabı ve açıklamayı göster

Cevap: The Lambda function response format is incorrect for a Lambda proxy integration. The developer must modify the Lambda function to return a JSON object containing an integer 'statusCode' and a stringified 'body'.

Cevap

The Lambda function response format is incorrect for a Lambda proxy integration. The developer must modify the Lambda function to return a JSON object containing an integer 'statusCode' and a stringified 'body'.
The correct response points out that in a Lambda proxy integration, API Gateway expects the backend Lambda function to return a structured JSON object containing a 'statusCode' (number) and a 'body' (which must be a stringified representation of the payload). Returning a custom JSON object directly without this structure results in a 502 Bad Gateway error and a 'Malformed Lambda proxy response' entry in the API Gateway logs.

Adım Adım Çözüm

1
Analyze the error message and the configuration context.
The client receives a 502 Bad Gateway error, but the Lambda function executes successfully and returns a custom JSON object.
This indicates that the integration between API Gateway and Lambda is working, but API Gateway is unable to parse the returned output.
2
Evaluate the response requirements for the configured integration type.
Since the API uses a Lambda proxy integration, the backend Lambda function is responsible for defining the entire HTTP response, including status codes, headers, and the body.
For Lambda proxy integrations, API Gateway expects a specific structure: { 'statusCode': number, 'body': 'string', 'headers': { ... } }.
3
Identify the formatting issue in the Lambda function's current output.
The current output is a plain JSON object with custom keys ('message', 'status'), which causes API Gateway to fail with a malformed proxy response error.
Changing the function code to return the correct envelope with a stringified body resolves the malformed response and allows API Gateway to map it to a proper HTTP response.

Anahtar Kavram

API Gateway Lambda Proxy Integration Response Requirements
Soru 248Soru

A developer is troubleshooting a Vue.js single-page application that is receiving a 502 Bad Gateway error when calling a POST endpoint on an Amazon API Gateway REST API. The API uses a Lambda proxy integration with a backend AWS Lambda function. In the Amazon CloudWatch logs, the developer confirms that the Lambda function executed successfully and returned the following JSON object:

{
"status": "success",
"data": {
"orderId": "78910"
}
}

Which of the following describes the root cause and the correct resolution for this error?

Cevabı ve açıklamayı göster

Cevap: The Lambda proxy integration requires the function's output to be a JSON object containing an integer 'statusCode' and a stringified JSON 'body'. The developer must modify the Lambda function's response payload to return this format.

Cevap

The Lambda proxy integration requires the function's output to be a JSON object containing an integer 'statusCode' and a stringified JSON 'body'. The developer must modify the Lambda function's response payload to return this format.
In a Lambda proxy integration, API Gateway expects the backend Lambda function to return a specific JSON response format containing an integer 'statusCode' and a string 'body'. If the backend Lambda function returns a custom JSON object instead of this format, API Gateway fails to parse the response and returns a 502 Bad Gateway error to the client. Modifying the Lambda function to return the correct structure resolves this integration issue.

Adım Adım Çözüm

1
Analyze the error message and execution logs.
The client receives a 502 Bad Gateway error, but CloudWatch logs confirm that the Lambda function completed execution successfully. This points to a communication or parsing error between API Gateway and Lambda.
Checking both client-side errors and backend logs helps distinguish between a Lambda function crash and an integration parsing failure.
2
Identify the integration type mapping requirements.
The API utilizes a Lambda proxy integration. Unlike custom integrations, proxy integrations do not support Integration Response mapping templates in API Gateway.
Understanding the difference between Lambda custom and Lambda proxy integrations dictates where the payload formatting must be performed.
3
Modify the Lambda function handler output format.
The developer updates the Lambda function to return an object structured with 'statusCode' (integer) and 'body' (stringified JSON).
API Gateway requires this specific contract to successfully construct the HTTP response for the client.

Anahtar Kavram

API Gateway Lambda Proxy Integration Response Formatting
Tahmini Süre:1m 30s
Soru 249Soru

An application running in Amazon ECS container tasks writes structured JSON logs to Amazon CloudWatch Logs. A sample log event is:

{
"eventType": "DatabaseError",
"details": {
"duration": 4500,
"status": "failed"
}
}

A developer wants to create a CloudWatch Metric Filter to monitor events where the event type is "DatabaseError" and the nested query duration is greater than 40004000 milliseconds. The developer initially configures a metric filter with the pattern `[eventType = "DatabaseError", details.duration > 4000]`, but notices that the metric is not being published and no matches are found. Which of the following actions must the developer take to resolve this issue and successfully monitor the database errors? (Select TWO.)

Geçerli olan tümünü seçin

Cevabı ve açıklamayı göster

Cevap: Update the filter pattern to use curly braces and JSON path notation: `{ .eventType = "DatabaseError" && .details.duration > 4000 }`; Specify a metric name, a metric namespace, and a metric value of 11 in the metric filter configuration.

Cevap

Update the filter pattern to use curly braces and JSON path notation, and specify a metric name, a metric namespace, and a metric value of 1 in the metric filter configuration.
To successfully capture and record metrics from the JSON logs, two actions are required. First, the filter pattern must match the structured JSON schema. This is achieved by enclosing the expression in curly braces and using JSON path notation with a single equals sign for string comparison. Second, the metric filter must be configured with a metric namespace, metric name, and a metric value to indicate how CloudWatch should generate the data point when a log matches the pattern.

Adım Adım Çözüm

1
Correct the log format interpretation in the filter pattern.
Change the pattern from space-delimited text syntax `[eventType = "DatabaseError", details.duration > 4000]` to JSON syntax `{ .eventType = "DatabaseError" && .details.duration > 4000 }`.
CloudWatch Logs requires curly braces `{}` and the `$.` prefix to query nested properties in JSON log events.
2
Map the filter matches to a target metric.
Define the target metric's namespace, name, and increment value (11).
A metric filter must specify how matching log events translate into custom metric data points in Amazon CloudWatch.

Anahtar Kavram

CloudWatch Logs Metric Filter JSON Syntax and Lifecycle
Tahmini Süre:2m 0s
Soru 250Soru

A developer is implementing fine-grained access control for a mobile application. Users authenticate via an Amazon Cognito User Pool, and the application needs to write user-specific profile data to an Amazon DynamoDB table named `UserProfiles`. The table's partition key is `UserId` (String). The developer created an Amazon Cognito Identity Pool to provide temporary AWS credentials to authenticated users and attached an IAM policy to the authenticated role that uses the `dynamodb:LeadingKeys` condition. However, when the application attempts to write data to the DynamoDB table, the API calls fail with an `AccessDeniedException` error. Which two actions must the developer take to resolve these authorization failures?

Geçerli olan tümünü seçin

Cevabı ve açıklamayı göster

Cevap: Configure the application to exchange the Cognito User Pool tokens for temporary AWS credentials from the Cognito Identity Pool, and use these credentials to sign the DynamoDB requests.; Ensure that the partition key `UserId` value in the DynamoDB write request is set to the user's Cognito Identity ID.

Cevap

To resolve the authorization failures, the application must exchange the Cognito User Pool tokens for temporary AWS credentials from the Cognito Identity Pool and use those credentials to sign the requests. Additionally, the partition key value in the DynamoDB write request must match the user's Cognito Identity ID.
To resolve the authorization failure, the developer must ensure that the mobile application properly coordinates authentication and authorization. First, the application must exchange the Cognito User Pool token for temporary AWS credentials using the Cognito Identity Pool, as the User Pool token alone does not grant direct AWS service access. Second, the write request to DynamoDB must use the user's Cognito Identity ID as the partition key value to satisfy the `dynamodb:LeadingKeys` condition in the IAM permissions policy.

Adım Adım Çözüm

1
Acquire temporary AWS credentials
The application authenticates against the Cognito User Pool, obtains an ID token, passes it to the Cognito Identity Pool using the `GetCredentialsForIdentity` API, and receives temporary AWS credentials associated with the authenticated IAM role.
DynamoDB requests must be signed with AWS credentials that map to the authorized IAM role, which is managed by the Identity Pool rather than the User Pool.
2
Align request partition key with IAM policy condition
The application sets the `UserId` partition key attribute of the write payload to the user's unique Cognito Identity ID.
The IAM policy uses `dynamodb:LeadingKeys` with `${cognito-identity.amazonaws.com:sub}`, meaning DynamoDB will reject any write request where the partition key does not match the requester's Cognito Identity ID.

Anahtar Kavram

Using Amazon Cognito Identity Pools and DynamoDB Fine-Grained Access Control (FGAC) to securely authorize mobile applications to access AWS services.
Tahmini Süre:1m 30s
Soru 251Soru

A developer is troubleshooting an application that writes space-delimited log events to an Amazon CloudWatch Logs log group. A sample log event is:

`2026-07-14T12:00:00Z INFO 192.168.1.50 GET /index.html 200 125`

The fields in the log event represent the timestamp, severity, client IP address, HTTP method, resource path, status code, and response time in milliseconds, in that order.

The developer wants to create a CloudWatch Logs metric filter that counts all requests where either the status code is 500500 or the response time is greater than 500 ms500\text{ ms}.

Which of the following filter patterns must the developer use to correctly implement this metric filter?

Cevabı ve açıklamayı göster

Cevap: [timestamp, severity, client_ip, method, resource, status_code = 500 || response_time_ms > 500]

Cevap

The filter pattern starting with square brackets and using the double pipe operator '||' to combine the field conditions.
The correct answer defines the space-delimited fields sequentially inside square brackets, assigning names to each position. It uses the correct logical OR operator '||' to combine the conditions for the status code and response time fields.

Adım Adım Çözüm

1
Identify the format of the log events in the log group.
The log events are space-delimited text, not JSON-formatted.
Knowing the log format determines whether to use bracket syntax `[...]` for space-delimited logs or curly brace syntax `{...}` for JSON logs.
2
Map the log fields to their corresponding positions inside the brackets.
The fields must be defined in the correct order: `timestamp`, `severity`, `client_ip`, `method`, `resource`, `status_code`, and `response_time_ms`.
Space-delimited log patterns match fields by position from left to right.
3
Construct the logical condition with the correct filter syntax.
The condition uses the `=` and `>` operators, combined with the logical OR operator `||` inside the brackets.
CloudWatch Logs metric filters require the logical operators `||` (OR) and `&&` (AND) for multiple conditions, and do not accept SQL keywords like 'OR'.

Anahtar Kavram

CloudWatch Logs metric filter pattern syntax for space-delimited logs.
Tahmini Süre:1m 30s
Soru 252Soru

A sports streaming application named FanStream logs viewer chat messages during live events. The chat messages are written to an Amazon DynamoDB table with EventID as the partition key and Timestamp as the sort key. During highly anticipated matches, the application experiences frequent ProvisionedThroughputExceededException errors on write operations, even though the total consumed write throughput is well below the table's provisioned capacity. Which of the following actions should the developer take to resolve this issue? (Select TWO.)

Geçerli olan tümünü seçin

Cevabı ve açıklamayı göster

Cevap: Append a random suffix to the EventID partition key value before writing the items to distribute the write requests across multiple physical partitions.; Configure the AWS SDK client to utilize exponential backoff and jitter when retrying throttled requests.

Cevap

To resolve the write throttling and key distribution issues, the developer should append a random suffix to the partition key (EventID) to distribute writes across partitions, and configure the AWS SDK client to use exponential backoff and jitter for retrying failed requests.
The correct options involve appending a random suffix to the partition key (which shards the hot partition key to distribute write traffic across physical partitions) and configuring the AWS SDK with exponential backoff and jitter (which prevents retry storms by spacing out requests and handling transient throttling gracefully).

Adım Adım Çözüm

1
Analyze the table key design and throttling error.
Identify that the partition key (EventID) has high write concurrency during matches, concentrating all writes onto a single logical partition (a hot key scenario), causing ProvisionedThroughputExceededException.
DynamoDB allocates capacity across physical partitions based on partition keys. Concentrating traffic on a single key leads to throttling even if the total provisioned throughput is not exceeded.
2
Select a strategy to distribute the write load.
Append a random suffix (e.g., EventID_1, EventID_2) to the partition key to split the writes across multiple logical partitions.
This key sharding strategy ensures write operations are evenly distributed, avoiding the limits of a single partition.
3
Implement a retry policy to handle transient spikes.
Configure the AWS SDK with exponential backoff and jitter.
This mitigates temporary spikes by spacing out retry attempts, avoiding a thundering herd problem where all retries hit the table at the same time.

Anahtar Kavram

Resolving hot partitions and throttling in DynamoDB
Soru 253Soru

An e-commerce application deployed on Amazon ECS writes structured JSON logs to Amazon CloudWatch Logs. A developer needs to create a CloudWatch metric filter to count the occurrences of HTTP 504 Gateway Timeout errors. A sample log event is:

{
"request": {
"path": "/checkout",
"responseCode": 504
}
}

Which filter pattern must the developer use to correctly match this log event?

Cevabı ve açıklamayı göster

Cevap: { $.request.responseCode = 504 }

Cevap

The pattern `{ $.request.responseCode = 504 }` is the correct filter pattern.
The correct pattern is `{ .request.responseCode = 504 }`. In CloudWatch Logs filter pattern syntax, JSON log events are matched using curly braces `{ }`. The root of the JSON document is represented by ``, and nested properties are traversed using dot notation (e.g., `$.request.responseCode`). Additionally, equality comparison in CloudWatch filter patterns is performed using a single equals sign (`=`).

Adım Adım Çözüm

1
Identify the log format
The log format is structured JSON, which requires curly braces `{ }` for the CloudWatch metric filter pattern.
CloudWatch Logs parses JSON objects only if the filter pattern is enclosed in curly braces.
2
Determine the path to the target field
The target field `responseCode` is nested under `request`. In CloudWatch Logs filter syntax, the root of the JSON object is represented by `,andnestedfieldsarereferencedusingdotnotation:`, and nested fields are referenced using dot notation: `.request.responseCode`.
Correct path syntax is necessary to address nested JSON properties.
3
Specify the comparison operator
CloudWatch Logs metric filter syntax uses a single equals sign `=` to evaluate equality.
Using operators like `==` will result in a syntax mismatch and zero metrics reported.

Anahtar Kavram

CloudWatch Logs Metric Filter JSON Syntax
Soru 254Soru

A developer is troubleshooting an application named PagePublish that stores metadata for online articles in an Amazon DynamoDB table. The table is configured with provisioned read capacity and uses ArticleStatus (such as DRAFT or PUBLISHED) as the partition key. During peak traffic hours, users experience high latency, and the application logs show numerous ProvisionedThroughputExceededException errors. Upon reviewing CloudWatch metrics, the developer notes that the read capacity is heavily consumed on a single partition, while other partitions remain idle. Which of the following is the most effective way to resolve this issue and prevent future throttling?

Cevabı ve açıklamayı göster

Cevap: Redesign the table schema to use a more granular attribute, such as ArticleID, as the partition key.

Cevap

Redesign the table schema to use a more granular attribute, such as ArticleID, as the partition key.
Redesigning the table schema to use a more granular attribute like ArticleID ensures that write and read requests are evenly distributed across multiple physical partitions. Since DynamoDB allocates partition capacity based on the partition key value, high-cardinality keys prevent hot partitions and eliminate ProvisionedThroughputExceededException errors caused by uneven traffic distribution.

Adım Adım Çözüm

1
Analyze the CloudWatch metrics and the exception logs.
Identify that the ProvisionedThroughputExceededException is occurring on a specific partition key value (ArticleStatus), indicating a hot partition issue.
Before applying a fix, the developer must determine if the throttling is due to overall capacity exhaustion or uneven key distribution.
2
Evaluate the cardinality of the partition key attribute.
Recognize that 'ArticleStatus' has very low cardinality (few distinct values like DRAFT or PUBLISHED), causing almost all requests to hit the same partition.
Understanding the key distribution characteristics is necessary to design a schema that distributes the workload evenly.
3
Select a partition key with high cardinality and modify the schema.
Choose a high-cardinality attribute like 'ArticleID' as the new partition key, which distributes read and write requests uniformly across partitions.
A high-cardinality partition key allows DynamoDB to partition the data across multiple physical SSDs, utilizing the provisioned throughput efficiently.

Anahtar Kavram

Resolving DynamoDB hot partitions by using a high-cardinality partition key design.
Tahmini Süre:1m 30s
Soru 255Soru

A developer is deploying a Go-based web application to Amazon EC2 instances. The application logs HTTP requests in a custom space-delimited format to /var/log/app/web.log. The fields in each log entry are: IP, client, user, datetime, request_path, response_status, and response_time_ms. The developer wants to use the unified CloudWatch agent to publish these logs to CloudWatch Logs and then create a metric filter to track only requests that returned an HTTP 404 response status. Which two configuration steps must the developer perform to meet these requirements?

Geçerli olan tümünü seçin

Cevabı ve açıklamayı göster

Cevap: In the CloudWatch agent configuration file, specify the log file path under the logs.logs_collected.files section and define a target log group.; Create a CloudWatch Logs metric filter on the target log group using the pattern [ip, client, user, datetime, request_path, response_status = 404, response_time_ms].

Cevap

To monitor the space-delimited log file, the developer must configure the log file path under the logs.logs_collected.files section of the unified CloudWatch agent configuration file, and create a CloudWatch Logs metric filter with the pattern [ip, client, user, datetime, request_path, response_status = 404, response_time_ms].
To stream local log files to CloudWatch Logs, the unified CloudWatch agent must be configured with the file path in the logs.logs_collected.files section. To create a metric filter for space-delimited logs, the filter pattern must list all fields in order, enclosed in brackets, and use the assignment operator to filter on the specific HTTP status code.

Adım Adım Çözüm

1
Configure the CloudWatch agent to collect the log file.
The file path /var/log/app/web.log and log_group_name are added to the logs.logs_collected.files section.
This informs the agent daemon to track the target log file and stream its content to CloudWatch Logs.
2
Create the metric filter for space-delimited events.
The metric filter is created on the target log group using the positional bracketed syntax [ip, client, user, datetime, request_path, response_status = 404, response_time_ms].
Because the logs are space-delimited rather than JSON, CloudWatch Logs maps fields positionally. Specifying the preceding fields is necessary for the filter to target the sixth field, response_status.

Anahtar Kavram

Configuring log collection with the unified CloudWatch agent and applying space-delimited metric filter patterns.
Soru 256Soru

An order ingestion application named OrderSync processes real-time transaction updates and writes them to an Amazon DynamoDB table. The table is configured with provisioned write capacity. During high-traffic flash sales, the application experiences a high rate of ProvisionedThroughputExceededException errors. CloudWatch metrics indicate that the overall write capacity consumption is well below the table's provisioned limit, but the write operations are concentrated on a small number of partition keys representing trending items.

Which TWO actions should the developer take to resolve these throttling issues? (Select TWO.)

Geçerli olan tümünü seçin

Cevabı ve açıklamayı göster

Cevap: Modify the application's write logic to append a random numeric suffix to the partition key for high-volume items to distribute writes across multiple partitions.; Implement exponential backoff and jitter in the application's SDK client retry configuration to handle transient throttling errors.

Cevap

Modify the application's write logic to append a random numeric suffix to the partition key for high-volume items, and implement exponential backoff and jitter in the application's SDK client retry configuration.
The correct options are to append a random numeric suffix to the partition key (which spreads the write requests across multiple physical partitions, preventing individual partition limit exhaustion) and to configure the AWS SDK with exponential backoff and jitter (which handles temporary spikes in write requests without failing the transactions outright).

Adım Adım Çözüm

1
Analyze the CloudWatch metrics and throttling errors.
Identified that the ProvisionedThroughputExceededException is caused by a hot partition key issue where writes are concentrated on a few trending items.
Before applying a fix, the developer must confirm whether the throttling is due to overall capacity exhaustion or uneven key distribution.
2
Apply write sharding using a random suffix.
The write requests are distributed across multiple partitions by appending a suffix, preventing a single partition from bearing the entire load.
DynamoDB partitions have a hard limit of 1000 WCU and 3000 RCU per partition. Distributing hot keys via sharding avoids hitting individual partition limits.
3
Configure the SDK retry policy with exponential backoff and jitter.
Transient throttling spikes are handled gracefully by retrying requests at randomized intervals.
Jitter prevents a 'thundering herd' problem where retried requests arrive simultaneously, causing repeated throttling.

Anahtar Kavram

Resolving DynamoDB throttling issues by avoiding hot partitions through partition key sharding and handling transient failures using backoff and jitter.
Soru 257Soru

A developer is troubleshooting a serverless application where an AWS Lambda function has a configured timeout of 15 seconds. The function is designed to write a custom JSON log entry to Amazon CloudWatch Logs at the end of its execution, structured as { "requestID": "123-456", "status": "COMPLETED", "executionTimeMs": 1250 }. If a database delay occurs, the function catches it and logs { "requestID": "123-456", "status": "ERROR", "errorType": "DatabaseTimeout" }. To track performance issues and failures, the developer configures a CloudWatch Metric Filter with the pattern { (.status="ERROR")(.status = "ERROR") || (.executionTimeMs > 15000) }. During testing, several invocations time out, but the metric filter does not register any data points. Why is the metric filter failing to capture these timeout events?

Cevabı ve açıklamayı göster

Cevap: When a Lambda function times out, the execution is abruptly terminated by the Lambda runtime, preventing the custom log statement from being written. The metric filter must instead match the platform-generated log string 'Task timed out'.

Cevap

When a Lambda function times out, the execution is abruptly terminated by the Lambda runtime, preventing the custom log statement from being written. The metric filter must instead match the platform-generated log string 'Task timed out'.
The correct answer is correct because AWS Lambda enforces execution timeouts at the platform level. If the function times out, the execution container is terminated immediately, preventing any application-level catch blocks or log statements from executing. As a result, the custom JSON log containing the execution time is never written. The developer must instead match the platform-generated log line which contains the phrase 'Task timed out'.

Adım Adım Çözüm

1
Analyze how AWS Lambda handles timeouts at the runtime level.
When the timeout threshold (15 seconds) is reached, the Lambda service immediately halts container execution.
This prevents any subsequent application-level code (including catch blocks or logging libraries) from running.
2
Determine where the log entries originate when a timeout occurs.
The application's custom JSON logs are not written. Instead, the AWS Lambda service writes a standard platform message containing the string 'Task timed out after 15.00 seconds'.
Since the application did not write the log, the metric filter looking for custom JSON properties like status or executionTimeMs will find nothing.
3
Formulate a metric filter pattern to capture these timeout events.
Create a metric filter that matches the string 'Task timed out' in the log group.
This platform-generated string is guaranteed to be logged by the Lambda service when a timeout occurs.

Anahtar Kavram

CloudWatch Logs filters and Lambda timeout log generation
Soru 258Soru

A fleet management system stores real-time diagnostics for 50,00050,000 delivery vehicles in an Amazon DynamoDB table. To minimize read latency and prevent database load, a developer deploys a DynamoDB Accelerator (DAX) cluster. The developer implements a background process that runs periodic Scan operations via the DAX client to pre-warm the cache. However, when the dashboard application performs GetItem calls to retrieve individual vehicle details, it continues to experience high read latency and triggers ProvisionedThroughputExceededException errors on the DynamoDB table. Which action should the developer take to resolve the performance bottleneck and utilize the DAX cache effectively?

Cevabı ve açıklamayı göster

Cevap: Modify the background process to perform individual GetItem or BatchGetItem calls for the vehicle records instead of Scan operations, allowing DAX to populate its item cache.

Cevap

Modify the background process to perform individual GetItem or BatchGetItem calls for the vehicle records instead of Scan operations, allowing DAX to populate its item cache.
The correct answer is to modify the background process to perform individual GetItem or BatchGetItem calls. Amazon DynamoDB Accelerator (DAX) utilizes two separate caches: the item cache and the query cache. GetItem and BatchGetItem operations check and populate the item cache. Scan and Query operations check and populate the query cache. Because the background process was using Scan, it only populated the query cache. Subsequent GetItem requests from the dashboard resulted in item cache misses and went directly to DynamoDB, causing latency and throttling. Warming the item cache using GetItem or BatchGetItem resolves this issue.

Adım Adım Çözüm

1
Analyze how DAX handles cache population for different API calls.
DAX maintains an item cache (populated by GetItem, BatchGetItem, etc.) and a query cache (populated by Query and Scan).
Understanding the difference between DAX's item cache and query cache is necessary to diagnose why GetItem calls are bypassing the cache.
2
Identify the cause of the cache misses and read throttling.
The background process uses Scan, which only populates the query cache. Subsequent GetItem calls search the item cache, result in cache misses, and hit the DynamoDB table directly.
This explains why the table is receiving ProvisionedThroughputExceededException errors despite the DAX cluster.
3
Apply the appropriate caching strategy to resolve the bottleneck.
Changing the background warming process to use GetItem or BatchGetItem calls ensures that the individual vehicle items are cached in the DAX item cache.
This allows subsequent GetItem calls from the dashboard to be served directly from the DAX item cache, eliminating database load and reducing latency.

Anahtar Kavram

DAX Caching Behavior (Item Cache vs. Query Cache)
Soru 259Soru

A document collaboration platform named DocuCollab tracks real-time document editing events and writes them to an Amazon DynamoDB table. The table is configured with provisioned write capacity and uses the DocumentId as the partition key. During peak hours, a small number of extremely popular shared documents experience heavy, concurrent editing activity. This results in ProvisionedThroughputExceededException errors and writes are dropped, even though the total consumed write capacity is well below the table's provisioned limit.

Which combination of actions will resolve this issue? (Select TWO.)

Geçerli olan tümünü seçin

Cevabı ve açıklamayı göster

Cevap: Append a random numeric suffix to the partition key value before writing the items to distribute the write load.; Configure the application SDK client to implement exponential backoff with jitter for retrying failed requests.

Cevap

To resolve the throttling issues, the developer should append a random numeric suffix to the partition key value before writing the items, and configure the application SDK client to implement exponential backoff with jitter for retrying failed requests.
The correct actions are appending a random numeric suffix to the partition key (sharding) and configuring the SDK to use exponential backoff with jitter. Appending a random suffix distributes the concurrent writes for a single popular document across multiple physical partitions, which prevents exceeding the 1,000 WCU physical partition limit. Implementing exponential backoff with jitter ensures that when throttling does occur, the application retries the requests at progressively longer, randomized intervals, preventing retry storms and allowing the writes to succeed without being dropped.

Adım Adım Çözüm

1
Analyze the DynamoDB ProvisionedThroughputExceededException and partition key design to identify if the workload is unevenly distributed.
Discovered that a few popular documents (hot partition keys) are exceeding the single physical partition throughput limit of 1,000 WCUs, even though the total table WCU consumption is low.
This step is necessary to pinpoint that the problem is a hot partition issue rather than a table-wide capacity limitation.
2
Redesign the partition key strategy by appending a random numeric suffix (e.g., a hash or random number from 1 to N) to the DocumentId before writing.
Writes for a single popular document are distributed across N different partition keys, spreading the throughput load across multiple physical partitions.
This step is required to scale the throughput of a single logical key beyond the 1,000 WCU physical partition limit.
3
Configure the application SDK client to implement exponential backoff with randomized jitter for request retries.
Throttled requests are retried with spacing in time, preventing collision patterns (retry storms) and allowing temporary spikes to resolve successfully.
This step is necessary to ensure that the application handles transient throttling gracefully without immediately dropping write requests.

Anahtar Kavram

Resolving DynamoDB throttling issues by redesigning partition keys (sharding) and configuring SDK retry policies with backoff and jitter.
Tahmini Süre:2m 0s
Soru 260Soru

An e-commerce checkout application named CartCheckout records transaction logs in Amazon DynamoDB. The table uses CheckoutDate (formatted as YYYY-MM-DD) as the partition key and TransactionID as the sort key. During a flash sale event, the application experiences multiple ProvisionedThroughputExceededException errors when writing to the table, even though the total consumed Write Capacity Units (WCUs) are well below the table's total provisioned limits. Which action should the developer take to resolve the write throttling and optimize the table's write performance?

Cevabı ve açıklamayı göster

Cevap: Redesign the partition key schema to use the high-entropy TransactionID as the partition key, or append a random suffix to the CheckoutDate, to distribute writes evenly across partitions.

Cevap

Redesign the partition key schema to use the high-entropy TransactionID as the partition key, or append a random suffix to the CheckoutDate, to distribute writes evenly across partitions.
The correct answer is correct because replacing the partition key with a high-entropy key (like TransactionID) or adding a random suffix to the date distributes the data and request load evenly across all available physical partitions. This avoids hot partition bottlenecks where a single partition key receives all writes.

Adım Adım Çözüm

1
Analyze the error message and table configuration to determine the root cause of throttling.
The ProvisionedThroughputExceededException combined with low overall table throughput indicates a hot partition issue due to poor partition key distribution.
Since the partition key is CheckoutDate (YYYY-MM-DD), all transaction writes on the day of the flash sale target the same partition, exceeding the throughput limit of a single physical partition.
2
Evaluate remediation strategies to distribute the write load more evenly across partitions.
A high-entropy attribute like TransactionID should be selected as the partition key, or write sharding (appending a random suffix) should be implemented on the CheckoutDate.
This spreads writes across multiple partition keys and therefore multiple physical partitions, utilizing the table's provisioned capacity effectively.

Anahtar Kavram

Identifying and resolving hot partitions in Amazon DynamoDB by designing high-entropy partition keys or implementing write sharding.
ÖncekiSayfa 13 / 14Sonraki
Troubleshooting and Optimization Alıştırma Soruları — AWS Certified Developer - Associate — Sayfa 13 | Examkin