Cloud Run Stay Awake
Python implementation of the cold start mitigation proposed by @guillaumeblaquiere (already implemented in Go & NodeJS )
Purpose
A Cloud Run GCP service stop after an idle period, this time cannot be forseen. As a result, the next request after the stop, will have a cold start, a delay of one or several seconds, Cloud Run takes to start a new container. One of the cheap solutions proposed by Guillaume (https://medium.com/google-cloud/3-solutions-to-mitigate-the-cold-starts-on-cloud-run-8c60f0ae7894) is to schedule an http call every minute to keep alive the service. However this solution is not accurate as the stop can occurs in less than a minute after the last request. And Cloud Scheduling can't go under a minute.
Another solutions is presented to trigger the stop signal (a SIGTERM signal) to self call the service to try to keep it alive. This is what this code is about.
How to Use
Easy steps:
pip install cloudRunStayAwake- In the main file of your code (Flask, Django, other...), add
import cloudRunStayAwake
Tests
In case you want to perform some tests before deploying to your code, there is a Dockerfile that can be used to test it on Cloud Run
License
This library is licensed under Apache 2.0. Full license text is available in LICENSE.
Metadata
Release files for cloudRunStayAwake 1.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cloudRunStayAwake-1.0.5-py3-none-any.whl | Python 3 | none | any | Details for cloudRunStayAwake-1.0.5-py3-none-any.whl |
Release files / cloudRunStayAwake-1.0.5-py3-none-any.whl
| Download URL | cloudRunStayAwake-1.0.5-py3-none-any.whl |
|---|---|
| Size | 12.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
513f79e0d69722587797515ede43dec25d475a3fab6a4dc59f9bf9f1e95c4b07
|
|
BLAKE2b-256 checksum How to use checksums |
3999a58a7e5d17adfac1a50d6549f6b0979b8a757ae59bf64f5bd8b88b51f19d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.6
|
Security for cloudRunStayAwake 1.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.