The Moving Parts
NetBox looks like one program, and in the browser it is one program. Under the page, four parts do four different jobs, and nearly every surprise in this guide — including most of the troubleshooting chapter — is one of these parts behaving exactly as designed while the reader expected another part's behaviour. This chapter names them.
The web application
The part you see is a Django
application — Python, the Django web
framework, and a set of NetBox's own
apps with names you will meet in the
API paths: dcim (the physical world:
sites, devices, interfaces, cables),
ipam (prefixes, addresses, VLANs),
tenancy, circuits, virtualization,
wireless, extras and users. It
serves the web pages and the REST API
from the same code and the same
records, which is why anything you can
do by clicking, a script can do by
calling — chapter 9 leans on this
throughout. One configuration file,
configuration.py, tells it where
everything else lives, and holds the
secret key that signs sessions.
PostgreSQL: where the truth is kept
Every record — every site, device,
address and cable — is a row in a
PostgreSQL database. Not a file,
not an embedded store: NetBox requires
PostgreSQL specifically, and leans on
it for the rules that make the records
trustworthy (uniqueness, references
between tables, transactions that
either happen whole or not at all).
The lab ran PostgreSQL 16.15 on a
throwaway port; NetBox's 337 database
migrations — the versioned steps
that build its schema — all applied
cleanly against it (transcript
t04-migrate.log). If PostgreSQL
stops, NetBox stops; there is no
degraded mode. Backing up NetBox means,
first of all, backing up this database.
Redis: the short-term memory
Redis holds everything NetBox needs
that is fast, shared and disposable:
cached answers, user sessions in some
setups, and the job queues described
next. NetBox's configuration names two
logical Redis databases — one for
tasks, one for caching — which the
lab pointed at one small Redis 7 server
on two database numbers, the usual
small-install arrangement. Redis holds
nothing irreplaceable: empty it and
NetBox re-fills it. The lab's Redis
answered on its lab port the whole run
(transcript t12-services-summary.txt).
The background worker: the rq queue
Some of NetBox's work is slow or due later: housekeeping, webhook delivery, reports, housekeeping chores like expiring old sessions and change logs. Those go onto a queue (the Python rq library, backed by the Redis tasks database) and a separate worker process picks them up. The web application will run happily with no worker — pages answer, records save — while jobs pile up unprocessed, which is why "the queue grows" is a troubleshooting entry and not an error message. The lab ran the worker once in burst mode (work until the queue is empty, then exit) and watched it complete a real System Housekeeping job and exit cleanly:
Successfully completed handle(job=<Job: System Housekeeping>)
Worker ...: done, quitting
(Transcript t10-rqworker-burst.txt.)
In production the same worker runs
continuously as a service; that form is
documented-only here.
Which part holds what
| Question | The part that answers it |
|---|---|
| Where is my device record, really? | PostgreSQL — a row like every other |
| Why does NetBox stop when the database stops? | The web app has no other store |
| Why is a page fast the second time? | Redis, caching the answer |
| Why did the webhook/report never happen? | The worker — check the queue |
| Why did my token stop working? | The users app and the pepper in configuration.py (chapter 9) |
| Why 337 steps at first run? | The migrations building the schema in PostgreSQL |
Keep this table in mind. When NetBox surprises you, the surprise has an address, and the address is one of these four.