> ## Documentation Index
> Fetch the complete documentation index at: https://docs.layerform.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Why layers

> Understand the benefits of using layers to create development infrastructure.

<div className="flex justify-center items-center">
  <img src="https://mintcdn.com/ergomake-83/br_QNJl4feQWyGIg/images/elephant-spawn.png?fit=max&auto=format&n=br_QNJl4feQWyGIg&q=85&s=d06ad9d8c07d4c90a9c8a0ab6e28b3a2" className="w-96" width="547" height="531" data-path="images/elephant-spawn.png" />
</div>

## The problem

Most companies have a single or too few "staging" environments. Therefore, engineers scramble to see who will use staging or end up merging changes without ever testing them in a production-like environment. Consequently, bugs slip, and there's a lot of rework to rollback changes and apply fixes after broken code has been merged.

<img src="https://mintcdn.com/ergomake-83/br_QNJl4feQWyGIg/images/staging-queue.png?fit=max&auto=format&n=br_QNJl4feQWyGIg&q=85&s=fb79821a5244c17607f9ec43288fa0e1" alt="" width="2075" height="978" data-path="images/staging-queue.png" />

Additionally, when systems are too big or too difficult to run locally, developers point their local applications to the only "staging" environment that exists. Sharing this single "staging" environment causes all sorts of weird behaviour because developers' changes will interfere with one another. Furthermore, when "staging" is broken, no one can write any code.

## The solution

**Layerform solves these problems by allowing each engineer to spin up their own "staging"**. That way, engineers have a production-like environment in which they can test changes before merging any code.

Engineers can also point their local applications to their own development infrastructure when writing code. That way, they won't interfere with one another's changes and won't be blocked if "staging" stops working.

<img src="https://mintcdn.com/ergomake-83/br_QNJl4feQWyGIg/images/multiple-envs.png?fit=max&auto=format&n=br_QNJl4feQWyGIg&q=85&s=67d9f1aa5b82258d0231f6e63ce3e574" alt="" width="2071" height="1110" data-path="images/multiple-envs.png" />

## Why layers?

Layers make it easy for engineers to create their own development environments while sharing core-pieces of infrastructure.

When using Layerform, engineers can encapsulate different types of development environments into layers, and each engineer can spin up the layers they need for developing and testing their applications.

<img src="https://mintcdn.com/ergomake-83/br_QNJl4feQWyGIg/images/dev-multi-layers.png?fit=max&auto=format&n=br_QNJl4feQWyGIg&q=85&s=f6ee7865a1e072a0330d37ca28f361ae" alt="" width="2918" height="1626" data-path="images/dev-multi-layers.png" />

Additionally, Layerform helps you:

* Understand the costs of each layer
* Use terraform to spin-up development environments instead of using error-prone in-house solutions
* Automatically turn-off environments after business hours or when they become inactive

## Symptoms indicating you should use layers

* You have a Slack channel in which developers fight for time slots to use `staging`
* You have created multiple pre-production environments (like `dev` or `sandbox`) in an attempt to avoid breaking `staging`
* You struggle to run all of your services in your machine
* Your developers write code pointing their local applications to `staging`
* You can't deploy code to production once it's gone into `main` because you haven't tested it in a production-like environment before
* You spend a lot of money maintaining a complex and suboptimal in-house system for deploying development infrastructure
