DVA-C02 Question 47
Select 3You are developing an e-commerce application hosted on AWS. The application uses Amazon API Gateway and AWS Lambda to handle incoming requests. To ensure the application can scale horizontally and remain resilient, which of the following design approaches should you implement?
- A
Store session state in Amazon DynamoDB instead of in-memory storage.
- B
Design Lambda functions to be stateless by not relying on local file storage.
- C
Use an Elastic Load Balancer to maintain session stickiness with Lambda functions.
- D
Implement Amazon S3 to store user-uploaded files instead of saving them locally in Lambda.
- E
Store the state in the Lambda execution environment for re-use across invocations.
Show answer and explanation
Correct answers: A, B, D
Explanation
Stateless applications are designed to avoid storing client-specific data (such as session state) locally within the application instance. This ensures the application can scale horizontally and handle traffic by distributing requests across multiple instances. By using external services like DynamoDB and S3, and ensuring Lambda remains stateless, the application architecture aligns with the best practices for resilience and scalability in AWS.
- A. Correct.
Correct. Amazon DynamoDB is a managed, highly available database service that can store session state externally, making the application stateless and scalable.
- B. Correct.
Correct. Lambda functions are designed to be stateless, meaning they should not rely on local file storage or execution environments that persist state between invocations.
- C. Incorrect.
Incorrect. Elastic Load Balancers are not used to direct traffic to Lambda functions and maintaining session stickiness contradicts the principle of stateless design.
- D. Correct.
Correct. Using Amazon S3 to store user-uploaded files offloads stateful storage from the application, supporting a stateless and scalable architecture.
- E. Incorrect.
Incorrect. Storing state in the Lambda execution environment is unreliable, as the environment may not persist between invocations, violating the stateless principles.