Ephemeral Environments at a Glance
Ephemeral development environments (sometimes called Preview Environments, Testing Environments, or on-demand environments) are one of the newest crazes in DevOps and Developer tooling and for good reason. As developers, we spend way too much time wrestling with environment setup and configuration - installing dependencies, configuring databases, setting up API keys, etc.. By the time you've finished fussing with your various staging and production environments, you've lost momentum, forgotten what you were coding in the first place and need to remember what it is you were doing in the first place. What if you could ditch that hassle and instantly spin up a new development environment for each feature branch that's pre-configured and ready to code in? Enter ephemeral environments.
Ephemeral environments are disposable development environments that are dynamically created when you start working on a new feature branch, and then torn down when you're done. They're like a fresh dev environment for each ticket or set of code changes that's automatically set up just the way you need it. No more waiting 30 minutes for a bottleneck in your dev or staging environment to free up, or dealing with "works on my machine" bugs because your environment has drifted from the main branch. Each ephemeral environment has the latest code, is easy to test, and can be spun down in moments without a second though.
Ephemeral Environments are becoming more of a mainstay for many teams, which is why you may be seeing more CD Pipeline tools touting them as a core feature. When you check out a new branch to work on a feature, your ephemeral environment tooling will spin up a dynamic environment for that branch pre-configured with everything you need to build, test and run your code. Code, commit and push as usual while your ephemeral environment keeps itself up to date. When you merge your branch back into the mainline, your environment self-destructs, leaving no trace it was ever there. No more idle environments chewing up resources or budget.
Ephemeral environments have revolutionized developer productivity and experience at companies like Spotify, Bloomberg and Anthropic by reducing environment setup time from 30 minutes to seconds and increasing deployment frequency by over 10x. Once you've coded with the freedom ephemeral environments provide for the development process, you'll never go back. The future is fast, disposable, and here to stay.
What Are Ephemeral Environments?
Ephemeral environments are temporary, disposable development environments that are created on demand when you start working on a new feature branch. Unlike the static environments you’re probably used to using (e.g. Dev, Staging, Prod) with fixed infrastructure and a continuous lifecycle, Ephemeral Environments aren’t meant to last. They're isolated environments tailored specifically to what you need for that branch. The key thing that makes them ephemeral is that they're torn down automatically when you merge or discard the branch. No more idle dev environments hanging around!
Ephemeral environments solve one of the biggest pain points developers face day to day in application development: environment setup. How many times have you gone to work on a new ticket only to spend 30 minutes installing dependencies, configuring databases and API keys, and getting your environment just right before you can even start coding?
Ephemeral environments are made possible by the combination of two things: containers and Git. Using Docker Containers, you can easily create a scaled-down version of all the underlying services your application needs to run. The ephemeral environment tool then connects those environment specs directly to your Git branches. When you check out a branch, it spins up that environment. When you merge or delete the branch, it tears the environment down automatically. No more idle environments chewing up resources!
Ephemeral environments have been an absolute game changer for developer productivity and experience. Companies like Spotify, Bloomberg and Anthropic have reported increases in developer productivity up to 50% and deployment frequency up to 10x after adopting ephemeral environments. Once you've coded in the freedom of an ephemeral flow, you'll never want to go back. The future is fast, disposable, and here to stay!
The Key Benefits of Ephemeral Environments
Ephemeral environments provide massive benefits for developer productivity, experience, and business costs. Here are the main advantages of using ephemeral environments:
Improved developer experience
Nothing kills your flow like wrestling with environment issues for 30 minutes before you can even start coding. Ephemeral environments spin up in seconds pre-configured with everything you need so you can get straight to work. Each new environment is born with the continuous integration and deployment functionality so you can push code, test it in a high-fidelity environment, and destroy it when you’re done.
Fast feedback loops
With ephemeral environments, you get a fresh dev environment for each new feature branch. That means you can build, test, and perform iteration loops on your code immediately without waiting for a shared environment to become available. Not only that, but these environments are shareable, so you can collaborate and test with your team.
Ephemeral environments are walled off from each other, so there's no danger of environment drift or interacting with other in-progress features. Each branch gets its own separate space to work.
Ephemeral environments are created from environment specs you define in code, so each new environment is spun up the exact same way. No more "it works on Bob's machine" because you can reproduce Bob's environment to debug issues.
Ephemeral environments are temporary, so when a feature branch is merged or discarded, its environment is destroyed. No more paying for idle environments that are only used occasionally. Ephemeral environments cut costs by only existing when they're actually needed.
Less environment sprawl
Before ephemeral environments, team members would spin up new environments for different use cases and stakeholders and then forget to tear them down, creating environment sprawl. Ephemeral environments are temporary by definition, so sprawl is impossible. When a branch is done, so is its environment.
Ephemeral environments revolutionize the developer experience by eliminating environment hassle and providing fast feedback loops and isolation. The benefits to productivity, costs, and code quality are huge. No wonder so many cutting-edge companies have adopted ephemeral environments as a best practice!
As long as you can define your environment in a Dockerfile or Kubernetes manifest, you can make it ephemeral. Other tools like Skaffold and Tilt are more opinionated, focusing on specific tech stacks, but can get you up and running even faster.
The future is fast, disposable, and coded environments as infrastructure. Ephemeral environments have revolutionized the developer experience by turning environment setup from a tedious, manual process into an automated, code-driven one. The less time we spend wrestling with environments, the more time we have to build amazing software. Ephemeral environments give us back the joy of coding by handling the hassle of environments.
Getting Started with Ephemeral Environments
So ephemeral environments sound like pretty good - what's the catch? Luckily, the barrier to getting started with ephemeral environments is pretty low. All you need are a few tools, a bit of configuration, and the motivation to implement them. Here's what you'll need to implement ephemeral environments:
1. Choose an ephemeral environment tool
We’re obviously partial to our own tool, but any of them will work. I can’t speak too much for the others, but for Zeet, you literally deploy the code, select the preview branch setting, and you’re good to go. In general, all of these tools connect your environments to Git branches and handle the creation and teardown automatically. They support any Docker and Kubernetes-based environment so you have flexibility in how you define your environment specs.
2. Define your environment specs
With some tools, you'll need to create Dockerfiles, Kubernetes manifests, or other config that defines what your environment and any microservice dependencies look like. The ephemeral environment tool will use these specs to spin up your environments on demand. With Zeet, you thankfully don’t have to do any of these steps, as we’ll take care of those for you. In any case, make sure to keep your environment definitions minimal and avoid baking in anything branch-specific.
3. Connect environments to branches
With whatever tool you use, you'll configure your ephemeral environment tool to spin up an environment for each feature branch. Most tools can connect to your Git host (GitHub, GitLab, Bitbucket) to watch for new branch creation events and act accordingly.
4. Automate environment creation
When your ephemeral environment tool detects a new feature branch, it will use your environment specs to build and deploy a new environment connected to that branch. Whether you use Jenkins, Github Actions, or Zeet for your CI/CD tool, they all integrate well with the various ephemeral environment tools. Developers just need to check out the branch to start working in the environment. Again, with Zeet, it’s all in one, so you can use us for CI/CD and Ephemeral Environments, but pick what’s best for you!
5. Tear down environments on merge/delete
Once a feature branch is merged or discarded, your ephemeral environment tool will automatically tear down the connected environment. No more idle environments wasting resources!
The shift to ephemeral environments does require a mindset change for developers who are used to long-lived environments. However, the productivity and cost benefits are huge. With the right tools and automation in place, ephemeral environments can revolutionize your development workflow and make environment setup a thing of the past. The days of "works on my machine" are numbered!
Limitations and Considerations
Ephemeral environments do come with a few limitations to be aware of. They require investment in additional tooling and processes. There is a learning curve for developers to adapt to this new workflow. Ephemeral environments may not suit monolithic applications with long build times. And because ephemeral environments have full access, security of these environments can be a concern. However, for most development teams, the pros far outweigh the cons. Ephemeral environments are the future of fast, efficient software development.
Operating ephemeral environments at scale can also present challenges. If you have hundreds of developers working on dozens of features at a time, orchestrating all those environments and resources could get messy. Some solutions are better suited to massive scale than others. You'll want to consider how well a tool can integrate with your existing infrastructure and if they offer enterprise-level support.
At the end of the day, while ephemeral environments provide massive benefits, they also require investment to implement properly. For some organizations, the costs may outweigh the rewards. However, if improving developer experience and productivity is a priority and you have the means to support it, ephemeral environments can be a game changer. The key is starting small by piloting a solution on a single team or project to learn the ropes before going all in.
With the right tooling and processes in place, the limitations of ephemeral environments are manageable. And as the technology and tools continue to mature, many of the challenges we face today may disappear altogether.
How you can get started with Ephemeral Environments
If you're sold on the benefits of ephemeral environments and want to get started, Zeet is a great tool to check out. Zeet supports any Docker and Kubernetes-based environment and connects ephemeral environments directly to your Git branches and cloud resources, no matter how many clouds you have. When you check out a branch, Zeet will spin up an environment for that branch in seconds pre-configured with everything you need. Code away on your feature and Zeet will automatically keep your environment up to date with your changes. When you merge or delete the branch, Zeet tears your environment back down, leaving no trace it was ever there.
The best part about Zeet is it works with any Docker and Kubernetes setup you already have. Don't have one? No problem, Zeet can set one up for you too. All you need to get started with Zeet is:
1. A cloud connection. If you’ve got a cloud account, simply connect Zeet to it and you’re done ever using a cloud console again.
2. Connect your Git repository so Zeet knows which branches to connect environments to.
3. Make a Pull Request, and point the branch at your preview branch.
4. Test away, and when you’re done, click destroy.
And that's it! Once you've got Zeet connected to your repo and environments, you'll instantly start reaping the benefits. No more waiting for environments to start up or dealing with environment drift. Each branch gets a clean slate and temporary environments are torn down as soon as you're done with them.