Skip to content

Independent marketplace for verified cloud accounts

Load Balancers, Private Networks and Firewalls: The Networking Baseline

The three networking pieces every cloud deployment needs, how a request moves through them, and the day one choices that are painful to change later.

Compute gets the attention and networking causes the outages. The three pieces almost every cloud deployment needs are a private network to put things in, a load balancer to spread traffic across them, and firewall rules to decide who may talk to whom. Get those right at the start and most of the hard problems never appear. Get them wrong and you will be unpicking address collisions and over permissive rules for years.

This is the baseline, written as the thing you build on day one rather than the thing you retrofit after an audit.

The three pieces and how traffic moves through them

Follow a single request. It arrives from the internet at a public address, which belongs to a load balancer. The load balancer terminates the connection, picks a backend, and opens a connection to that backend over the private network. A firewall rule on the backend allows traffic from the load balancer and nothing else. The backend queries a database on another private address, permitted by a second rule that allows only the application tier. The response travels back the same way.

Notice what is absent. The backend has no public address. The database has no public address. The only reachable thing from outside is the load balancer, and it only accepts the one protocol you configured. That shape is the baseline, and almost every networking incident is a deviation from it.

Private networks: address space you choose once

A private network, called a VPC or a virtual network or a private cloud depending on the provider, is an isolated address range that your resources live inside. Instances in it can reach each other by private address without crossing the public internet, which is both faster and free of a whole category of exposure.

The decision that matters here takes two minutes and lasts forever: the address range. Pick a block from private address space, make it large enough to subdivide, and make it different from every other network you are likely to connect to later. Overlapping ranges are the reason company networks cannot be peered, the reason acquisitions take six months to integrate, and the reason somebody eventually proposes network address translation between two of your own environments.

Subdivide the block by purpose rather than by team: a public subnet for load balancers and anything that needs an internet facing address, a private subnet for application instances, and a separate subnet for data stores. Spread each of those across availability zones so that a zone loss does not take a whole tier with it. Our guide to how regions and availability zones work covers why that spread is worth the extra subnets.

Load balancers: layer four and layer seven

Load balancers come in two broad flavours and the difference is how much they understand about your traffic.

A layer four balancer works at the TCP level. It sees addresses and ports, forwards connections, and is fast and protocol agnostic. Use it for anything that is not HTTP, for very high connection rates, and when you want encryption to terminate on the backend rather than at the edge.

A layer seven balancer parses HTTP. It can route by hostname and path, rewrite headers, terminate TLS, retry idempotent requests, and insert the client address into a forwarded header. That last point matters more than it sounds: without it, every request in your application logs appears to come from the load balancer, and you lose the ability to investigate anything per client.

Managed load balancers from the provider save real work: they are redundant by default, they handle certificate renewal, and they scale without you noticing. They also bill hourly plus per unit of traffic, which is a line item worth watching. Running your own balancer on a small instance is cheaper and entirely reasonable at modest scale, at the cost of becoming the person who maintains it. Providers in the developer cloud tier make the self managed route pleasant, which is part of why accounts like Buy Digital Ocean Account and Buy Vultr Account are popular for this pattern. The DigitalOcean and Vultr comparison goes into how their managed networking offerings differ.

Firewalls at the instance, at the subnet, and in front

Cloud firewalling happens at several layers and they behave differently, which is why rules that look correct sometimes do nothing.

Instance level groups are stateful: allow an inbound connection and the response is automatically allowed back out. They are usually default deny inbound, and they can typically reference other groups as a source, which is the single most useful feature in cloud networking. A rule saying “allow port five four three two from the application group” keeps working as instances come and go, while a rule listing addresses does not.

Subnet level access lists are stateless. Both directions must be allowed explicitly, including ephemeral return ports, and rules are evaluated in order. They are a coarse second line of defence, useful for blocking an address range outright, and a common source of confusing partial connectivity when somebody forgets the return rule.

In front of everything you may also have a web application firewall inspecting HTTP payloads. That is a different job: it filters content, not reachability. Use the first two to control who can connect and the third to control what they may send. For the rule design itself, our guide to firewall rules that hold up goes further than there is room for here.

