← Back to blog

October 12, 2026 · 21 min read

Cloud Fundamentals Every Senior Engineer Needs

From Mid-Level to Senior · Part 11 of 18

  • #cloud
  • #aws
  • #gcp
  • #devops
  • #senior-engineer
  • #engineering-practices

Sooner or later you sit in a design review and someone says: "Put it in a private subnet behind the ALB, give the task role read access to the bucket, and keep an eye on the NAT costs."

Half the room nods. If your work so far has been writing the service and watching the pipeline go green, that sentence has four things in it you'd have to look up, and nobody stops the meeting for you to do it.

The list of things to learn is shorter than the provider consoles make it look. AWS has more than two hundred services and GCP isn't far behind, but an architecture conversation about a backend system keeps returning to the same five questions:

  1. Where does the code run? (compute)
  2. How do requests get to it, and what can it reach? (networking)
  3. Who operates the things it depends on? (managed vs self-run)
  4. Who is allowed to do what? (IAM)
  5. What does it cost, and what makes the cost grow?

Part 10 ended with mitigations like "scale out" and "fail over to another zone", which assume you know what the platform under your service can do. This part is that knowledge. I'll use AWS and GCP names side by side, because those are the two I've run production systems on, and because seeing both makes it easier to notice which part is the concept and which part is branding.

One running example for the whole post: order-service, a Spring Boot API with a PostgreSQL database, a queue for asynchronous work, and a bucket for generated PDFs. Nothing exotic. Most backend systems are some version of it.

Where the code runs

There are three families of compute, and every provider sells all three.

Three columns comparing compute options. Virtual machine, for example EC2 or Compute Engine: you manage the operating system, patches, runtime and the app; it scales by adding machines, in minutes; you pay per hour the machine is on, busy or idle; it fits software that needs the OS, licences or unusual hardware; watch out for patching and images that drift apart. Container platform, highlighted in amber, for example ECS on Fargate, EKS, Cloud Run or GKE: you manage the image and its CPU and memory settings; it scales by adding containers, in seconds; you pay for the CPU and memory you request; it fits long-running services, APIs and workers, which is most backends; watch out for requests and limits that don't match real usage. Functions, for example Lambda or Cloud Run functions: you manage only the code and its configuration; it scales per request and down to zero; you pay per request and per millisecond of execution; it fits event handlers, glue code and spiky low-volume work; watch out for cold starts, time limits and many small pieces to follow. A note at the bottom says that the further right you go, the less you operate and the less you control, and that the default for a Spring Boot service is the middle column.

Virtual machines (EC2, Compute Engine). You get a computer with an operating system. Everything above the hypervisor is yours: patches, the JDK, the process manager, disk space, log rotation. You pay for every hour the machine is on, whether it's serving requests or idle at 3 a.m.

Containers (ECS and EKS on AWS, Cloud Run and GKE on GCP). You hand over an image and say how much CPU and memory it needs. The platform decides where it runs, restarts it when it dies, and adds copies when load goes up. There are two flavours, and the difference matters for your weekends. With Kubernetes (EKS, GKE) you get the full API and a cluster to look after: upgrades, node pools, add-ons. With the "serverless container" products (Fargate, Cloud Run) there's no cluster for you to see. You give up some control and get a lot of time back.

Functions (Lambda, Cloud Run functions). You hand over code that handles one event. It scales per request, goes down to zero when nothing is happening, and you pay per invocation and per millisecond.

For order-service, the answer is the middle column, and for most Java backends it will be. A long-running HTTP service with a connection pool and a warm JIT is exactly what container platforms were built for.

Two things about the JVM are worth knowing here.

The first is memory. A JVM in a container reads the container's memory limit, but by default it only takes a quarter of it for the heap. In a 1 GB container that's a 256 MB heap and a lot of memory you're paying for and not using. Set it explicitly:

ENTRYPOINT ["java", "-XX:MaxRAMPercentage=75", "-jar", "/app/app.jar"]

Leave the other 25% for metaspace, thread stacks and off-heap buffers. If you set the heap to 100% of the limit, the platform kills the container the first time non-heap memory grows, and the only thing you'll see is OOMKilled with no Java stack trace.

The second is startup time. A Spring Boot application takes seconds to start, and that's fine for a container that then lives for days. It's a problem for a function that starts on demand while a user waits. There are ways around it (Lambda SnapStart, CRaC, GraalVM native images), and each one has its own cost in build complexity. If someone proposes putting a Spring Boot service on functions, "what's the cold start, and who sees it?" is the question to ask.

Functions do have a place in this system. Something like "when a PDF lands in the bucket, generate a thumbnail" runs a few hundred times a day and has nobody waiting on it, which is the shape functions are good at. Use them for the edges of a system. I'd be careful about making them the core of one.

How requests get there

Networking is where most backend engineers feel least at home. You can get a long way with one picture.

Diagram of a virtual network with address range 10.0.0.0/16 spread over two availability zones. At the top, the internet sends traffic to a load balancer that spans both zones and is the only component with a public address. In each zone there are three layers. A public subnet, with a route to the internet, holds the load balancer nodes and a NAT gateway. A private application subnet holds the order-service containers, which accept traffic only from the load balancer and reach the internet outbound through the NAT gateway. A private data subnet holds PostgreSQL, primary in zone A and standby in zone B, which accepts traffic only from the application on port 5432 and has no route to the internet. A note at the bottom says that a subnet is public or private because of its route table and not because of its name, and that firewall rules should reference the source group, not IP addresses.

A VPC is your private network. It has a range of private IP addresses, written in CIDR notation: 10.0.0.0/16 means the 65,536 addresses that start with 10.0. Nothing gets in or out unless you build a path for it.

Regions and zones. A region is a geographic area (sa-east-1 is São Paulo on AWS, southamerica-east1 on GCP). Inside it there are several availability zones, which are separate data centres close enough to act as one network. A whole zone going down is rare, but it happens, and running in two or three zones is the cheapest insurance against it. A whole region going down is much rarer, and protecting against that costs a lot more. Most systems don't need it. The ones that do usually know it already.

Subnets divide the VPC's range into smaller ones. What makes a subnet public or private is its route table, whatever name someone gave it. A public subnet has a route to an internet gateway. A private subnet doesn't, so nothing on the internet can open a connection to what's inside.

The layout in the diagram is the one you'll find, with small variations, in most production systems:

  • The load balancer sits in the public subnets and is the only thing with a public address. It terminates TLS and spreads requests over healthy instances in both zones.
  • The application sits in private subnets. It receives traffic from the load balancer and nothing else.
  • The database sits in private subnets with no path to the internet at all, with a standby in the second zone.

Outbound traffic from a private subnet needs a NAT gateway. order-service calls a payment provider's API, so its requests leave through the NAT, which has a public address and translates on the way out. Remember that it exists. It comes back in the section on cost.

Firewalls. AWS calls them security groups and GCP calls them firewall rules. Both are lists of "allow this traffic from that source". The habit to pick up is referencing sources by identity rather than by IP address. The database rule should say "allow port 5432 from the application's security group". Don't write it as "allow port 5432 from 10.0.3.0/24". The first one stays true when instances come and go, and it can be read by someone who doesn't have the subnet plan memorised.

This is also the first place where the two providers differ in a way that matters. On AWS, a VPC belongs to one region and each subnet to one zone. On GCP, a VPC is global and each subnet covers a whole region. The picture above still applies to both, but if you carry the AWS layout into GCP line by line you'll create more subnets than you need.

When something can't connect, the list of suspects is short and the order rarely changes. Check DNS first (does the name resolve to what you think?), then the route (is there a path between the two subnets?), then the firewall (is the port allowed from this source?), and finally the application (is it listening on that port, on that interface?). A connection that hangs until it times out usually points at a firewall or a route. An immediate "connection refused" means you reached the machine and nothing was listening on that port.

Managed or self-run

The database for order-service can be a PostgreSQL you install on a VM or a managed one (RDS or Aurora on AWS, Cloud SQL or AlloyDB on GCP). The same choice exists for queues, caches, search, Kafka and Kubernetes itself.

A managed service costs more per hour than the same capacity on raw VMs. What you get for the difference is that someone else handles backups, patching, failover, minor version upgrades and replacing failed disks. The trade-off is that you lose some knobs: no superuser, a fixed list of extensions, upgrade windows you can influence but not fully control.

I ask three questions before deciding:

  • Is running this thing what our company is good at, or what it sells? For almost every product company, operating PostgreSQL is neither.
  • Who gets paged when it breaks at 3 a.m., and do they know how to do a point-in-time restore? If the answer is "the one person who set it up", you don't really have a self-run database. You have a single point of failure, and it happens to be a colleague.
  • What does the managed version stop us from doing, and do we need that? Sometimes it's a real limit, like an extension you depend on. Most of the time you never hit it.

My default is managed for anything that holds state, and I want a specific reason to do otherwise. Stateless things are easy to run yourself, because when one breaks you can replace it. Stateful things are where an operational mistake loses data.

Then there's lock-in, which comes up every time. It helps to separate two kinds. Managed PostgreSQL is still PostgreSQL: you can dump it and restore it somewhere else, and your code doesn't change. A proprietary database with its own API and data model (DynamoDB, Firestore, Spanner) is a different commitment, because moving away means rewriting the data access layer and sometimes rethinking the model. That can still be the right choice. It should be a decision somebody made, with the exit cost written down. Too often it's just what the first tutorial happened to use.

Wrapping everything in abstraction layers "in case we change providers" isn't something I'd recommend. You pay for that every day in indirection and lost features, to save on an event that may never happen. Keeping provider SDKs behind your own interfaces at the edge of the application is usually enough, and it's just normal good design.

Who is allowed to do what

Every provider's permission system, with all its vocabulary removed, answers one question: can this principal perform this action on this resource?

  • A principal is a person or a workload.
  • An action is an API call: read an object, publish a message, start an instance.
  • A resource is the specific thing: this bucket, that queue.

A policy puts the three together. This is the AWS format, which lets order-service read and write PDFs in one bucket and nothing else:

{
  "Effect": "Allow",
  "Action": ["s3:GetObject", "s3:PutObject"],
  "Resource": "arn:aws:s3:::acme-invoices-prod/*"
}

GCP expresses it the other way around. You grant a role (a named set of permissions, such as roles/storage.objectUser) to a principal on a resource. The syntax is different, but you're still naming the same three things.

Three habits cover most of what goes wrong with IAM.

Workloads get roles, not keys. The old way was to create an access key, paste it into an environment variable, and forget about it for four years. The current way is to attach an identity to the workload itself: an IAM role for the ECS task or the Kubernetes service account on AWS, a service account with Workload Identity on GCP. The platform hands the running container short-lived credentials and rotates them. Your code doesn't hold a secret at all:

// No keys anywhere. The SDK finds the role attached to the workload.
S3Client s3 = S3Client.create();

This is the same idea as the OIDC setup for pipelines from Part 8. A credential that expires within the hour and never sat in a file is very hard to leak.

Start narrow. s3:* on * makes the error go away, and it also means a bug or a compromised dependency in order-service can read every bucket in the account. Grant the actions the code calls on the resources it uses. When you get AccessDenied, read the message, since it names the exact action and resource that were refused. Add that one and move on.

Separate environments at the account level. An AWS account or a GCP project is the strongest boundary the provider gives you. Production in its own account means a mistake in a staging policy can't touch production data, and it also makes the bill readable. More on that next.

Humans follow the same rules: single sign-on, roles assumed for a limited time, and no personal long-lived keys on laptops. If your team still shares a root or owner login, fix that before anything else in this post.

Cost is a design constraint

On your own hardware, a wasteful design is slow. In the cloud it's also an invoice, and the invoice arrives a month later, when nobody remembers which decision caused it.

You don't need to memorise price lists. Know the four things that are metered, and for each one, what makes it grow.

What's meteredWhat makes it growThe usual surprise
Compute timeInstances × size × hours onStaging running nights and weekends, memory requested and never used
StorageGB stored × how longSnapshots and old log buckets nobody deletes
Data movementGB leaving the provider, crossing zones, or passing through a NATA chatty service calling across zones, large downloads through the NAT
Requests and managed premiumsCalls, messages, GB of logs ingestedDebug logging left on in production

The third row is the one that catches experienced teams. Traffic coming in is generally free. Traffic going out to the internet is charged per GB. Traffic between zones is charged too, at a lower rate, and so is every GB that goes through a NAT gateway. Each of those is small per gigabyte and none of them shows up in an architecture diagram. A service that pulls large files from an external API through the NAT all day can cost more in data processing than in compute.

Logs are the other regular. A single DEBUG line in a hot path, multiplied by production traffic and charged per GB ingested, has funded many awkward conversations. That's the cost side of what Part 9 said about log levels and cardinality.

What a senior engineer does about cost is mostly unglamorous:

  • Tag everything with service, environment and team from day one. You can't reduce a bill you can't break down by owner.
  • Estimate before building. A rough number is enough: how many instances, how much data, how many GB moving and to where. If you can't estimate it, you don't understand the design yet.
  • Right-size from real metrics. Look at CPU and memory actually used over two weeks and compare with what's requested. The gap is usually large.
  • Turn off what isn't being used. Development and staging environments don't need to run at night.
  • Commit only to what's stable. Reserved capacity and savings plans give real discounts in exchange for a one or three year commitment. Use them for the baseline that's been flat for months, and don't commit to a forecast.
  • Set a budget alert. It takes five minutes and turns a surprise at the end of the month into a message on day six.

A caution in the other direction: engineer time is also a cost. Spending two weeks to save forty dollars a month is poor optimisation. Go after the biggest lines on the bill and leave the rest alone.

The same model under different names

Here are the same concepts with both providers' names next to each other.

A table with three columns: the concept, its name on AWS and its name on GCP. Isolation and billing boundary: account, project. Private network: VPC, which is regional, and VPC, which is global. Virtual machine: EC2, Compute Engine. Managed Kubernetes: EKS, GKE. Containers without a cluster: ECS on Fargate, Cloud Run. Functions: Lambda, Cloud Run functions. Object storage: S3, Cloud Storage. Managed PostgreSQL: RDS or Aurora, Cloud SQL or AlloyDB. Queue and pub/sub: SQS plus SNS, Pub/Sub. HTTP load balancer: Application Load Balancer, which is regional, and Application Load Balancer, which is global. Workload identity: IAM role, service account. Secrets: Secrets Manager, Secret Manager. A note at the bottom says that the closest equivalent is not the same thing, and that the differences are in the defaults, the limits and the failure behaviour.

The table is useful for the first week and misleading after that, because "closest equivalent" doesn't mean "same behaviour". A few differences that matter in practice:

  • Queues. SQS is a queue: consumers pull, and fan-out to several consumers needs SNS in front. Pub/Sub is topics and subscriptions in one product, and it can push to an HTTP endpoint. Ordering, delivery retries and dead-letter handling are configured differently in each. A consumer written for one makes assumptions the other doesn't honour.
  • Load balancers. GCP's HTTP load balancer is global, with one IP address in front of several regions. AWS's is regional, and going multi-region means adding another layer on top.
  • Networks. As mentioned above: global VPC with regional subnets on one side, regional VPC with zonal subnets on the other.
  • IAM. AWS attaches policy documents to identities and to resources. GCP binds roles at a level of a hierarchy (organisation, folder, project, resource) and they inherit downwards. The question "who can read this bucket?" is answered by looking in different places.

