英文:
How to set a cloud run app to idle state?
问题
在一个相关但不同的问题中,我收到了关于云运行的生命周期的参考1。空闲状态听起来非常适合我的需求,一个应用程序通常如何进入空闲状态,只是调用sleep
并等待传入的HTTP请求,还是需要调用云运行中的一些API函数主动释放其CPU时间?
关于项目的一些背景信息,可能与问题无关:
该应用程序将处理突发性工作,通常每两个小时的工作时间为5-20分钟。目前,工作是通过Pub/Sub复苏的,可能会将多个工作项合并成一个单元,然后将已完成的工作提交到另一个Pub/Sub中。因此,应用程序本身知道何时工作繁忙以及何时处于空闲状态,因此这一部分引起了我的注意。如果这将使生命周期更容易,我可能会重新设计流程以使用HTTP。
英文:
In an related but different question I was given a reference to Lifetime of a cloud run
The idle state sounds great for my needs, how would an app typically enter the idle state, just calling sleep
and wait for an incoming http request, or does it need to call some API functions in the Cloud Run to voluntarily give up its CPU time?
Some background about the project probably not relevant for the question:
The app will handle work in bursts typicality 5-20 minutes of work every other hour. Currently the work is revived on a pubsub, when possible several items of work are combined into one unit and then recites of completed work is submitted on another pubsub.
So the app itself is aware of when it is working hard and when it is idle, hence this section caught my attention. I could potentiality redesign the flow to use http if that will make the lifetime easier.
答案1
得分: 1
Cloud Run
实例在不接收任何请求时会进入空闲状态。您无需采取任何措施。当 Cloud Run
容器处于空闲状态时,其 CPU
会被限制在接近零的水平。这意味着您的应用程序将以非常缓慢的速度运行,但您不会被收取 CPU
时间的费用。
英文:
Cloud run
instances become idle, if they are not receiving any requests. You don't need to do anything. When a Cloud Run container is idle, its CPU
is throttled to nearly zero. This means that your application will run at a very slow pace, but you won't be charged for the CPU
time.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论