SAA-C03 Question 111
Single answerYou are designing a microservices-based application on AWS. One of the services processes user requests and stores session data temporarily. The team is debating whether to use a stateless or stateful architecture for the service. Which design choice aligns with microservices best practices?
- A
Design the service as stateless and store session data in an external data store like Amazon DynamoDB or ElastiCache.
- B
Design the service as stateful and store session data within the service's local memory.
- C
Design the service as stateful and use Amazon S3 for session storage.
- D
Design the service as stateless but store session data directly in each service instance's local disk.
Show answer and explanation
Correct answer: A
Explanation
Microservices should be stateless to ensure they can scale horizontally and handle failures effectively. This involves offloading any stateful information, such as session data, to external systems like DynamoDB or ElastiCache. By doing so, individual service instances remain independent and replaceable, which supports fault tolerance and scalability.
- A. Correct.
This is correct. Microservices are best designed to be stateless, as this allows them to scale horizontally and be more resilient. Storing session data in an external store like Amazon DynamoDB or ElastiCache ensures session data is available independently of the service instance.
- B. Incorrect.
This is incorrect. A stateful service ties session data to a specific instance, which makes horizontal scaling and failover more difficult, violating microservices best practices.
- C. Incorrect.
This is incorrect. While Amazon S3 is a great storage solution for many use cases, it is not suitable for session storage due to its higher latency compared to in-memory stores like ElastiCache or databases like DynamoDB.
- D. Incorrect.
This is incorrect. Storing session data directly on the local disk of each instance makes the service stateful, as the data is tied to specific instances. This approach does not align with microservices best practices.