Skip to content

Performance issues in prefix views with large-scale data #21870

@Miyoshi-Ryota

Description

@Miyoshi-Ryota

NetBox Version

v4.5.7

Python Version

3.14

Area(s) of Concern

  • User Interface
  • REST API
  • GraphQL API
  • Python ORM
  • Other

Details

The current implementation of prefix views exhibits high latency (over 5 minutes) and significant memory usage growth (approximately +500 MB) in environments with large-scale IPAM data.

Target Path

  • /ipam/prefixes/
  • /ipam/prefixes/<id of 10.0.0.0/8 prefix>/

Expected Behavior

  • Pages should load within a reasonable time (e.g., a few seconds) even with large datasets.

Actual Behavior

  • Page load time exceeds 5 minutes.
  • Memory usage increases by approximately 500 MB during request.

Observations notes

  • In List View (/ipam/prefixes/), the loading time drops from over 5 minutes to under 1 second when the "Utilization" column is removed. This suggests that the utilization calculation is the primary bottleneck.

Environment

Registered Data

  • Prefixes: 10.0.0.0/8 subdivided into /23 prefixes. (32,769 total)
  • IP Addresses: 1,000,000 entries within 10.0.0.0/8.

Versions

$ python --version
Python 3.14.3

// I reproduced this issue on the latest main branch (commit: [dbb871b75a3517860d5274db1427a31ec3b7d10a]).
$ git rev-parse HEAD
dbb871b75a3517860d5274db1427a31ec3b7d10a

$ grep '^version:' release.yaml
version: "4.5.7"

$ ./manage.py version
5.2.12

$ psql -V
psql (PostgreSQL) 16.13

$ redis-server --version
Redis server v=6.2.20 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=cc01d7ff18b462c0

Server Spec

  • 4vCPU, 16GB RAM, SSD.

Reproduction Steps

  1. Deploy NetBox on a VM by following the official documentation:
    https://netbox.readthedocs.io/en/stable/development/getting-started/

    • Note that DEBUG and DEVELOPER in "6. Configure NetBox" are set to "False" to measure performance in a production-like environment.
  2. Open the NetBox shell:

    ./manage.py shell
  3. Run the following script to register the seed data:

from netaddr import IPNetwork
from ipam.models import Prefix
from ipam.choices import PrefixStatusChoices
from itertools import islice
from ipam.models import IPAddress

# Create root prefix
parent, _ = Prefix.objects.get_or_create(
    prefix="10.0.0.0/8",
    defaults={"status": PrefixStatusChoices.STATUS_ACTIVE, "description": "seed root"},
)

# Create /23 child prefixes
children = [
    Prefix(
        prefix=str(p),
        status=PrefixStatusChoices.STATUS_ACTIVE,
        description="seed /23",
    )
    for p in IPNetwork("10.0.0.0/8").subnet(23)
]

Prefix.objects.bulk_create(children, batch_size=1000)


# Create 1,000,000 IP addresses
remaining_ip_count = 1_000_000
ip_addresses_to_create = []

for prefix in children[: (remaining_ip_count + 254) // 255]:
    ip_count_for_prefix = min(255, remaining_ip_count)
    for ip in islice(IPNetwork(str(prefix.prefix)).iter_hosts(), ip_count_for_prefix):
        ip_addresses_to_create.append(
            IPAddress(
                address=f"{ip}/23",
                status="active",
                description="seed 1m ip",
            )
        )
    remaining_ip_count -= ip_count_for_prefix

IPAddress.objects.bulk_create(ip_addresses_to_create, batch_size=5000)
  1. Start the server.
./manage.py runserver --insecure 0.0.0.0:8000
  1. Access the following URL:
  • /ipam/prefixes/
  • /ipam/prefixes/<id of 10.0.0.0/8>/

Result

  • /ipam/prefixes/
    • It takes 5.6 minutes to load the page.
Image
  • /ipam/prefixes/<id of 10.0.0.0/8>/
    • It takes 5.4 minutes to load the page.
Image

Metadata

Metadata

Assignees

Labels

netboxstatus: acceptedThis issue has been accepted for implementationtype: performanceA concern regarding application performance
No fields configured for Performance.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions