问题
There is not documentation that I can find about the storage that Google Cloud Run has. For example, does it contains few Gigabyte storage as we create a VM? If not, is there a '/tmp' folder that I can put data temporarily into during the request? What's the limitation if available?
If neither of them available, what's the recommendation if I want to save some temporary data while running Cloud Run?
回答1:
Cloud Run is a stateless service platform, and does not have any built-in storage mechanism.
Files can be temporarily stored for processing in a container instance, but this storage comes out of the available memory for the service as described in the runtime contract. Maximum memory available to a service is 2 GB.
For persistent storage the recommendation is to integrate with other GCP services that provide storage or databases.
The top services for this are Cloud Storage and Cloud Firestore.
These two are a particularly good match for Cloud Run because they have the most "serverless" compatibility: horizontal scaling to matching the scaling capacity of Cloud Run and the ability to trigger events on state changes to plug into asynchronous, serverless architectures via Cloud Pub/Sub and Cloud Storage's Registering Object Changes and Cloud Functions with Cloud Function Events & Triggers.
回答2:
The writable disk storage is an in-memory filesystem, which limited by instance memory to a maximum of 2GB. Anything written to the filesystem is not persisted between instances.
See:
- https://cloud.google.com/run/quotas
- https://cloud.google.com/run/docs/reference/container-contract#filesystem
来源:https://stackoverflow.com/questions/55908257/whats-the-default-storage-for-google-cloud-run