|
| 1 | +# VPA Performance Benchmark |
| 2 | + |
| 3 | +Measures VPA component latencies using KWOK (Kubernetes WithOut Kubelet) to simulate pods without real resource consumption. |
| 4 | + |
| 5 | +> **Note:** Currently only updater metrics are collected. Recommender metrics are planned for the future. |
| 6 | +
|
| 7 | +<!-- toc --> |
| 8 | +- [Prerequisites](#prerequisites) |
| 9 | +- [Quick Start](#quick-start) |
| 10 | +- [What It Does](#what-it-does) |
| 11 | +- [Profiles](#profiles) |
| 12 | +- [Flags](#flags) |
| 13 | +- [Metrics Collected](#metrics-collected) |
| 14 | + - [Updater Metrics](#updater-metrics) |
| 15 | +- [Cleanup](#cleanup) |
| 16 | +- [Notes](#notes) |
| 17 | + - [Performance Optimizations](#performance-optimizations) |
| 18 | + - [Caveats](#caveats) |
| 19 | +<!-- /toc --> |
| 20 | + |
| 21 | +## Prerequisites |
| 22 | + |
| 23 | +- Go 1.21+ |
| 24 | +- kubectl |
| 25 | +- Kind |
| 26 | +- yq |
| 27 | + |
| 28 | +## Quick Start |
| 29 | + |
| 30 | +```bash |
| 31 | +# Create a Kind cluster with tuned settings |
| 32 | +kind create cluster --config=benchmark/kind-config.yaml |
| 33 | + |
| 34 | +# Deploy VPA |
| 35 | +./hack/deploy-for-e2e-locally.sh full-vpa |
| 36 | + |
| 37 | +# Build and run |
| 38 | +go build -C benchmark -o ../bin/vpa-benchmark . |
| 39 | +# requires --kubeconfig flag, KUBECONFIG env var, or ~/.kube/config |
| 40 | +bin/vpa-benchmark --profile=small --output=results.txt |
| 41 | +``` |
| 42 | + |
| 43 | +## What It Does |
| 44 | + |
| 45 | +1. Installs KWOK and creates a fake node |
| 46 | +2. Configures VPA deployments with higher QPS/burst limits |
| 47 | +3. For each profile run: |
| 48 | + - Scales down VPA components |
| 49 | + - Cleans up previous benchmark resources |
| 50 | + - Creates ReplicaSets with fake pods assigned directly to KWOK node (bypasses scheduler) |
| 51 | + - Creates VPAs targeting those ReplicaSets |
| 52 | + - Scales up recommender, waits for recommendations |
| 53 | + - Scales up updater, waits for its loop to complete |
| 54 | + - Scrapes `vpa_updater_execution_latency_seconds_sum` metrics |
| 55 | +4. Outputs results to stdout and/or a CSV file if specified |
| 56 | + |
| 57 | +e.g., of output using this command: `bin/vpa-benchmark --profile=small,large,xxlarge` |
| 58 | + |
| 59 | +```bash |
| 60 | +========== Results ========== |
| 61 | +┌───────────────┬───────────────┬────────────────┬───────────────────┐ |
| 62 | +│ STEP │ SMALL ( 25 ) │ LARGE ( 250 ) │ XXLARGE ( 1000 ) │ |
| 63 | +├───────────────┼───────────────┼────────────────┼───────────────────┤ |
| 64 | +│ AdmissionInit │ 0.0000s │ 0.0001s │ 0.0004s │ |
| 65 | +│ EvictPods │ 2.4239s │ 24.5535s │ 98.6963s │ |
| 66 | +│ FilterPods │ 0.0002s │ 0.0020s │ 0.0925s │ |
| 67 | +│ ListPods │ 0.0001s │ 0.0006s │ 0.0025s │ |
| 68 | +│ ListVPAs │ 0.0024s │ 0.0030s │ 0.0027s │ |
| 69 | +│ total │ 2.4267s │ 24.5592s │ 98.7945s │ |
| 70 | +└───────────────┴───────────────┴────────────────┴───────────────────┘ |
| 71 | +``` |
| 72 | + |
| 73 | +We can then compare the results of a code change with the results of the main branch. |
| 74 | +Ideally the benchmark would be done on the same machine (or a similar one), with the same benchmark settings (profiles and runs). |
| 75 | + |
| 76 | +## Profiles |
| 77 | + |
| 78 | +| Profile | VPAs | ReplicaSets | Pods | |
| 79 | +| ------- | ---- | ----------- | ---- | |
| 80 | +| small | 25 | 25 | 50 | |
| 81 | +| medium | 100 | 100 | 200 | |
| 82 | +| large | 250 | 250 | 500 | |
| 83 | +| xlarge | 500 | 500 | 1000 | |
| 84 | +| xxlarge | 1000 | 1000 | 2000 | |
| 85 | + |
| 86 | +## Flags |
| 87 | + |
| 88 | +| Flag | Default | Description | |
| 89 | +| ---- | ------- | ----------- | |
| 90 | +| `--profile` | small | Comma-separated profiles to run. You can run multiple profiles at once. (e.g., `--profile=small,medium`) | |
| 91 | +| `--runs` | 1 | Iterations per profile. This is used for averaging multiple runs. | |
| 92 | +| `--output` | "" | Path to output file for results table (CSV format). Output will always be printed to stdout. | |
| 93 | +| `--kubeconfig` | "" | Path to kubeconfig. Required if not using KUBECONFIG env var or ~/.kube/config. | |
| 94 | + |
| 95 | +## Metrics Collected |
| 96 | + |
| 97 | +### Updater Metrics |
| 98 | + |
| 99 | +| Metric | Description | |
| 100 | +| ------ | ----------- | |
| 101 | +| `ListVPAs` | List VPA objects | |
| 102 | +| `ListPods` | List pods matching VPA targets | |
| 103 | +| `FilterPods` | Filter evictable pods | |
| 104 | +| `AdmissionInit` | Verify admission controller status | |
| 105 | +| `EvictPods` | Evict pods needing updates | |
| 106 | +| `total` | Total loop time | |
| 107 | + |
| 108 | +## Cleanup |
| 109 | + |
| 110 | +```bash |
| 111 | +kind delete cluster |
| 112 | +``` |
| 113 | + |
| 114 | +## Notes |
| 115 | + |
| 116 | +### Performance Optimizations |
| 117 | + |
| 118 | +The benchmark includes several performance optimizations: |
| 119 | + |
| 120 | +- Modifies VPA deployments at startup using `yq`: |
| 121 | + - Sets `--kube-api-qps=100` and `--kube-api-burst=200` on all three components |
| 122 | + - Sets `--updater-interval=2m` on the updater (default is 60s) |
| 123 | +- Pods are assigned directly to the KWOK node via `nodeName`, bypassing the scheduler for faster creation |
| 124 | +- The `kind-config.yaml` increases API server limits (`max-requests-inflight`, `max-mutating-requests-inflight`) and kube-controller-manager client QPS to handle the large number of API calls |
| 125 | +- Uses ReplicaSets instead of Deployments to skip the Deployment controller layer and speed up pod creation, but keep a targetRef for VPA |
| 126 | + |
| 127 | +### Caveats |
| 128 | + |
| 129 | +- The updater uses `time.Tick` which waits the full interval before the first tick, so the benchmark sleeps 2 minutes before polling for metrics |
| 130 | +- The benchmark uses Recreate update mode. In-place scaling is not supported on KWOK pods. |
| 131 | +- The benchmark scales down all VPA components at the start of each run, so that any caching is not a factor. |
0 commit comments