Networking Infrastructure Architecture: How nginx, Caddy, curl & DNS Servers Work

Every request you make passes through code like this: a DNS resolver, an HTTP client, a web server, maybe a message broker. These projects are decades of hard-won decisions about concurrency, parsing and failure, and they are some of the best-written C and Go in open source.

Each page below is an analysis of the real source: module maps, request flows and diagrams generated from the code. If you have ever wondered how nginx serves thousands of connections per worker or how a resolver decides what to cache, this is the code, mapped.

Networking & Infrastructure: full architecture breakdowns

Patterns in network infrastructure

Event loops, not threads per connection

nginx, Unbound and Mosquitto multiplex many connections over a small number of processes or threads using non-blocking I/O. The architecture is organized around readiness events, with each connection advancing through a state machine instead of blocking.

Protocols as state machines

HTTP, DNS and MQTT are all implemented as explicit states and transitions. curl models every transfer this way across dozens of protocols, which is what lets one library drive them through a single API.

Modules and configuration as the extension point

nginx compiles in modules that hook into request phases; Caddy composes modules from its JSON config and gets automatic HTTPS as one of them. The core stays small and behavior is assembled around it.

More infrastructure architectures

Frequently asked questions

How does nginx handle so many connections?

nginx runs a master process and a small number of worker processes, each running an event loop over non-blocking sockets. A worker never waits on one slow client; it services whichever connections are ready. The nginx analysis below maps the modules behind that loop.

What is the difference between BIND9 and Unbound?

BIND9 is a full DNS server that can be authoritative for zones as well as resolve recursively. Unbound is focused on recursive, caching and validating resolution. Their architectures reflect that split, and both are analyzed here.

What does Caddy do differently from nginx?

Caddy is written in Go, configured through a JSON API that its Caddyfile is converted into, and obtains and renews TLS certificates automatically. Its functionality is built from pluggable modules loaded from that configuration.

Can I get this analysis for my own codebase?

Yes. These pages are generated by Revibe's codebase analysis. Import a repository from GitHub or upload a zip and you get the same architecture diagrams, module maps and execution flows for your own project.

Explore every analysis in the Revibe Codes gallery, or analyze your own codebase to get the same architecture diagrams, module maps, and execution flows.