
Answer-first summary for fast verification
Answer: Configure provisioned concurrency for the Lambda function that handles the requests.
**Explanation:** **Why Option B is correct:** 1. **Cold start latency reduction:** The problem states that the Lambda function loads many libraries when it receives requests. This indicates significant cold start latency. Provisioned concurrency keeps a specified number of Lambda function instances initialized and ready to respond to requests immediately, eliminating cold start delays. 2. **Fewest changes to operations:** Configuring provisioned concurrency requires minimal operational changes compared to other options - it's a simple configuration change in Lambda settings. 3. **Addresses the root cause:** The main latency issue described is the time spent loading libraries (cold start), not database query performance or network latency. **Why other options are incorrect:** **Option A:** Establishing a direct connection between the frontend and database: - **Security risk:** Exposes the database directly to the internet/frontend, bypassing API Gateway's security features - **Architectural anti-pattern:** Violates the separation of concerns principle - **Doesn't address cold starts:** The main latency issue is Lambda cold starts, not API Gateway latency **Option C:** Caching results in Amazon S3: - **Inappropriate cache solution:** S3 is for object storage, not for low-latency query caching - **Better alternatives exist:** Amazon ElastiCache or DynamoDB would be more suitable for caching - **Doesn't address cold starts:** The latency issue is in Lambda initialization, not data retrieval **Option D:** Increasing database size: - **Costly and inefficient:** Scaling up the database is expensive and doesn't address the actual problem - **Wrong bottleneck:** The issue is Lambda cold starts, not database connection limits - **No impact on library loading:** Database size has no effect on Lambda function initialization time **Additional context:** - **Provisioned concurrency** keeps Lambda functions initialized, which is perfect for applications with infrequent traffic patterns or high initialization overhead - **Alternative considerations:** If the data processing is complex, consider using Lambda layers for shared libraries or optimizing the function initialization code - **Monitoring:** Use AWS X-Ray to identify specific latency bottlenecks in the Lambda execution
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
A company hosts a frontend application that uses an Amazon API Gateway API backend that is integrated with AWS Lambda. When the API receives requests, the Lambda function loads many libraries. Then the Lambda function connects to an Amazon RDS database, processes the data, and returns the data to the frontend application. The company wants to ensure that response latency is as low as possible for all its users with the fewest number of changes to the company's operations.
Which solution will meet these requirements?
A
Establish a connection between the frontend application and the database to make queries faster by bypassing the API.
B
Configure provisioned concurrency for the Lambda function that handles the requests.
C
Cache the results of the queries in Amazon S3 for faster retrieval of similar datasets.
D
Increase the size of the database to increase the number of connections Lambda can establish at one time.