Google Professional Cloud Developer Question 31
Single answerGoogle Cloud PlatformYou are developing a web application on Google Cloud that requires managing user sessions for an e-commerce platform. The application must ensure session consistency while scaling across multiple instances. Which approach should you use to manage user session data effectively?
- A
Store session data in Google Cloud Firestore with automatic synchronization.
- B
Use in-memory session storage on each instance to handle user sessions.
- C
Leverage Google Cloud Memorystore (Redis) to store session data in a centralized cache.
- D
Store session data in instance-specific local files for faster access.
Show answer and explanation
Correct answer: C
Explanation
The primary requirement is to maintain session consistency across multiple instances while scaling. Google Cloud Memorystore (Redis) is the best choice for managing user session data in this scenario because it provides a centralized, low-latency cache that is ideal for session storage. Other options either fail to meet the consistency requirements or are not optimized for real-time session management.
- A. Incorrect.
Firestore is a scalable NoSQL database suitable for long-term storage, but it is not optimized for low-latency session management in real-time applications.
- B. Incorrect.
In-memory session storage on individual instances does not support session consistency, as user sessions can be lost if the instance is terminated or if traffic is routed to another instance.
- C. Correct.
Memorystore (Redis) is a fully managed, low-latency, in-memory data store that supports centralized session storage. It enables shared access to session data across multiple instances, ensuring scalability and consistency.
- D. Incorrect.
Local file storage is not recommended for session data in a distributed environment because it lacks scalability and data consistency across instances.