You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that we could provider a cleaner workflow for this in faas-netes by using annotations. I think an ideal workflow would look something like this
add a new flag/env variable "hpa-scaling-enabled" to the faas-netes server
add a configuration to the Helm chart to enable this
we could even add a pre-install hook to check for the metrics-server to ensure the cluster is ready
During a function deployment, we check the function annotations and create a corresponding HPA object targeting the function. This means we create 3 k8s object: a Service, a Deployment, and a HorizontalPodAutoscaler.
during deletes, we of course delete all three objects
Doing this should significantly simplify these more advanced use-cases. This could be especially useful for async workflows that should be scaled on metrics like queue depth or cpu/memory usage instead of requests per second.
Supporting one or multiple is relatively easy by just sorting and filtering the annotations on the string com.openfaas.scale.metric
The serialization and keys names are of course up to debate.
A note about validation: I think we can roll this out iteratively, starting with built-in metrics and then expanding to custom metrics. When we add support for custom metrics, we should add validation for or automatically inject the prometheus scrape annoations that are required to ensure the metrics exist.
A Note about Sidecars: In k8s 1.20+ we can also create container resource metrics using ContainerResource which we can use to target just the function container. This is useful in clusters that have sidecar injection, for example clusters using a service mesh or some of the tracing deployments. We should sniff the cluster version and prefer this object instead of the more generic Resource
The text was updated successfully, but these errors were encountered:
Hi @LucasRoesler thanks for sharing your thoughts here. This is something that Stefan had mentioned a few times in the past.
We also have some good documentation on how to configure HPAv2 (that you also mentioned). What I found in testing was that HPAv2 was more heavy-weight - relying on several extra components for custom metrics usage, and also lagged so was not as responsive for bursting workloads, it took up to 15 minutes as I remember to start scaling down.
My question is: have you seen any customer demand for this? Any comments or issues that you can reference?
A frequent question that happens in Slack is questions about alternative ways to control scaling and/or instance placement in a cluster. We already have a tutorial about how to replace the default request-rate auto-scaling with metrics based scaling via HPA in Kubernetes. See openfaas/docs#164, https://docs.openfaas.com/tutorials/kubernetes-hpa/, https://docs.openfaas.com/tutorials/kubernetes-hpa-custom-metrics/
Overview
It seems that we could provider a cleaner workflow for this in faas-netes by using annotations. I think an ideal workflow would look something like this
Doing this should significantly simplify these more advanced use-cases. This could be especially useful for async workflows that should be scaled on metrics like queue depth or cpu/memory usage instead of requests per second.
Details
The HPA walkthrough in the k8s docs gives an advanced example that looks like this
The simplest implementation would support a single metric for scaling and map 1:1 to the fields, for example
would become these annotations
Alternatively, to support multiple metrics we could use a key=value format
a single rule could look like
Supporting one or multiple is relatively easy by just sorting and filtering the annotations on the string
com.openfaas.scale.metric
The serialization and keys names are of course up to debate.
A note about validation: I think we can roll this out iteratively, starting with built-in metrics and then expanding to custom metrics. When we add support for custom metrics, we should add validation for or automatically inject the prometheus scrape annoations that are required to ensure the metrics exist.
A Note about Sidecars: In k8s 1.20+ we can also create container resource metrics using
ContainerResource
which we can use to target just the function container. This is useful in clusters that have sidecar injection, for example clusters using a service mesh or some of the tracing deployments. We should sniff the cluster version and prefer this object instead of the more genericResource
The text was updated successfully, but these errors were encountered: