Soru

Zorluk: KolayServerless Development with AWS Lambda

A developer has deployed an AWS Lambda function that performs CPU-intensive image resizing. During testing, the function successfully processes small image files, but frequently times out when processing larger image files. The developer wants to increase the processing speed of the function to prevent these timeouts. Which configuration change should the developer make?

  1. A
    Increase the function's execution timeout limit to 15 minutes.
  2. B
    Deploy the Lambda function in a private VPC subnet without a NAT gateway or VPC endpoints.
  3. Increase the memory allocation for the Lambda function.Cevap
  4. D
    Hardcode AWS access keys directly in the function initialization code to bypass IAM role evaluation latency.

Cevap

Increase the memory allocation for the Lambda function.
Increasing the memory allocation is the correct solution because AWS Lambda allocates CPU power proportionally to the configured memory. By allocating more memory, the function automatically receives more CPU capacity, which directly speeds up CPU-intensive processing tasks like image resizing.

Adım Adım Çözüm

1
Analyze the cause of the timeout.
The function is performing CPU-intensive work (image resizing) and timing out on larger files.
Identifying that the workload is CPU-bound is critical to selecting the correct optimization strategy.
2
Identify how AWS Lambda allocates CPU resources.
AWS Lambda allocates CPU power proportionally to the configured memory size.
Understanding that increasing memory is the mechanism for increasing CPU power allows for performance optimization.
3
Select the configuration change that increases CPU resource allocation.
Increasing the memory allocation of the function.
Increasing memory will provide more CPU power, speeding up the execution and preventing the timeout.

Anahtar Kavram

AWS Lambda resource allocation and scaling behavior (memory and CPU relationship)
Bu soruyu puanla