-
Notifications
You must be signed in to change notification settings - Fork 51
docs(function-autoscaler): add function autoscaler docs for self-hosted #1020
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
Open
borao
wants to merge
3
commits into
main
Choose a base branch
from
docs/function-autoscaler-self-hosted
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+250
−92
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,37 +1,55 @@ | ||
| # Function Autoscaling | ||
|
|
||
| The NVCF Function Autoscaler is a distributed Rust service that monitors function utilization and uses it to determine the ideal instance count per function on the NVCF control plane. It runs as a horizontally scaled deployment on the same Kubernetes cluster as the rest of the control plane. | ||
|
|
||
| On an interval, the function autoscaler reads metrics from the timeseries database, decides how many instances each function should have, and calls the NVCF API to apply that decision. | ||
|
|
||
| The function autoscaler depends on a Prometheus-compatible timeseries database fed by the worker pods and invocation-plane services. Without it, the service reports `not ready` and makes no scaling decisions. See [Timeseries database](./architecture.md#timeseries-database) for the required metrics and endpoints. | ||
| The NVCF Function Autoscaler reads function metrics, calculates a desired | ||
| instance count, and sends that count to the NVCF API. It runs in the | ||
| self-hosted control-plane cluster. | ||
|
|
||
| ## Function Autoscaler vs Horizontal Pod Autoscaler | ||
|
|
||
| Function autoscaling is distinct from Kubernetes horizontal pod autoscaling (HPA). HPA scales pods within a single cluster, so it cannot reach NVCF worker pods that are spread across multiple clusters. Function autoscaling orchestrates scaling across clusters using global load patterns. | ||
| Function autoscaling is distinct from Kubernetes horizontal pod autoscaling | ||
| (HPA). HPA scales a Kubernetes workload in one cluster. The Function | ||
| Autoscaler sets the desired instance count for an NVCF function version, which | ||
| can run across NVCF compute clusters. | ||
|
|
||
| ## Key Functionality | ||
|
|
||
| - Discovers active functions from invocation and worker metrics in the timeseries database and persists the active set in Cassandra. | ||
| - Periodically computes a desired instance count per function from recent utilization and the function's scaling policy. | ||
| - Discovers active functions from invocation and worker metrics in the | ||
| timeseries database and persists the active set in Cassandra. | ||
| - Periodically computes a desired instance count per function from recent | ||
| utilization and the function's scaling policy. | ||
| - Applies the desired count by calling the NVCF API's predictions endpoint. | ||
| - Coordinates work across replicas using hash-based bucket assignment and Cassandra Lightweight Transaction (LWT) distributed locks. | ||
| - Coordinates work across replicas using hash-based bucket assignment and | ||
| Cassandra lightweight transaction (LWT) locks. | ||
|
|
||
| ## Self-hosted deployment | ||
|
|
||
| The self-managed control-plane stack defaults to the `control` observability | ||
| profile. The `control` and `all` profiles install the Function Autoscaler. The | ||
| `compute` and `disabled` profiles do not. | ||
|
|
||
| State Metrics must be enabled for `control` and `all`. With the default | ||
| component modes, the control-plane stack also installs the shared collector and | ||
| VictoriaMetrics. See [Observability Configuration](../observability.md) for | ||
| profile and backend settings. | ||
|
|
||
| ## Architecture Overview | ||
|
|
||
| ```mermaid | ||
| flowchart LR | ||
| Workers[Workers / Invocation Services] --> TSDB[(Time Series DB)] | ||
| Services[Metrics endpoints] --> Collector[OpenTelemetry Collector] | ||
| Collector --> TSDB[(VictoriaMetrics or external backend)] | ||
| TSDB --> Autoscaler[Function Autoscaler] | ||
| Autoscaler <--> Cassandra[(Cassandra)] | ||
| Autoscaler --> NVCF[NVCF API] | ||
| ``` | ||
|
|
||
| See [Architecture](./architecture.md#sequence-diagram) for the end-to-end sequence diagram and the bucket model. | ||
| See [Architecture](./architecture.md#sequence-diagram) for the end-to-end | ||
| sequence and bucket model. | ||
|
|
||
| ## See Also | ||
|
|
||
| - [Architecture](./architecture.md) for components, data flow, and the Cassandra LWT lock behavior that elects the discovery leader. | ||
| - [Configure Autoscaling](../configure-autoscaling.md) for setting per-function scaling bounds, factors, thresholds, and stickiness via the NVCF API. | ||
| - [Function Autoscaler Operations](./operations.md) for health endpoints and operational guidance. | ||
| - [Function Autoscaler Observability](./observability.md) for the metrics, traces, and logs emitted by the service. | ||
| - [Observability Configuration](../observability.md) for profiles and metrics backend configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,65 +1,73 @@ | ||
| # Function Autoscaler Operations | ||
|
|
||
| This page covers operating the function autoscaler after deployment, including health probes, common operational issues, and pointers to the Helm chart values. For log filter syntax, metrics, and traces, see [Function Autoscaler Observability](./observability.md). | ||
| The self-managed stack deploys the Function Autoscaler for the `control` and | ||
| `all` observability profiles. State Metrics must remain enabled for both. See | ||
| [Observability Configuration](../observability.md) for profile and metrics | ||
| backend settings. | ||
|
|
||
| ## Health endpoints | ||
|
|
||
| The function autoscaler exposes three HTTP health endpoints. Their exact paths differ from the rest of the NVCF control plane: liveness and readiness are namespaced under `/admin/health/`. | ||
|
|
||
| | Endpoint | Purpose | Use as | | ||
| |----------|---------|--------| | ||
| | `GET /admin/health/liveness` | Always returns 200. Indicates the process is alive. | Kubernetes liveness probe. | | ||
| | `GET /admin/health/readiness` | Returns 200 when all components are healthy, 503 otherwise. | Kubernetes readiness probe. | | ||
| | `GET /health` | Returns per-component health for `cassandra_client` and `timeseries_db_client`. | Operator-facing detail and dashboards. | | ||
|
|
||
| The liveness probe deliberately does not check Cassandra or the timeseries database. Restarting the pod when those are unreachable does not help, so the function autoscaler stays running and lets readiness flip instead. | ||
| Apply an environment change from the self-managed stack directory: | ||
|
|
||
| ## Common operational issues | ||
| ```bash | ||
| make apply HELMFILE_ENV=<environment-name> | ||
| ``` | ||
|
|
||
| ### Cassandra connection failures | ||
| ## Verify the deployment | ||
|
|
||
| Symptoms: readiness flips to 503, `/health` reports the `cassandra_client` component as unhealthy, log lines from `rs_autoscaler::cassandra` show connection errors. | ||
| Check State Metrics and the Function Autoscaler: | ||
|
|
||
| Checks: | ||
| ```bash | ||
| kubectl get deployment -n nvcf \ | ||
| -l app.kubernetes.io/instance=state-metrics | ||
| kubectl get deployment -n nvcf \ | ||
| -l app.kubernetes.io/instance=function-autoscaler | ||
| kubectl rollout status deployment/function-autoscaler -n nvcf | ||
| ``` | ||
|
|
||
| - SSL certificates are mounted at the path expected by `cassandra.ssl`. The function autoscaler container expects the cert directory to exist; create `/etc/app/config` if it is missing. | ||
| - Credentials in the secrets file are valid for the configured keyspace. | ||
| - The contact points resolve from the pod's network namespace. | ||
| Confirm the resolved PromQL endpoint. This ConfigMap does not contain the | ||
| backend credentials: | ||
|
|
||
| ### Timeseries database query failures | ||
| ```bash | ||
| kubectl get configmap -n nvcf function-autoscaler-env \ | ||
| -o jsonpath='{.data.TIMESERIES_DB__TIMESERIES_DB_URL}{"\n"}' | ||
| ``` | ||
|
|
||
| Symptoms: `nvcf_autoscaler.timeseries_db.requests_total` shows a rising error count, `auth_failure_total` or `server_side_failure_total` is non-zero, log lines from `rs_autoscaler::timeseries_db` show 4xx or 5xx responses. | ||
| For the bundled backend, the result should point to `vmsingle` in the | ||
| configured monitoring namespace. For an existing backend, it should match | ||
| `metricsBackend.promqlEndpoint`. | ||
|
|
||
| Checks: | ||
|
|
||
| - `timeseries_db.timeseries_db_url` is reachable from the pod. | ||
| - The bearer token in the secrets file is current. Token rotation is the most common cause of `auth_failure_total` spikes. | ||
| - Query time ranges fit the retention window of the backing store. | ||
|
|
||
| ### NVCF API errors | ||
|
|
||
| Symptoms: `nvcf_autoscaler.nvcf_api.request_duration_milliseconds` shows a sustained rise in 4xx or 5xx, scaling decisions stop applying. | ||
| ## Health endpoints | ||
|
|
||
| Checks: | ||
| The Function Autoscaler exposes three health endpoints: | ||
|
|
||
| - The OAuth2 token endpoint is reachable and the client credentials in the secrets file are valid. | ||
| - The functions being scaled are still in a deployable status. Functions in unexpected states are skipped, not retried. | ||
| - `nvcf_api.disable_auth` is set as intended for the deployment. Leave it `false` whenever the NVCF API enforces authentication. | ||
| | Endpoint | Purpose | Use as | | ||
| | --- | --- | --- | | ||
| | `GET /admin/health/liveness` | Always returns 200. Indicates the process is alive. | Kubernetes liveness probe. | | ||
| | `GET /admin/health/readiness` | Returns 200 when all components are healthy, 503 otherwise. | Kubernetes readiness probe. | | ||
| | `GET /health` | Returns per-component health for `cassandra_client` and `timeseries_db_client`. | Operator-facing detail and dashboards. | | ||
|
|
||
| ### Discovery is stalled | ||
| Inspect the detailed endpoint through the service: | ||
|
|
||
| Symptoms: the active function set in Cassandra stops growing despite traffic to new functions, `nvcf_autoscaler.distributed_lock.acquisition_failures_total` is rising across all replicas. | ||
| ```bash | ||
| kubectl port-forward -n nvcf service/function-autoscaler 8181:8181 | ||
| curl http://127.0.0.1:8181/health | ||
| ``` | ||
|
|
||
| Checks: | ||
| The liveness probe does not check Cassandra or the metrics backend. Dependency | ||
| failures change readiness instead. | ||
|
|
||
| - Inspect the `locks` table for the discovery lock row and its TTL. If the row never expires, the previous leader may have stopped refreshing without releasing it. | ||
| - Confirm at least one replica's `nvcf_autoscaler.distributed_lock` gauge reports the leader state. | ||
| - Restart the holding replica if the cluster is otherwise healthy. The lock expires within `discovery_lock_duration_seconds`. | ||
| ## Troubleshooting | ||
|
|
||
| See [Architecture](./architecture.md#cassandra-lightweight-transactions-lwts) for the lock state machine. | ||
| | Symptom | Check | | ||
| | --- | --- | | ||
| | Function Autoscaler is not installed | Use the `control` or `all` profile. Keep `stateMetrics.enabled: true`. | | ||
| | `cassandra_client` is unhealthy | Check contact-point DNS, credentials, and the configured TLS files. | | ||
| | `timeseries_db_client` is unhealthy | Check the resolved PromQL endpoint, authentication mode, credentials, and backend retention. | | ||
| | Scaling decisions are not applied | Check NVCF API authentication and function status. | | ||
| | Discovery does not find active functions | Confirm the backend contains the request and worker metrics listed in [Architecture](./architecture.md#metrics-backend). Check the discovery lock metrics and TTL. | | ||
|
|
||
| ## See also | ||
|
|
||
| - [Function Autoscaler Observability](./observability.md) for the metrics and traces referenced in the symptoms above. | ||
| - [Configure Autoscaling](../configure-autoscaling.md) for setting per-function scaling bounds and policy via the NVCF API. | ||
| - [Architecture](./architecture.md) for the component layout these symptoms map to. | ||
| - [Observability Configuration](../observability.md) for shared stack settings. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: NVIDIA/nvcf
Length of output: 50368
🏁 Script executed:
Repository: NVIDIA/nvcf
Length of output: 50368
🏁 Script executed:
Repository: NVIDIA/nvcf
Length of output: 50368
🏁 Script executed:
Repository: NVIDIA/nvcf
Length of output: 40153
🏁 Script executed:
Repository: NVIDIA/nvcf
Length of output: 5488
Narrow the fallback wording
The autoscaler falls back only when the initial worker-count query returns no series. It does not fall back after a worker query error or after a cached worker source returns no series. Document these conditions or add handling and tests for them.
🤖 Prompt for AI Agents