Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

Exam Professional Cloud Architect topic 1 question 4 discussion

Actual exam question from Google's Professional Cloud Architect
Question #: 4
Topic #: 1
[All Professional Cloud Architect Questions]

A news feed 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 problem?

  • A. The session variable is local to just a single instance
  • B. The session variable is being overwritten in Cloud Datastore
  • C. The URL of the API needs to be modified to prevent caching
  • D. The HTTP Expires header needs to be set to -1 stop caching
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
jackdbd
Highly Voted 1 year, 11 months ago
It's A. 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 stateless.
upvoted 96 times
H_S
1 year, 10 months ago
thank you man that is a great explanation
upvoted 2 times
...
AzureDP900
1 year, 6 months ago
I agree with detailed explanation
upvoted 2 times
...
omermahgoub
1 year, 4 months ago
Very well stated, jack. I just wanted to point, GAE is a webserver platform anyway, so making application stateless or stateful is up to the developer and has nothing to do with GAE. The issue is about session consistency. GAE spin new container if there's a need, and based on the code, the session is stored locally, this means, there's no consistency between container, and there's no grantee that the same container might serve the same user. Thank you Jack, very good explanation
upvoted 14 times
...
...
JoeShmoe
Highly Voted 4 years, 5 months ago
A is correct
upvoted 29 times
...
Amor_Apprendido
Most Recent 6 months, 3 weeks ago
Hello Guys, If you have PDF copy of this Cloud Architect course. Please share to this email: [email protected] Please don't ignore.
upvoted 1 times
...
heretolearnazure
8 months ago
very true
upvoted 1 times
...
Badri9898
1 year ago
The most likely cause of the reported issue is that the session variable is local to just a single instance. In the code provided, the sessions variable is a dictionary that stores the viewed news articles for each user. However, this variable is only stored in memory on the instance that handles the request, and it is not shared between instances. Therefore, when a new request is handled by a different instance, it will not have access to the same session data, and the user may see previously viewed news articles. To solve this problem, a shared session management system should be used that can be accessed by all instances. Google App Engine provides a few options for session management, such as using Memcache or Cloud Datastore to store the session data. By using a shared session management system, all instances can access the same session data, and users will not see previously viewed news articles.
upvoted 6 times
...
simonab23
1 year, 2 months ago
A is the right answer
upvoted 1 times
...
jay9114
1 year, 3 months ago
Where in the code does it show that the session variable is local to just a single instance?
upvoted 3 times
...
omermahgoub
1 year, 4 months ago
A The most likely cause of the issue described in the code is that the session variable is local to just a single instance. In this code, the session variable is defined as a local dictionary within the Flask application. This means that it is not shared across different instances of the application and will not be persisted between requests. As a result, when the application is running on multiple instances, each instance will have its own local copy of the session variable, and users may see news articles that they have already viewed on other instances.
upvoted 4 times
omermahgoub
1 year, 4 months ago
To fix this issue, you could consider using a persistent storage solution, such as Cloud Datastore or Cloud SQL, to store the session data in a way that is shared across all instances of the application. This would allow you to maintain a consistent view of the session data for each user across all instances of the application. Other potential causes for this issue, such as modifying the URL of the API to prevent caching or setting the HTTP Expires header to -1 to stop caching, are not related to the issue described in the code and would not likely address the problem.
upvoted 1 times
...
...
Amrit123_
1 year, 4 months ago
A is correct
upvoted 1 times
...
angelumesh
1 year, 4 months ago
Selected Answer: A
stateful variable should be in firestore (redis).
upvoted 1 times
...
Racinely
1 year, 5 months ago
I agree with ackdbd
upvoted 1 times
...
Mahmoud_E
1 year, 6 months ago
Selected Answer: A
A is the correct answer app becoming stateful and it should not be sin case of app engine, cloud run and functions
upvoted 1 times
...
minmin2020
1 year, 6 months ago
Selected Answer: A
A. The session variable is local to just a single instance The others are not relevant
upvoted 1 times
...
sgofficial
1 year, 8 months ago
Thank you that was nice explanation
upvoted 2 times
...
jay9114
1 year, 9 months ago
Where was this presented in the GCP Architecture training & labs?
upvoted 2 times
...
backhand
1 year, 9 months ago
vote A - rule out C,D not thing to do with problem - rule out B, Q is not mention datastore
upvoted 2 times
...
nicoueron
1 year, 10 months ago
Selected Answer: A
A of course, it's just a code pb here
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...