|
| 1 | +# Performance Troubleshooting |
| 2 | + |
| 3 | +This guide helps diagnose and address potential performance issues when running Retina, particularly the `packetparser` plugin on high-core-count systems. |
| 4 | + |
| 5 | +## Background |
| 6 | + |
| 7 | +Community users have reported performance considerations when running the `packetparser` plugin (used in Advanced metrics mode) on systems with high CPU core counts under sustained network load. For detailed background, see the [`packetparser` performance considerations](../03-Metrics/plugins/Linux/packetparser.md#performance-considerations). |
| 8 | + |
| 9 | +## Symptoms to Monitor |
| 10 | + |
| 11 | +Watch for these indicators after deploying Retina: |
| 12 | + |
| 13 | +- **Decreased network throughput** compared to baseline |
| 14 | +- **High CPU usage** by Retina agent pods |
| 15 | +- **Elevated context switches** on nodes running Retina |
| 16 | +- **Increased latency** in network-intensive applications |
| 17 | + |
| 18 | +## Diagnostic Steps |
| 19 | + |
| 20 | +### Step 1: Identify Your Configuration |
| 21 | + |
| 22 | +Check which plugins are enabled: |
| 23 | + |
| 24 | +```bash |
| 25 | +kubectl get configmap retina-config -n kube-system -o yaml | grep enabledPlugin |
| 26 | +``` |
| 27 | + |
| 28 | +If `packetparser` is enabled, you're running Advanced metrics mode which is more resource-intensive. |
| 29 | + |
| 30 | +### Step 2: Check Node Specifications |
| 31 | + |
| 32 | +```bash |
| 33 | +# Check core count on nodes |
| 34 | +kubectl get nodes -o custom-columns=NAME:.metadata.name,CPU:.status.capacity.cpu |
| 35 | + |
| 36 | +# Identify nodes with high core counts (32+) |
| 37 | +kubectl get nodes -o json | jq '.items[] | select((.status.capacity.cpu | tonumber) >= 32) | {name: .metadata.name, cpu: .status.capacity.cpu}' |
| 38 | +``` |
| 39 | + |
| 40 | +### Step 3: Monitor Retina Resource Usage |
| 41 | + |
| 42 | +```bash |
| 43 | +# Check CPU and memory usage of Retina pods |
| 44 | +kubectl top pods -n kube-system -l app=retina |
| 45 | + |
| 46 | +# For more detailed analysis, check specific pod on a node |
| 47 | +RETINA_POD=$(kubectl get pods -n kube-system -l app=retina -o jsonpath='{.items[0].metadata.name}') |
| 48 | +kubectl top pod $RETINA_POD -n kube-system |
| 49 | +``` |
| 50 | + |
| 51 | +### Step 4: Establish Performance Baseline |
| 52 | + |
| 53 | +Before and after Retina deployment, measure: |
| 54 | + |
| 55 | +- Network throughput (using your application's metrics or tools like iperf3) |
| 56 | +- Application response times |
| 57 | +- CPU utilization on nodes |
| 58 | + |
| 59 | +## Mitigation Options |
| 60 | + |
| 61 | +If you observe performance impact, consider these approaches: |
| 62 | + |
| 63 | +### Option 1: Use Basic Metrics Mode (Recommended) |
| 64 | + |
| 65 | +Basic metrics mode provides node-level observability without the `packetparser` plugin: |
| 66 | + |
| 67 | +```bash |
| 68 | +# Reinstall or upgrade Retina without packetparser |
| 69 | +helm upgrade retina oci://ghcr.io/microsoft/retina/charts/retina \ |
| 70 | + --set enabledPlugin_linux="\[dropreason\,packetforward\,linuxutil\,dns\]" \ |
| 71 | + --reuse-values |
| 72 | +``` |
| 73 | + |
| 74 | +**Trade-off:** You'll have node-level metrics only, not pod-level metrics. |
| 75 | + |
| 76 | +### Option 2: Enable Data Sampling |
| 77 | + |
| 78 | +Reduce event volume by sampling packets: |
| 79 | + |
| 80 | +```yaml |
| 81 | +apiVersion: v1 |
| 82 | +kind: ConfigMap |
| 83 | +metadata: |
| 84 | + name: retina-config |
| 85 | + namespace: kube-system |
| 86 | +data: |
| 87 | + config.yaml: | |
| 88 | + dataSamplingRate: 10 # Sample 1 out of every 10 packets |
| 89 | +``` |
| 90 | +
|
| 91 | +**Trade-off:** Reduced data granularity, but lower overhead. |
| 92 | +
|
| 93 | +### Option 3: Use High Data Aggregation Level |
| 94 | +
|
| 95 | +Reduce events at the eBPF level: |
| 96 | +
|
| 97 | +```yaml |
| 98 | +apiVersion: v1 |
| 99 | +kind: ConfigMap |
| 100 | +metadata: |
| 101 | + name: retina-config |
| 102 | + namespace: kube-system |
| 103 | +data: |
| 104 | + config.yaml: | |
| 105 | + dataAggregationLevel: "high" |
| 106 | +``` |
| 107 | +
|
| 108 | +**Trade-off:** Disables host interface monitoring; API server latency metrics may be less reliable. |
| 109 | +
|
| 110 | +### Option 4: Selective Deployment |
| 111 | +
|
| 112 | +Deploy Retina only on nodes where you need detailed observability: |
| 113 | +
|
| 114 | +```yaml |
| 115 | +# Use node selectors or taints/tolerations |
| 116 | +apiVersion: apps/v1 |
| 117 | +kind: DaemonSet |
| 118 | +spec: |
| 119 | + template: |
| 120 | + spec: |
| 121 | + nodeSelector: |
| 122 | + retina-enabled: "true" |
| 123 | +``` |
| 124 | +
|
| 125 | +## Advanced Diagnostics |
| 126 | +
|
| 127 | +### Inspecting eBPF Maps |
| 128 | +
|
| 129 | +To see what data structures Retina is using: |
| 130 | +
|
| 131 | +```bash |
| 132 | +# Access the node |
| 133 | +kubectl debug node/<node-name> -it --image=ubuntu |
| 134 | + |
| 135 | +# In the debug container, enter the host namespace |
| 136 | +chroot /host |
| 137 | + |
| 138 | +# List BPF maps (requires bpftool) |
| 139 | +bpftool map list | grep retina |
| 140 | + |
| 141 | +# Check the packetparser map type |
| 142 | +bpftool map show name retina_packetparser_events |
| 143 | +``` |
| 144 | + |
| 145 | +Currently, `packetparser` uses `BPF_MAP_TYPE_PERF_EVENT_ARRAY`. |
| 146 | + |
| 147 | +### Monitoring Event Rates (Advanced) |
| 148 | + |
| 149 | +If you have bpftrace available on nodes: |
| 150 | + |
| 151 | +```bash |
| 152 | +# Monitor perf_event activity |
| 153 | +sudo bpftrace -e ' |
| 154 | + kprobe:perf_event_output { @events = count(); } |
| 155 | + interval:s:5 { print(@events); clear(@events); } |
| 156 | +' |
| 157 | +``` |
| 158 | + |
| 159 | +High event rates may correlate with increased CPU usage. |
| 160 | + |
| 161 | +## Reporting Issues |
| 162 | + |
| 163 | +If you experience performance issues, please report them with: |
| 164 | + |
| 165 | +1. **Node specifications**: CPU count, memory, kernel version |
| 166 | +2. **Retina configuration**: Version, enabled plugins, configuration settings |
| 167 | +3. **Workload characteristics**: Network throughput, number of pods, traffic patterns |
| 168 | +4. **Performance metrics**: CPU usage, network throughput before/after, specific observations |
| 169 | + |
| 170 | +Open an issue at: <https://github.com/microsoft/retina/issues> |
| 171 | + |
| 172 | +## Further Resources |
| 173 | + |
| 174 | +- [Packetparser Performance Considerations](../03-Metrics/plugins/Linux/packetparser.md#performance-considerations) |
| 175 | +- [Data Aggregation Levels](../05-Concepts/data-aggregation.md) |
| 176 | +- [Configuration Options](../02-Installation/03-Config.md) |
0 commit comments