Development environments: permanent, ephemeral and owned

How development environments grow into one of the largest lines on a cloud bill, and what took one team from $40k to $1.5k a month.

  • BITServices team
  • #kubernetes
  • #finops

Development and test environments rarely get the attention production gets, and that is how they become one of the largest lines on a cloud bill. In one company we worked with, development cost $40k a month on AWS. Two months later it cost $1.5k. This is what changed, and most of it applies to any team.

How it gets there

It is a normal result of growth. Every test gets its own environment because that is the fastest way to work. New features are built as new services. Environments live on the same kind of infrastructure as production, often managed Kubernetes with its own nodes, load balancers and volumes. Nobody deletes the old ones, because nobody is sure who still uses them. Without monitoring, nobody can see any of this.

Make it visible first

You cannot cut what you cannot see. Before changing anything:

  • add monitoring for the clusters and the workloads
  • label every environment with its owner, team and purpose
  • break the cost down by environment, service and team

The numbers usually surprise people, and they make the next decisions easy.

Two kinds of environments

Split environments into two kinds and treat them differently.

Permanent environments are shared by the whole team, such as a staging environment. There are only a few, and each has a named owner.

Ephemeral environments are for testing one change. They are created from a branch and deleted automatically when the branch is merged or after a fixed time. Nobody has to remember to clean up.

Split CI and CD

Many pipelines build and deploy in one step, straight into one cluster. Split them:

  • CI builds and tests the image once and pushes it to the registry
  • CD deploys that same image to any environment, each with its own config and secrets

Now the image you tested is the image you ship, and development can run somewhere other than production.

Development does not have to run where production runs

Development needs the same Kubernetes, not the same provider. A cluster on a cheaper provider such as Hetzner Cloud, with its cloud controller manager and CSI driver for load balancers and volumes, runs the same manifests. It needs tooling to create clusters from code and to keep them upgraded, so it does not become a side project for the team.

Look at the architecture

Development cost often points at architecture problems that also cost money in production:

  • a new service for every feature. Each one adds memory, database connections, a pipeline and maintenance. Ask whether the code can live in an existing service.
  • data passed from service to service over REST. If device data or events go hop by hop, write them once to a stream, for example Redis Streams, and let the services that need them read from it.

Make cost part of the work

The changes only last if the team owns them. In our project we trained the team on the platform, showed management and developers how to read the cost data, and wrote runbooks for the maintenance tasks. Cost became part of normal decisions: who creates an environment is responsible for it, and a new service is weighed against what it adds to the bill.