Issue
I have a flask app that I'm using Google Cloud to host. Part of its data is an SQL database that is updated by user actions. However, I am finding that this database is being regularly reset to its original value every few days. Is there a way to disable this functionality so that any user data added during a session is saved to the cloud?
For reference, here is my app.yaml file:
runtime: python
env: flex
entrypoint: gunicorn -b :$PORT main:app --timeout 300
runtime_config:
python_version: 3
manual_scaling:
instances: 1
resources:
cpu: 1
memory_gb: 0.5
disk_size_gb: 10
Solution
App Engine instances restart at least once a week. I'm unable to find this piece of doc again. But the instance need to be patched and have other maintenances operation, that's why it's roughly once a week.
In addition, the documentation mention clearly that, after a while, the uptime is now longer guarantee: physical outage or maintenance can occur
In addition, the principle of serverless application is to be stateless. It can scale up and down more easily without any disk attachment, concurrent read or whatever.
All the data loaded on your App Engine instance live in memory and are swapped when the instances is shut down. And because the containers are immutable, your data are definitively lost
Therefore, you have to design your application to store the data outside the serverless service, in a managed database like Cloud SQL for instance.
Answered By - guillaume blaquiere
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.