Google Professional Cloud Developer Question 33
Single answerGoogle Cloud PlatformYou are developing a cloud-based e-commerce application that requires users to log in and manage their session state across multiple requests. The application is deployed on Google Kubernetes Engine (GKE) with multiple replicas to handle scaling. Which of the following approaches would best ensure consistent and scalable user session management?
- A
Use an in-memory session store like Redis and configure it as a managed service via Memorystore.
- B
Store session data in the local memory of each container instance running on GKE.
- C
Include session tokens in client-side cookies and validate them on each request using a secret key.
- D
Use a Cloud SQL database to store session data for scalability and reliability.
Show answer and explanation
Correct answer: A
Explanation
In a distributed application deployed on GKE, session management must account for scalability and container lifecycle management. Using an in-memory session store like Redis, configured as a managed service via Memorystore, ensures high performance, centralization, and reliability while supporting a stateless architecture. Other approaches either lack scalability, introduce unnecessary latency, or compromise session flexibility.
- A. Correct.
Using an in-memory session store like Redis via Memorystore is a scalable and performant solution for session management in a distributed architecture. It avoids the pitfalls of local storage and provides fast, centralized session storage.
- B. Incorrect.
Storing session data in the local memory of each container instance is not a scalable or reliable solution. Since GKE can scale up or down, session data could be lost if a container is terminated.
- C. Incorrect.
Using session tokens in client-side cookies is a stateless approach, but it may not provide the flexibility needed for advanced session management like expiration or revocation.
- D. Incorrect.
While Cloud SQL can store session data, it is not optimized for high-speed, frequently accessed data like session management. It introduces unnecessary latency compared to in-memory solutions like Redis.