> ## Documentation Index
> Fetch the complete documentation index at: /llms.txt
> Use this file to discover all available pages before exploring further.

# Scaling & Resource Management

> Scale a Livepeer Gateway - session limit benchmarking, GPU resource management, when to split video and AI workloads onto separate nodes, and horizontal scaling patterns.

> [!NOTE]
>
> Session limits and GPU management apply primarily to Orchestrators running compute locally.
> \
> &#x20;A pure routing Gateway (off-chain AI, no local GPU) is limited mainly by network throughput and horizontal instance count.
> \
> &#x20;Jump to [Horizontal Scaling](#horizontal-scaling) if that describes the setup.

A Gateway routes jobs to Orchestrators instead of processing them locally, but it still has resource limits: session capacity, network throughput, and (for Dual Gateways) the GPU resources shared between video and AI workloads.
\
&#x20;This guide covers how to measure those limits, decide when they have been reached, and scale in the right direction.

## Scaling Signals

Before adjusting anything, confirm there is actually a capacity problem. These are the reliable indicators.

> [accordion] Session limit reached
>
> The Prometheus metric `livepeer_current_sessions_total` approaching `livepeer_max_sessions_total` means the Gateway is at capacity and will start rejecting new sessions. This is the clearest signal.
>
> ```bash icon="terminal" theme={null}
> curl http://localhost:8935/metrics | grep livepeer_current_sessions
> ```

> [accordion] GPU memory pressure
>
> For Dual Gateways, the `/hardware/stats` endpoint reports GPU utilisation and memory:
>
> ```bash icon="terminal" theme={null}
> curl http://localhost:8935/hardware/stats
> ```
>
> If VRAM usage is consistently above 85%, the Gateway is at risk of OOM failures on new model loads (AI) or performance degradation on concurrent transcoding segments (video).

> [accordion] Increasing latency under load
>
> Rising transcoding latency or AI inference latency under load, combined with high Orchestrator swap rates, suggests the Orchestrators being routed to are also under pressure. This is an Orchestrator-side scaling problem. See [Orchestrator Selection](/v2/gateways/guides/advanced-operations/orchestrator-selection.md) for expanding the Orchestrator pool.

> [accordion] Client rejections
>
> Errors with `OrchestratorCapped` in the Gateway log indicate that a downstream Orchestrator has hit its own session limit and rejected the job. Either expand the Orchestrator pool or negotiate higher capacity with preferred Orchestrators.

### Step 1

### Session Limits

Session limits define how many concurrent jobs the Gateway (or its local Orchestrator, for dual setups) accepts. The default is 10.

```bash icon="terminal" -maxSessions theme={null}
-maxSessions 20
```

Setting this too high causes performance degradation or OOM failures. Setting it too low wastes available capacity. The right value comes from benchmarking.

### Step 1

### Benchmarking

`livepeer_bench` tests transcoding throughput for a range of concurrent session counts. Run this on the machine that will perform local transcoding before setting `-maxSessions` in production.

```bash icon="terminal" livepeer_bench theme={null}
# Download the standard transcoding options file
wget https://raw.githubusercontent.com/livepeer/go-livepeer/master/cmd/livepeer_bench/transcodingOptions.json

# Run the benchmark across 1 to 20 concurrent sessions
for i in {1..20}; do
    ./livepeer_bench \
        -in bbb/source.m3u8 \
        -transcodingOptions transcodingOptions.json \
        -nvidia 0 \
        -concurrentSessions $i |& grep "Duration Ratio" >> bench.log
done

cat bench.log
```

Read the output: find the last line where the real-time duration ratio is at or below 0.8. That concurrent session count is the hardware limit. Leave a 20% buffer for upload and download overhead.

```text icon="terminal" Output Example theme={null}
Concurrent sessions 12: Duration Ratio 0.79  <- last line at or below 0.8
Concurrent sessions 13: Duration Ratio 0.88
Concurrent sessions 14: Duration Ratio 0.97
```

In this example, set `-maxSessions 12`.

For machines with multiple identical GPUs, benchmark one GPU and multiply. For machines with different GPU models, benchmark each separately and use the lower value as the bottleneck.

> [!TIP]
>
> Bandwidth can be a tighter limit than compute. Each 1080p stream requires approximately 4-8 Mbps inbound and 12-24 Mbps outbound (for a 4-rung ABR ladder). If bandwidth is the bottleneck, it sets a lower ceiling than the hardware benchmark.

### Step 1

### GPU Management

For Dual Gateways, video transcoding and AI inference compete for the same GPU.

```bash icon="terminal" GPU Stats theme={null}
# GPU model, VRAM, and system specs
curl http://localhost:8935/hardware/info

# Live GPU utilisation, memory, temperature
curl http://localhost:8935/hardware/stats
```

VRAM allocation between video transcoding and AI inference is managed by the Orchestrator, not the Gateway. Video transcoding (NVENC/NVDEC) uses dedicated hardware encoder/decoder blocks on NVIDIA GPUs, which do not compete directly with CUDA cores used for AI inference. However, VRAM is shared, and large AI models can exhaust available memory.

As a rule of thumb:

* Reserve at least 8 GB VRAM per concurrent AI inference model
* Keep video transcoding sessions below the benchmarked hardware limit even when running AI jobs simultaneously
* Monitor temperature: sustained GPU temperature above 85 degrees C indicates thermal throttling

### Step 1

### Split or Share?

If a Dual Gateway runs video + AI on one node, the central decision is when to split those workloads onto separate nodes.

> [tab] Decision Guide
>
> <table>
>   <tr>
>     Factor
>
>     Stay on single node
>
>     Split onto separate nodes
>   </tr>
>
>   <tr>
>     Load
>
>     Low to medium, predictable
>
>     High, variable, or growing
>   </tr>
>
>   <tr>
>     SLA requirements
>
>     Best-effort
>
>     Committed latency or uptime
>   </tr>
>
>   <tr>
>     GPU VRAM
>
>     Model fits with transcoding headroom
>
>     Models exhaust VRAM under load
>   </tr>
>
>   <tr>
>     Operational complexity
>
>     Prefer simplicity
>
>     Can manage two nodes
>   </tr>
>
>   <tr>
>     Cost
>
>     Minimise hardware spend
>
>     Willing to pay for isolation
>   </tr>
> </table>
>
> The practical trigger for splitting is usually VRAM contention (AI models OOM when video load spikes) or SLA pressure (customers require guaranteed latency for one workload that the other interferes with).

> [tab] Split Architecture
>
> Once split, run two separate go-livepeer processes - one configured as a Video Gateway, one as an AI Gateway - each with its own Orchestrator list:
>
> ```bash icon="terminal" Split Settings theme={null}
> # Video Gateway (on-chain, port 8935, RTMP 1935)
> livepeer -gateway \
>     -network arbitrum-one-mainnet \
>     -rtmpAddr 0.0.0.0:1935 \
>     -httpAddr 0.0.0.0:8935 \
>     -orchAddr <video-orchestrators>
>
> # AI Gateway (off-chain, port 8935 on separate host)
> livepeer -gateway \
>     -httpAddr 0.0.0.0:8935 \
>     -orchAddr <ai-orchestrators> \
>     -httpIngest
> ```
>
> The middleware or load balancer routes incoming requests to the correct Gateway based on job type.

### Step 1

### Horizontal Scaling

```mermaid theme={null}
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#1a1a1a', 'primaryTextColor': '#fff', 'primaryBorderColor': '#2d9a67', 'lineColor': '#2d9a67', 'secondaryColor': '#0d0d0d', 'tertiaryColor': '#1a1a1a', 'background': '#0d0d0d', 'fontFamily': 'system-ui' }}}%%
flowchart LR
    subgraph Scale["Scaling path"]
    direction LR
    S1["1. Vertical\nBigger GPU"] --> S2["2. Split\nSeparate video + AI nodes"] --> S3["3. Horizontal\nMultiple instances per type"]
    end
```

