Skip to content

SNMP Performance Tuning

Two parameters control how fast SNMP discovery runs and how much memory it uses:

Parameter Where Default What it does
snmp_concurrency Job form 100 Simultaneous SNMP requests — the primary speed lever
snmp_engine_batch_size PLUGINS_CONFIG 1000 IPs per processing batch — controls memory and recycle overhead

How to Size Them

Concurrency — tune this first

Discovery time scales directly with concurrency:

total_time ≈ N × ( timeout / concurrency  +  0.5 ms )

The 0.5 ms term is fixed per-IP processing overhead (encoding, socket setup). It sets a practical floor: for 131 000 IPs the minimum scan time is around 65 s regardless of how high concurrency is set.

Calibrated example: 131 000 IPs at concurrency = 4 000, timeout = 5 s → ~4 minutes.

Batch size — tune this second

batch_size controls how many IPs the SNMP engine holds in memory at once. After each batch the engine is recycled and memory is freed. A larger value means fewer recycles and lower overhead, but higher peak memory.

Rule of thumb: set batch_size so the scan completes in 10–20 batches.

batch_size  ≥  ceil( N / 15 )

batch_size does not need to equal concurrency. A batch_size 5–8× larger than concurrency is typical and works well.

Peak memory per batch:

memory ≈  batch_size × 3 KB  +  concurrency × 50 KB

Reference Table

Estimates use snmp_timeout = 5 s. Memory is peak usage during the SNMP phase.

Scan size (N) concurrency batch_size Est. time Est. memory
1 000 1 000 1 000 ~6 s ~53 MB
10 000 2 000 2 000 ~30 s ~105 MB
10 000 4 000 4 000 ~18 s ~210 MB
65 000 4 000 5 000 ~2 min ~215 MB
131 000 4 000 9 000 ~4 min ~225 MB
131 000 8 000 9 000 ~2.7 min ~425 MB
131 000 10 000 10 000 ~2.2 min ~520 MB
1 000 000 4 000 67 000 ~29 min ~390 MB
1 000 000 10 000 67 000 ~17 min ~685 MB
10 000 000 10 000 667 000 ~2.8 h ~2.4 GB

Beyond concurrency ≈ 10 000, gains are marginal — per-IP processing overhead dominates. For scans above 1M IPs the memory estimate assumes the batch_size target of 15 batches; reduce batch_size if the worker has less than the listed memory available (more batches, same time).


Quick Sizing Helper

def snmp_settings(scan_size: int, available_memory_mb: int) -> tuple[int, int]:
    """Return (batch_size, concurrency) given scan size and available worker memory."""
    K_B, K_C = 3 * 1024, 50 * 1024   # bytes per pending / active request
    C_MAX = 10_000
    M = available_memory_mb * 1024 * 1024
    C = min(M // (K_C + K_B), scan_size, C_MAX)
    B = min((M - C * K_C) // K_B, scan_size)
    return int(B), int(C)

# Examples (available_memory = worker RAM minus ~300 MB base overhead)
snmp_settings(131_000, available_memory_mb=512)   # → (9896, 9892)
snmp_settings(131_000, available_memory_mb=1024)  # → (131000, 10000)

Configuration

snmp_engine_batch_size goes in PLUGINS_CONFIG:

PLUGINS_CONFIG = {
    "nautobot_device_discovery": {
        "snmp_engine_batch_size": 32000,
    }
}

snmp_concurrency is set on the job form at run time and does not require a restart.