Coder Social home page Coder Social logo

resousse / cloudrun-stay-awake Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 16 KB

Python implementation to minimize/reduce the cold start of the GCP Cloud Run container by doing a self call when the container is about to expire

License: Apache License 2.0

Dockerfile 18.27% Python 81.73%
cloudrun gcp coldstart

cloudrun-stay-awake's Introduction

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.

cloudrun-stay-awake's People

Contributors

resousse avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.