-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: scale new functions down to zero which have never been invoked #979
Comments
Thanks for your detailed proposal @cedricvidal ! I like solution 3 as well (would like to hear other's thoughts, too). I'm surprised replicas 0 isn't collected when it is deployed for the first time. I thought all the services were collected with Replicas count. |
I'm hoping for some more direction from @kenfdev then we'll try to find someone to help with this work. |
Okay, having a more detailed look, I realized that I wasn't understanding the circumstance well and solution 3 probably won't be a easy change. The metrics for e.g.
IMHO, I think this is faas-idler's responsibility. It already collects all the functions by requesting the gateway here. But unfortunately, it gets no results due to the PromQL targeted to I haven't looked deep into WDYT? |
I would agree with your analysis @kenfdev. Implementing this in the idler is possible, but will be orthogonal since it will only cover an edge-case for functions which have never been invoked but have more than 0 replicas. At the moment it's probably the best option we have and should be a reasonably small fix here: https://github.com/openfaas-incubator/faas-idler/blob/master/main.go#L114 If there is no data, or the invocation count is zero, we'd have to still enter the checking code and then find out if there are replicas. If there are replicas and either we have no stats or the stats are zero, then we scale down. Alex |
@kenfdev You're welcome Hum, that being said, is it possible to take into account the healthiness of the function? In case the function has no metrics, scale it down only if it's healthy? Otherwise, it could potentially hide startup problems until the function is used for the first time. This is contrary to the principle of detecting problems as early as possible. |
FYI @rgee0 started looking at this. |
Is there any update for this issue? Thanks. @alexellis |
@hotjunfeng there's a new version of faas-idler which you can take from @rgee0. |
@alexellis I found that the new version of @rgee0 has been merged to faas-idler. I have run the latest version but it still does not work. In other words, my function can not scale to zero when there is no request for some time. |
Which specific version did you use? Richard tests all his changes thoroughly, so I would be surprised if that were the case. |
@alexellis The specific version is: Your Environment
|
@rgee0 PTAL |
Is this still an issue? It's been open for quite some time, and in my experience functions are idled all the time in a manner in which I would consider mostly intuitive. That, and scale-to-zero is an OpenFaaS Pro feature now, so I don't think the idler really lives in this specific project anymore. |
Expected Behaviour
When deploying a function for the first time with
com.openfaas.scale.zero: true
andfaas-idler
's-dry-run
isfalse
, I expect my function to be idled, ie scaled down to zero after deployment but it isn't.Current Behaviour
Currently, the function replicas will be set upon deployment to
com.openfaas.scale.min
which defaults to 1.Despite the fact that
com.openfaas.scale.zero: true
, the faas-idler is not indry-run
mode and my function is not used, its replica stays to its minimum and my function is not idled.The faas-idler kicks in only when the metric is present in prometheus, the function is ignored otherwise. When a function is deployed for the first time, its metrics are not yet in prometheus, they are collected only after the function is used for the first time.
Possible Solutions
It looks to me that solution 3 is the best, less moving parts.
Note from @alexellis :
Optionally, another consideration is I think that however it is implemented, one should not idle a non healthy function. If the function is not healthy, doesn't start for some reason and is idled by the faas-idler, one might never know that the function is broken until the function is first used.
Context
For the context, I would like to use OpenFAAS to deploy GPU deep learning models to multiple demo environments. Since they are very heavy and costly to run, I would like them to be only started when actually used.
Your Environment
faas-cli version
):docker version
(e.g. Docker 17.0.05 ):Are you using Docker Swarm or Kubernetes (FaaS-netes)?
Kubernetes
Operating System and version (e.g. Linux, Windows, MacOS):
OSX
Link to your project or a code example to reproduce issue:
Verbatim java8 sample
The text was updated successfully, but these errors were encountered: