> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/smc/latest/llms.txt) (all documentation: [llms.txt](https://docs.cennso.com/llms.txt)). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cennso.com/components/smc/latest/guides/load-control.md).

# Adaptive load control

Session Management Controller (SMC) ships with an optional adaptive load control subsystem. When enabled, it protects the gateway from overload by shedding excess traffic, prioritizing critical GTP message types, and dynamically adjusting the concurrent-request limit based on observed processing latency.

This page is the operator-facing entry point: what the feature does, how to choose a mode, how to enable it, and what the migration path looks like. For Prometheus metrics, see [Adaptive load control metrics](https://docs.cennso.com/components/smc/latest/observability/metrics.md#adaptive-load-control-metrics). For the bundled Grafana dashboards, see [Adaptive load control dashboard](https://docs.cennso.com/components/smc/latest/observability/dashboard-ergw-load-control.md) and [API latency dashboard](https://docs.cennso.com/components/smc/latest/observability/dashboard-api-latency.md). For symptom-based diagnosis, see [Troubleshooting](https://docs.cennso.com/components/smc/latest/troubleshooting/load-control.md). For the algorithms, parameter tables, and tuning guidance, see [Adaptive load control technical reference](https://docs.cennso.com/components/smc/latest/reference/load-control.md).

> [!NOTE]
> Adaptive load control is **off by default**. SMC continues to use the rate-limit static admission path unless the operator opts in through the `loadControl` Helm value. The defaults preserve pre-3.15 behavior exactly; you do not need to act on upgrade.

## What it does

A production gateway has a finite amount of work it can perform per unit time. When demand exceeds capacity, the system must choose between three bad options:

- Accept everything and degrade silently. Queue length grows, latency rises, and retries from clients amplify the overload. Eventually the system falls over.
- Apply static rate limits. The operator picks a threshold at which requests start to be rejected. If the threshold is too low, capacity is wasted at low load. If it is too high, it protects nothing at peak load.
- Apply adaptive admission. The gateway continuously measures its own capacity and adjusts the admission threshold to match. Under overload, a predictable fraction of low-priority traffic is rejected; the remainder experiences stable latency.

Adaptive load control implements the third option. It combines a priority model (four tiers × 128 cohorts = 512 priority levels), a velocity-form proportional-integral-derivative (PID) controller that computes a rejection ratio, an empirical percentile tracker that maps the ratio to a threshold consistent with the actual traffic mix, and a Vegas auto-tuner that adjusts the concurrency limit based on processing latency. The Technical Reference covers each component in detail.

## Admission modes

SMC supports three admission modes, selected through `loadControl.mode`:

| Mode | Admission path | Instrumentation |
| --- | --- | --- |
| `rate-limit` (default) | Static per-tier rate and counter limits. | None. |
| `rate-limit-observe` | Static admission as above. | Shadow adaptive controller reports what it would have decided. |
| `adaptive` | PID rejector + priority queue + Vegas auto-tuner. | Active. |

> [!IMPORTANT]
> Mode and every tunable under `loadControl` can be changed **at runtime without restarting SMC** through the Operations, Administration, and Maintenance (OAM) REST API. Helm values are the persisted baseline; the API is the operational control surface. See [Runtime reconfiguration](#runtime-reconfiguration).

### Which mode should I pick

**Pick `rate-limit`** when you need a running system fast and don't yet have measured capacity numbers, or when you need a hard, predictable cap (for example, for contractual SLOs or for a downstream component with a known limit). It won't adapt to changing capacity, and you should set the limit conservatively — noticeably below what the setup can actually sustain — because you're giving up the safety margin that adaptive tuning would provide.

**Pick `adaptive`** when you want the system to discover and hold near its real capacity on its own, especially if load patterns or backend latency vary over time. It needs a short warm-up before it converges.

**`rate-limit-observe`** is the evaluation bridge: static admission stays in control while the adaptive stack runs in parallel and reports what it would have done. Use it to validate adaptive behavior against real traffic before flipping.

### Scope

Load control applies to GTP-C request handling. SMC handles GTP Echo Requests at the socket level before the request logic runs, so they are **not subject to load control** — they always pass. The `data` tier (in rate-limit mode) or the priority queue (in adaptive mode) covers user-plane forwarding between SMC and the UPG.

## Quick start

Enable the adaptive controller with a minimal configuration:

```yaml
loadControl:
  mode: adaptive
```

SMC emits a `load_control` section to the generated configuration with `mode: adaptive` and all other parameters at their defaults. This is enough to activate the full adaptive stack: rejector, priority queue, and Vegas auto-tuner.

For a safer rollout that observes the adaptive path without changing admission decisions:

```yaml
loadControl:
  mode: rate-limit-observe
```

A full configuration example tuned for a deployment with known baseline latencies:

```yaml
loadControl:
  mode: adaptive
  queue:
    mode: strict
    max_inflight: 200
    max_wait: 5000
    max_queue: 500
  rejector:
    tick_interval: 500
    kp: 0.1
    ki: 0.2
    kd: 0.05
    priority_window_size: 2000
  vegas:
    min_interval: 2000
    max_interval: 30000
    min_samples: 250
    inflight_limit: 200
    min_inflight: 8
    ema_alpha: 0.25
    long_ema_alpha: 0.01
    smoothing: 0.2
    min_gradient: 0.5
```

See the [Technical Reference](https://docs.cennso.com/components/smc/latest/reference/load-control.md) for what each parameter does and how to tune it.

## Migration path

The safe path from `rate-limit` to `adaptive` is staged and fully reversible at every step:

1. **Deploy with `mode: rate-limit`** (or no `loadControl` section at all, which is equivalent). Behavior is identical to pre-3.15 SMC.
2. **Switch to `mode: rate-limit-observe`** during a representative traffic window. Admission decisions do not change; the `jobs` queues continue to gate traffic. The adaptive stack runs in parallel and reports what it would have decided.
3. **Flip to `mode: adaptive`** once the shadow behavior looks reasonable. Admission is now controlled by the adaptive stack.
4. **If anything goes wrong**, flip back to `mode: rate-limit` through the OAM API. No restart, no configuration file change.
5. **Persist `mode: adaptive` in the Helm values** once confident, so the choice survives a restart.

> [!IMPORTANT]
> Convergence takes time. When overload arrives, the PID needs a few seconds to ramp the rejection ratio up. During this window, the priority queue absorbs the excess, bounded by `max_queue`. After overload ends, the Vegas auto-tuner takes about one minute to recover the concurrency limit to its pre-overload value. Plan the rollout on a day when short recovery lags are acceptable.

## Rate-limit mode queues

When `loadControl.mode` is `rate-limit` or `rate-limit-observe`, admission is controlled by four independent `jobs` queues — one per load class. Each queue has its own rate or counter limit and operates independently of the others.

Only one of `rate` or `counter` must be set per tier. The unset field is ignored by the `jobs` application.

| Parameter | Description |
| --- | --- |
| `loadControl.rateLimit.create.rate` | Maximum Create Session / PDP requests per second. |
| `loadControl.rateLimit.create.counter` | Maximum concurrent Create Session / PDP requests. |
| `loadControl.rateLimit.create.max_time` | Maximum queue wait time in milliseconds. Requests waiting longer are rejected. |
| `loadControl.rateLimit.create.cpu_feedback` | CPU feedback modifier as a percent increment. When CPU utilisation rises, the effective limit is reduced by this percentage. |

`loadControl.rateLimit.delete`, `loadControl.rateLimit.data`, and `loadControl.rateLimit.other` accept the same four sub-keys.

The rate-limit tiers operate independently: a burst of `create` traffic does not affect `delete` traffic because they queue separately and are regulated separately. This is the main behavioral difference from `adaptive` mode, which uses a single priority queue.

### The `data` tier and IPv6 connectivity

The `data` tier covers PDU forwarding between the User Plane Gateway (UPG) and SMC. In the absence of IPv6, this tier sees almost no traffic — it is only used for Neighbor Discovery, which is low volume but essential for IPv6 connectivity to work at all.

> [!CAUTION]
> Do not set `loadControl.rateLimit.data.rate` (or `counter`) lower than the `create` tier's equivalent. Doing so starves IPv6 Neighbor Discovery under load and breaks IPv6 connectivity for sessions that are otherwise admitted successfully. If you are not operating IPv6, the `data` tier can be left at its default or set very low without operational impact.

### The `upfRestart` tier lives elsewhere

Rate-limit admission control includes a fifth tier, `upfRestart`, that limits the rate of session teardowns when a User Plane Gateway restarts. This tier has no counterpart in `loadControl.rateLimit` and no `adaptive` mode — it stays on the older Erlang `sys.config` configuration path and is controlled through the existing `requestLimits.upfRestart.rate` Helm value. See [Rate limitation](https://docs.cennso.com/components/smc/latest/guides/rate-limitation.md).

### Auto-translation from `requestLimits`

The chart translates the existing `requestLimits` Helm values into `loadControl.rateLimit` transparently when `loadControl.rateLimit` is not set explicitly. An upgrade from a pre-3.15 release picks up the new YAML-driven load control config path without any operator action, and the runtime `jobs` queues configured for `create`, `delete`, and `other` retain the same rates and queue wait times.

The translation uses the following field mapping for each tier:

| `requestLimits` field | `loadControl.rateLimit` field |
| --- | --- |
| `rate` | `rate` |
| `queueTime` | `max_time` |
| `queueLen` | *not translated* — the new schema has no equivalent |

`queueLen` (the old `jobs` `max_size`) does not appear in the new schema. Operators who relied on `requestLimits.*.queueLen` for tight queue-depth control should set `loadControl.queue.max_queue` when they opt into `adaptive` mode, or set `loadControl.rateLimit.*.counter` for a concurrent-request cap in `rate-limit` mode.

When `loadControl.rateLimit` is set explicitly, the translation is skipped and `requestLimits` is ignored for the `create`, `delete`, and `other` tiers. `requestLimits.upfRestart` continues to be honoured regardless.

## Runtime reconfiguration

Every tunable exposed under `loadControl` in the Helm values can be changed at runtime through the OAM REST API, without restarting SMC. Runtime changes are not persisted: a restart returns to the Helm-values state.

The load control endpoints live under the existing OAM HTTP API path (by default, port `9090` on the pod's `http_api` interface). See [Operations](https://docs.cennso.com/components/smc/latest/concepts/gtp-procedures.md) for general OAM API access and authentication.

| Method | Path | Body and response |
| --- | --- | --- |
| `GET` | `/oam/v1alpha/load_control/mode` | Response: `{"mode": "adaptive"}` (or `rate-limit`, or `rate-limit-observe`). |
| `PUT` | `/oam/v1alpha/load_control/mode` | Request: `{"mode": "adaptive"}`. Response: `204 No Content`. |
| `GET` | `/oam/v1alpha/load_control/config` | Response: the full live configuration as a JSON object. |
| `PATCH` | `/oam/v1alpha/load_control/config` | Request: a partial configuration (RFC 7396 merge patch). Response: `204 No Content`. |

### Examples

Flip from `rate-limit-observe` to `adaptive`:

```bash
curl -X PUT -H 'content-type: application/json' \
     -d '{"mode":"adaptive"}' \
     http://{SMC_POD}:9090/oam/v1alpha/load_control/mode
```

Roll back to `rate-limit`:

```bash
curl -X PUT -H 'content-type: application/json' \
     -d '{"mode":"rate-limit"}' \
     http://{SMC_POD}:9090/oam/v1alpha/load_control/mode
```

Retune the integral gain without touching anything else:

```bash
curl -X PATCH -H 'content-type: application/merge-patch+json' \
     -d '{"rejector":{"ki":0.25}}' \
     http://{SMC_POD}:9090/oam/v1alpha/load_control/config
```

Every runtime change is validated against the same schema used at startup. An invalid value returns `400 Bad Request` with an `application/problem+json` body describing the field and the failure reason; the current configuration is unchanged.

Mode switches are atomic and take effect on the next admission decision. Requests already in flight complete through their original backend: the admission handle is tagged at admission time so the completion always routes correctly even if the mode changes in between.

### Helm values versus the API

Use the **OAM API** for:

- Emergency rollback during an incident. Flipping `mode` is instant; a Helm upgrade is not.
- Tuning experiments during a maintenance window.
- A/B comparisons across pods.

Use the **Helm values** for:

- The persisted baseline that survives restart.
- Configuration that should be reproducible across environments.
- Changes that go through your normal change management process.

## See also

- [Adaptive load control metrics](https://docs.cennso.com/components/smc/latest/observability/metrics.md#adaptive-load-control-metrics) — Prometheus metric reference and key monitoring signals.
- [Adaptive load control dashboard](https://docs.cennso.com/components/smc/latest/observability/dashboard-ergw-load-control.md) and [API latency dashboard](https://docs.cennso.com/components/smc/latest/observability/dashboard-api-latency.md) — bundled Grafana dashboards.
- [Troubleshooting](https://docs.cennso.com/components/smc/latest/troubleshooting/load-control.md) — symptom-based diagnosis for the rejector, Vegas, and shadow-mode comparisons.
- [Adaptive load control technical reference](https://docs.cennso.com/components/smc/latest/reference/load-control.md) — architecture, algorithms, parameters, and tuning guidance.
- [Chart configuration reference](https://docs.cennso.com/components/smc/latest/reference/chart-configuration.generated.md) — full Helm value list with types and defaults.
