PROFESSIONAL-CLOUD-ARCHITECT · Question #30
A news teed web service has the following code running on Google App Engine. During peak load, users report that they can see news articles they already viewed. What is the most likely cause of this…
The correct answer is A. The session variable is local to just a single instance. AppEngine spins up new containers automatically according to the load. During peak traffic, HTTP requests originated by the same user could be served by different containers. Given that the variable sessions is recreated for each container, it might store different data. The…
Question
Options
- AThe session variable is local to just a single instance.
- BThe session variable is being overwritten in Cloud Datastore.
- CThe URL of the API needs to be modified to prevent caching.
- DThe HTTP Expires header needs to be set to -1 to stop caching.
How the community answered
(22 responses)- A64% (14)
- B23% (5)
- C5% (1)
- D9% (2)
Explanation
AppEngine spins up new containers automatically according to the load. During peak traffic, HTTP requests originated by the same user could be served by different containers. Given that the variable sessions is recreated for each container, it might store different data. The problem here is that this Flask app is stateful. The sessions variable is the state of this app. And stateful variables in AppEngine / Cloud Run / Cloud Functions are problematic. A solution would be to store the session in some database (e.g. Firestore, Memorystore) and retrieve it from there. This way the app would fetch the session from a single place and would be
Topics
Community Discussion
No community discussion yet for this question.