**Off-chain AI Gateways** scale horizontally without special configuration. They are stateless: no ETH key, no session state. Add instances behind a standard HTTP load balancer and use the `/health` endpoint for health checks.

```yaml icon="code" /health yaml theme={null}
# Example: three AI Gateway instances behind nginx
upstream ai_gateways {
    server 10.0.0.1:8935;
    server 10.0.0.2:8935;
    server 10.0.0.3:8935;
}

server {
    location / {
        proxy_pass http://ai_gateways;
    }
}
```

**Video Gateways** require sticky sessions for streaming continuity. A live RTMP stream cannot be moved between Gateway instances mid-session. Configure the load balancer to use IP-hash or cookie-based session affinity for RTMP connections. HTTP API requests (non-streaming) can be round-robined normally.

**Dual Gateways:** Split into separate video and AI instances before scaling horizontally. Trying to horizontally scale a Dual node adds complexity without solving the resource contention problem.

## Capacity Planning

> [accordion] Video transcoding
>
> Per GPU, the practical limit for 1080p to 720p/480p/360p transcoding is approximately 8-12 concurrent sessions on a modern NVIDIA T4, and 15-25 on an RTX 3080 or equivalent. Run `livepeer_bench` on the specific hardware to get a precise number.
>
> Multiply by the number of GPUs in the Orchestrator pool to get total network capacity. The Gateway can route to all of them.
>
> For deposit sizing: video transcoding payments are per-pixel. Estimate the expected pixel throughput (resolution x frame rate x concurrent sessions x hours per day) and size the Arbitrum deposit to cover at least 24 hours of expected traffic.

> [accordion] AI inference
>
> AI inference capacity depends entirely on the model and the Orchestrators in the pool. FLUX.1-dev requires approximately 12-16 GB VRAM per concurrent inference; smaller SD 1.5 models can fit in 6 GB.
>
> For off-chain AI Gateways, the bottleneck is the number of AI-capable Orchestrators available. Expand the `-orchAddr` list or use a discovery URL that returns a larger pool.
>
> Set a monitoring alert at 70% of observed capacity. This gives time to provision additional Orchestrators before hitting the ceiling.

> [accordion] Alert thresholds
>
> <table>
>   <tr>
>     Metric
>
>     Warning
>
>     Critical
>   </tr>
>
>   <tr>
>     Session utilisation
>
>     70% of `-maxSessions`
>
>     90% of `-maxSessions`
>   </tr>
>
>   <tr>
>     GPU memory
>
>     75% VRAM used
>
>     90% VRAM used
>   </tr>
>
>   <tr>
>     GPU temperature
>
>     80 degrees C
>
>     87 degrees C
>   </tr>
>
>   <tr>
>     Orchestrator swap rate
>
>     2x baseline
>
>     5x baseline
>   </tr>
>
>   <tr>
>     ETH deposit balance
>
>     20% remaining
>
>     5% remaining
>   </tr>
> </table>

## Related Pages

> [card] [Orchestrator Selection](/v2/gateways/guides/advanced-operations/orchestrator-selection.md)
>
> Expand the Orchestrator pool to increase available capacity.

> [card] [Gateway Middleware](/v2/gateways/guides/advanced-operations/gateway-middleware.md)
>
> Route requests across scaled instances with middleware.

> [card] [GPU Support](/v2/gateways/resources/reference/go-livepeer/gpu-support.md)
>
> Tested GPU models and session limit data.

> [card] [Monitoring Setup](/v2/gateways/guides/monitoring-and-tooling/monitoring-setup.md)
>
> Prometheus metrics and dashboards for scaling signals.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.