Soru

Zorluk: OrtaDebugging Lambda Execution and Configuration Issues

A developer has deployed an AWS Lambda function inside the private subnets of a custom VPC. The function processes metadata uploads, writes records to an Amazon Aurora PostgreSQL database located in the same private subnets, and notifies an external analytics endpoint (https://analytics.example.com/api/log) via HTTPS. During testing, the developer notices that the Lambda function intermittently fails due to execution timeouts when calling the external API. Additionally, under heavy concurrent load, the Aurora database runs out of available connections, causing subsequent invocations to fail. The database connection client is currently initialized inside the Lambda handler function.

Which two actions should the developer take to resolve the timeout failures and prevent database connection exhaustion? (Select TWO.)

  1. Update the route table associated with the Lambda function's subnets to route traffic destined for 0.0.0.0/0 to a NAT Gateway.Cevap
  2. Initialize the database connection client outside of the Lambda handler function, allowing the connection to be reused across warm execution contexts.Cevap
  3. C
    Move the Lambda function to the public subnets of the VPC to grant it direct access to the Internet Gateway.
  4. D
    Increase the Lambda function's timeout configuration to 15 minutes to allow sufficient time for new database connections to be established.
  5. E
    Configure the security group attached to the Lambda function to allow inbound HTTPS traffic from the external analytics service's IP addresses.

Cevap

Update the route table associated with the Lambda function's subnets to route traffic destined for 0.0.0.0/0 to a NAT Gateway, and initialize the database connection client outside of the Lambda handler function to reuse it across executions.
The correct options are updating the private subnet route table to point default traffic to a NAT Gateway and initializing the database connection client outside the handler. The NAT Gateway provides the outbound route required for the Lambda function to reach the external analytics endpoint. Moving the database connection logic outside the handler leverages Lambda's execution context reuse, preserving database connection limits.

Adım Adım Çözüm

1
Address the external API timeout issue by configuring network routing.
The Lambda function inside the private VPC subnet can access the internet to call the external HTTP endpoint.
VPC-enabled Lambda functions lack internet access by default. To reach the internet, they must be deployed in private subnets with a route table rule pointing 0.0.0.0/0 traffic to a NAT Gateway located in a public subnet.
2
Address the database connection limit exhaustion by optimizing connection reuse.
Database connections are reused across sequential Lambda invocations on the same execution environment, drastically reducing the total concurrent connection count on the Aurora database.
Initializing connections inside the handler function creates a new PostgreSQL connection per invocation. Moving the initialization outside the handler ensures execution context reuse, meaning warm containers keep their database connections active and reuse them.

Anahtar Kavram

Configuring outbound VPC routing for Lambda and utilizing execution context reuse for resource connection management.
Bu soruyu puanla