Networking basics for backend developers: DNS, TCP, TLS, HTTP, and proxies
Why backend developers need networking#
Many production issues look like code bugs but start in the network: stale DNS, wrong timeouts, proxy body limits, expired TLS certificates, blocked database ports, or failed load balancer health checks.
The request path#
A browser request commonly goes through DNS lookup, TCP connection, TLS negotiation, HTTP request handling, CDN or reverse proxy routing, load balancing, application processing, and database or service calls.
- DNS: maps a domain name to an IP address.
- TCP: provides reliable ordered delivery.
- TLS: encrypts traffic and verifies the server identity.
- HTTP: carries methods, headers, body, and status codes.
- Proxy/load balancer: routes traffic, terminates TLS, and applies policies.
DNS and TTL#
Common DNS records include A, AAAA, CNAME, MX, and TXT. TTL controls how long resolvers can cache a record. Lower TTL before infrastructure cutovers; raise it after the change stabilizes.
dig example.com
dig api.example.com CNAME
nslookup example.com
TCP, timeout, and retry#
Every dependency call should have a timeout. No timeout can hang resources indefinitely; overly short timeouts create false failures. Use bounded retries and log the dependency that is slow or failing.
TLS and HTTP semantics#
TLS is often terminated at a CDN, load balancer, or reverse proxy. Common issues include expired certificates, missing intermediate certificates, incorrect domains, and wrong forwarded scheme headers.
HTTP status codes are part of the operational contract. Use 400 for invalid requests, 401 for unauthenticated access, 403 for insufficient permission, 404 for missing resources, 409 for conflicts, 429 for rate limits, 500 for unexpected server errors, and 503 for temporary unavailability.
Reverse proxy basics#
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://app:3000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
}
}
Debugging toolkit#
curl -I https://example.com
curl -v https://api.example.com/health
dig example.com
nc -vz db.example.com 5432
openssl s_client -connect example.com:443 -servername example.com
Primary references#
Share this article
Help others discover this article
Comments
Loading comments...
Loading comments...