DVA-C02 Question 19
Select 2A company is developing a RESTful API using Amazon API Gateway and AWS Lambda. The API is designed to handle user authentication and store session information. The development team is debating whether to use a stateful or stateless design for the API. Which of the following statements is true about the stateless approach?
- A
Stateless APIs require storing session data on the client side, such as in cookies or tokens, rather than on the server.
- B
Stateless APIs maintain user session information on the server to ensure consistent user experience across requests.
- C
Stateless APIs allow the server to scale more easily since each request is treated independently without relying on prior state.
- D
Stateless APIs are not suitable for distributed systems as they do not support session persistence across multiple servers.
Show answer and explanation
Correct answers: A, C
Explanation
Stateless APIs are designed to treat each request as independent and self-contained, without relying on any stored state on the server. This design choice enhances scalability and reliability, especially in distributed systems, as it eliminates dependencies on server-side session data. Instead, any required state is typically stored on the client side using mechanisms like tokens or cookies. This contrasts with stateful approaches, where the server must track and maintain session information, which can complicate scaling in distributed environments.
- A. Correct.
Correct: Stateless APIs typically store session-related information, such as authentication tokens, on the client side, ensuring that each request is self-contained and does not rely on server-side state.
- B. Incorrect.
Incorrect: This describes a stateful approach, where session information is maintained on the server to track user state across multiple requests.
- C. Correct.
Correct: Stateless APIs are well-suited for scalability because they do not depend on any prior state stored on the server, making it easier to distribute and handle requests across multiple servers.
- D. Incorrect.
Incorrect: Stateless APIs are highly suitable for distributed systems because their independence from server-side state allows for greater flexibility and scalability.