DVA-C02 Question 45
Select 4You are designing a stateless web application hosted on Amazon ECS (Elastic Container Service) and need to ensure the application can scale horizontally while maintaining its stateless nature. Which of the following design choices should you implement?
- A
Store user session data in Amazon ElastiCache.
- B
Use a shared Amazon EFS file system to persist application state across ECS tasks.
- C
Store application logs in Amazon S3 for centralized access and durability.
- D
Use environment variables in the ECS task definition to pass configuration settings.
- E
Save file uploads directly to Amazon S3 instead of local ephemeral storage.
Show answer and explanation
Correct answers: A, C, D, E
Explanation
Stateless applications do not retain information about previous requests or sessions. To maintain statelessness, all stateful data (e.g., sessions, logs, file uploads) should be externalized to services like Amazon S3, ElastiCache, or DynamoDB. This allows the application to scale horizontally, as no instance-specific information is required. Using environment variables for configuration ensures the application can run independently of specific instances.
- A. Correct.
Correct: Storing user session data in Amazon ElastiCache ensures the application remains stateless by offloading session management to an external service.
- B. Incorrect.
Incorrect: Using Amazon EFS to share file storage across ECS tasks would make the application stateful, violating the principles of statelessness.
- C. Correct.
Correct: Storing logs in Amazon S3 offloads stateful data like logs from the application, preserving its stateless nature.
- D. Correct.
Correct: Using environment variables in the ECS task definition provides configuration without embedding state directly in the application.
- E. Correct.
Correct: Saving file uploads to Amazon S3 ensures the application does not rely on local storage, maintaining its stateless design.