NAT, public addresses and the cost of being reachable

Instances in a private subnet still need outbound access for package updates and API calls. That is what a NAT gateway provides: a shared outbound path with no inbound reachability. It is also, at several providers, one of the more expensive small components in the stack, billed both per hour and per gigabyte processed. A busy private subnet pushing backups or container images through NAT can run up a bill out of proportion to its size.

Two mitigations are worth knowing. Private endpoints let instances reach provider services over the internal network instead of through NAT, which removes both the cost and the exposure. And a self managed NAT instance on a small virtual machine is cheaper, at the price of being a component you now own. Public addresses themselves are also increasingly chargeable, including for addresses you have reserved and are not using, which is a classic source of a slow bill creep.

DNS and health checking as part of the path

DNS is networking, even though it usually lives in a different part of the console. Internal DNS lets services find each other by name instead of by address, which is what makes instance replacement painless. External DNS is the first thing a client touches, and its time to live value sets the floor on how quickly you can move traffic during an incident. A record with a long TTL is a record you cannot fail over quickly, no matter how good your redundancy is.

Health checked DNS and health checked load balancing do similar things at different speeds. The load balancer removes a bad backend in seconds. DNS based failover removes a bad endpoint only as fast as caches expire, which is unreliable because resolvers do not always honour your TTL. Treat DNS failover as a coarse regional tool and the load balancer as your real one.

A baseline you can build in an afternoon

One private network with a deliberately chosen address block. Public subnets in at least two zones holding only load balancers and NAT. Private subnets in the same zones holding application instances. A separate data subnet with no route to the internet at all. One security group per tier, each referencing the tier above it rather than listing addresses. A managed load balancer with TLS terminated at the edge and a health check that touches a real dependency. Internal DNS names for everything, short TTLs on external records.

Write all of that in infrastructure code rather than clicking it, because the value of this baseline is that it can be recreated identically in a second environment. Our guide to separate accounts per environment explains why that second environment should be a genuinely separate account.

Mistakes that show up months later

An address range too small to subdivide, discovered when you add a third environment. A security group opened to the whole internet “temporarily” during a debugging session on a Friday. Databases given public addresses because a developer’s laptop needed access, then never removed. Return rules missing from stateless lists, producing connections that open and hang. Load balancer logs disabled, so the one request that caused the incident left no trace.

Every item on that list is cheap to prevent on day one and tedious to fix on day four hundred. The networking baseline is not exciting work, which is exactly why it rewards being done early and once. If you are still choosing where to build it, the provider catalogue lists what each account includes by way of private networking before you commit.

Related comparisons

Azure vs Digital Ocean
vs

Azure vs Digital Ocean

DigitalOcean optimises for a developer getting something running today. Azure optimises for an organisation running a thousand things for a…

Digital Ocean vs Scaleway
vs

Digital Ocean vs Scaleway

A United States developer cloud against a French provider with ARM instances, bare metal and European jurisdiction. Where your customers…

Digital Ocean vs Vultr
vs

Digital Ocean vs Vultr

Vultr gives you more places to run a server and more instance shapes to choose from. DigitalOcean gives you a…

AWS vs Digital Ocean
vs

AWS vs Digital Ocean

How far does a small team get on DigitalOcean before platform complexity starts costing more than it saves? This comparison…

Accounts discussed in this guide

Buy Digital Ocean Account
Buy Digital Ocean Account
DigitalOcean

Buy Digital Ocean Account

The cloud computing industry has a reputation for complexity. Hyperscalers compete on the number of services they offer, the granularity of their pricing, and…

From$25 5 options
Buy Vultr Account
Buy Vultr Account
Vultr

Buy Vultr Account

Vultr has emerged as one of the most compelling alternatives to the major cloud providers, offering a combination of global reach, competitive pricing, and…

From$25 3 options

Keep reading

Developer-First Clouds: Simplicity as a Feature
Provider Guides 7 min read

Developer-First Clouds: Simplicity as a Feature

Smaller cloud providers are described by what they lack, but the restraint is the product. What simplicity buys you, and the specific…

Need the account, not just the theory?

Browse documented configurations across every provider in the catalog, or ask us which one fits your workload.

Telegram