So learn the concept first, then learn where your provider's version deviates from it. Someone who understands what a queue guarantees will be productive on Pub/Sub in a day. Someone who only knows which buttons to press in the SQS console is starting over.

What I'd repeat on any migration

I led the migration of a company's platform from GCP to AWS: around thirty services and workloads, an external vendor working with the internal team, under three minutes of downtime, and a cloud bill about 10% lower afterwards.

Looking back, very little of what made it work was specific to AWS. It was the five questions from the top of this post, asked about each service in turn. This is what I'd do again on any move of that size, between any two providers:

  • Write the map before touching anything. For each component, what it does today and what its closest equivalent is on the other side. Then mark the ones where "equivalent" hides a design change. There are always a handful, and they are where the schedule goes.
  • Run both sides in parallel. Bring the new environment up next to the old one and test it with real traffic patterns before any customer depends on it. A cutover is a bad moment to discover anything.
  • Treat data as the hard part. Stateless services move in an afternoon. The database decides how long the downtime window is, so that's what deserves rehearsal: replication, the final sync, and the check that both sides agree.
  • Rehearse the cutover and write the rollback. A cutover measured in minutes comes from a list of steps that has already been executed more than once, with a point marked on it where going back is still cheap.
  • Lower DNS TTLs days in advance. It's a small thing that is easy to forget. If the TTL is 24 hours when you switch, some clients keep going to the old address for 24 hours.
  • Use the move to right-size. A migration forces you to write down what every service needs. It's the one moment when questioning each instance size costs nothing extra.

The lesson I took from it is that the provider's names were the cheap part to learn. The expensive part was knowing what each piece of the system needed from the platform, and that knowledge didn't depend on the provider at all.

What to try this week

  • Draw your service's network path. From the user's browser to the database: load balancer, subnets, firewall rules. If you can't, that's what to ask your platform team about.
  • Find out how your service authenticates to the cloud. A role attached to the workload, or a key in an environment variable? If it's a key, find out how old it is.
  • Read your service's permissions. Look for * in actions or resources and ask whether it needs to be there.
  • Check the JVM heap settings in your container. Compare the memory limit with the heap the JVM actually took.
  • Open the bill. Find the three biggest lines for your team's account or project. Can you explain each one?
  • Look up one equivalent. Take a managed service you use and read the other provider's version of it. Write down two ways they differ.

The short version

  • Five questions cover most cloud conversations: where the code runs, how traffic reaches it, who operates its dependencies, who's allowed to do what, and what it costs.
  • Compute comes as VMs, containers and functions. The further you go toward functions, the less you operate and the less you control. A Spring Boot service usually belongs on a container platform.
  • Set the JVM heap for the container explicitly, and leave room for non-heap memory.
  • A VPC is a private network. Public subnets hold the load balancer, private subnets hold everything else, and the database has no path to the internet.
  • Use more than one zone. Multi-region is for the systems that can justify what it costs.
  • Default to managed for anything stateful, and know which kind of lock-in you're accepting.
  • IAM is principal, action, resource. Workloads get roles instead of keys, permissions start narrow, and environments live in separate accounts or projects.
  • Cost has four meters: compute time, storage, data movement and requests. Data movement is the one that surprises people.
  • Service names map between providers, but behaviour doesn't always. Learn the concept, then the deviations.

Now that you know what the platform can do, with several copies of a service behind a load balancer across zones, the next question is how to replace those copies with a new version without everyone noticing. That's Part 12: blue-green, canary and rolling deployments, what each one costs, and how to make a release something you can take back.

This is Part 11 of 18 in the series. The Senior Engineer Roadmap maps the whole series, with a short self-assessment and four reading orders.