In Part 3, our static EC2 Agent worked exactly as expected. Builds no longer ran on the Jenkins Controller, the execution environment had its own compute boundary, and labels gave us a clear way to control where Pipelines should run.
But a working architecture is not necessarily a scalable one.
As Jenkins adoption grows, a single static Agent is rarely enough. More concurrent builds require more execution capacity, while different workloads begin to require different types of Agents. A Java build may need Maven and a specific JDK, a frontend Pipeline may require Node.js, an infrastructure Pipeline may need Terraform and the AWS CLI, and a security Pipeline may depend on its own scanning tools.
Before long, one static Agent becomes a fleet of static Agents.
And then another problem becomes difficult to ignore: most of that capacity is not busy all the time.
Outside peak development hours, during quiet periods, or over weekends, EC2 Agents may sit idle while still consuming compute and storage cost. They also continue to require patching, monitoring, Java/runtime maintenance, disk management, and operational attention whether or not a Pipeline is actually running.
At that point, the question is no longer simply:
How many Jenkins Agents do we need?
A more useful question is:
Why should build capacity exist when there is no build waiting to run?
That question takes us from static Jenkins Agents to elastic Jenkins Agents.
In Part 4, we will define what an elastic Agent means from the Jenkins perspective, compare three practical AWS execution models—dynamic EC2, Amazon ECS with AWS Fargate, and Amazon EKS—and then select the target architecture for the next stage of the series.
1. When One Static Agent Becomes a Fleet
The static EC2 Agent from Part 3 solved the first architectural problem correctly: build execution moved away from the Controller. The Controller can focus on the Queue, scheduling, Pipeline orchestration, and Jenkins state, while the Agent owns the Executor, Workspace, tools, and build compute.
The next challenge appears when usage grows.
More builds require more Agents
With one Agent and one Executor, only one compatible build can execute at a time. As more developers push code or more repositories start using Jenkins, the Queue begins to grow.
The obvious response is to add more static Agents.
That works—but every additional Agent becomes another EC2 instance that must be provisioned, connected to Jenkins, monitored, patched, and eventually replaced.
Different workloads require different Agent types
Capacity is not only about quantity.
Different Pipelines often require different execution environments:
- Java builds may require a specific JDK and Maven or Gradle.
- Frontend builds may require Node.js and package managers.
- Infrastructure Pipelines may require Terraform, the AWS CLI, and deployment tooling.
- Security workloads may require scanners, SBOM tools, or additional CPU and memory.
- Some workloads may require completely different instance sizes or operating-system capabilities.
As a result, scaling Jenkins can turn a small worker pool into a collection of specialized Agent types.
Static capacity creates an efficiency problem
The problem becomes most visible when demand falls.
A static Agent exists before a build arrives and remains running after the build completes. If there are no builds overnight, the Agent still exists. If a specialized Agent is used only a few times per day, we still pay for the rest of its uptime.
The operational cost also remains. Idle hosts still need OS patching, Java/runtime upgrades, monitoring, disk cleanup, image management, and lifecycle maintenance.
The static model is therefore not wrong. It is simply optimized for stable, predictable demand.
CI/CD demand is often different: quiet for periods of time, then suddenly bursty.
That mismatch between fixed worker capacity and variable build demand is the reason we now need to discuss elasticity.
2. What Do We Mean by an Elastic Jenkins Agent?
An elastic Agent is execution capacity that Jenkins can obtain when demand appears and release when that demand disappears.
Conceptually, the lifecycle becomes:
The Jenkins fundamentals from the first three parts do not change. There is still a Queue, an Agent, an Executor, a Workspace, and a Controller making scheduling decisions. The difference is that the Agent is no longer assumed to exist before the build request arrives.
That change affects cost, isolation, scaling latency, image management, credentials, cleanup, and failure handling.
3. What Should Our Elastic Platform Optimize For?
Before comparing AWS services, we need to define what we are optimizing for. For this series, the target Jenkins platform should keep builds away from the Controller, provision capacity from demand, prefer immutable execution environments, isolate workloads by tools/resources/IAM permissions, minimize infrastructure we must patch, remain understandable to a DevOps/SRE engineer, and leave room for production concerns such as cost, observability, recovery, and Infrastructure as Code.
Those requirements give us a clearer definition of the problem. We do not simply need more Jenkins Agents. We need an execution platform that can create the right type of Agent when demand appears, give that Agent the resources and permissions required by the workload, and remove the capacity when the work is finished.
On AWS, there are three practical execution models we want to evaluate in this series:
- Dynamic EC2 Agents keep the virtual-machine model from Part 3, but provision and terminate those machines dynamically.
- ECS Fargate Agents change the execution unit from a virtual machine to an on-demand container task.
- EKS Agents move the same idea into Kubernetes, where Jenkins provisions an ephemeral Pod for the workload.
Conceptually, all three options are solving the same Jenkins problem:
The Jenkins model remains the same. What changes is the compute platform responsible for creating and running the Agent.
That gives us a natural way to evaluate the options: start with the architecture we already understand—EC2—and progressively remove infrastructure management until we find the right balance for this series.
3.1. Option 1 — Elastic Agents on Amazon EC2
The most conservative way to introduce elasticity is to keep the execution model we already built in Part 3.
Instead of maintaining EC2 Agents permanently, Jenkins can create an EC2 instance when additional capacity is required and terminate it when that capacity is no longer needed. In other words, we keep the EC2 Agent model, but change its lifecycle from static to dynamic.
Jenkins can provision EC2 Agents dynamically. The Jenkins Amazon EC2 plugin can launch instances when Jenkins needs additional execution capacity, connect them as Agents, and terminate excess instances when demand falls. This is Jenkins-aware provisioning driven by build demand. Generic EC2 Auto Scaling can also manage EC2 fleet capacity, but it is a separate infrastructure mechanism rather than a direct replacement for Jenkins Agent provisioning.
Conceptually:
Why dynamic EC2 is attractive
EC2 provides maximum operating-system flexibility. Build Agents can use custom AMIs, specialized instance families, large local disks, GPUs, or host-level tooling. Workloads that require Docker daemon access, privileged operations, unusual kernel features, or specialized hardware may fit EC2 better than a serverless container runtime.
It is also a natural evolution from Part 3 because we already understand the EC2 Agent model.
What remains operationally expensive
The unit of capacity is still a virtual machine. We still own AMI lifecycle, OS patching, Java/runtime updates, disk management, bootstrap behavior, and instance startup time.
Dynamic provisioning reduces idle capacity, but it does not remove host lifecycle management.
For some Jenkins environments, that trade-off is completely reasonable. EC2 remains the strongest option when build workloads need host-level control or highly specialized compute.
Dynamic EC2 solves the idle-capacity problem without changing the execution model we already understand. But every Agent is still a virtual machine, so AMI lifecycle, operating-system maintenance, bootstrapping, and disk management remain part of the platform.
That leads to the next question:
What if Jenkins could request build capacity without us managing the worker operating system at all?
That is where AWS Fargate changes the model.
3.2. Option 2 — Amazon ECS with AWS Fargate
Instead of provisioning an entire virtual machine for a Jenkins Agent, Amazon ECS with AWS Fargate lets us provision a container task.
The execution unit therefore changes from EC2 Instance → Jenkins Agent to Fargate Task → Jenkins Agent Container.
With Amazon ECS and Fargate, we define the container image, CPU, memory, networking, IAM roles, and other task settings. AWS runs the task without requiring us to provision or manage the underlying EC2 worker fleet.
For Jenkins, this maps naturally to ephemeral build Agents:
A build environment can therefore become a versioned container image rather than a long-lived server.
Why this fits our goals
Each workload can have its own Agent template, image, CPU/memory size, label, and IAM Task Role. A Java Agent can be different from a Terraform Agent without maintaining two permanent EC2 machines.
Fargate also removes the EC2 worker-node layer from the Agent platform. We define the task image, CPU, memory, networking, and IAM boundaries, while AWS provides and operates the underlying compute for each task.
Fargate removes server management for the compute layer. It does not remove Jenkins operations.
The Jenkins Controller still needs configuration, plugins, state, backup, observability, security, upgrades, and recovery.
Constraints we must accept
Fargate is deliberately more constrained than a general-purpose EC2 host. Some low-level container capabilities are unavailable, including privileged containers, and workloads that need direct host-level control may require another execution model.
That is a trade-off rather than a defect. For standard compile, test, scan, package, Terraform, and deployment workloads, the simpler compute lifecycle can be more valuable than unrestricted host access.
Fargate gives us disposable container-based Agents without requiring us to manage worker servers. But containers can also be orchestrated through Kubernetes, and Jenkins has a mature pattern for creating ephemeral Kubernetes Agents.
That introduces our third option:
What if Jenkins Agents were scheduled as Kubernetes Pods instead of ECS tasks?
For organizations already operating Kubernetes, that can be a very powerful model.
3.3. Option 3 — Amazon EKS
With Amazon EKS, the execution unit changes again. Instead of an EC2 instance or an ECS task, Jenkins requests a Kubernetes Pod.
Amazon EKS gives us managed Kubernetes on AWS. Jenkins can use Kubernetes-style ephemeral Agents, where each build receives a Pod with the containers, resources, volumes, and workload identity that the job requires.
Conceptually:
This is a powerful execution model. Kubernetes gives us rich scheduling, namespaces, resource requests and limits, multiple containers in a Pod, affinity rules, ecosystem tooling, and a mature pattern for ephemeral Jenkins Agents.
Amazon EKS also reduces infrastructure management through a managed control plane and several compute models, including managed node groups, EKS Fargate, and EKS Auto Mode.
When EKS is the right answer
If an organization already operates EKS as a shared platform, Jenkins Agents on Kubernetes can be an excellent choice. The cluster already exists, the team understands Kubernetes, observability and policy may already be standardized, and Jenkins becomes another workload on an established platform.
The equation changes when Jenkins is the reason we need Kubernetes.
Kubernetes introduces its own platform concepts: cluster lifecycle, API access, RBAC, networking, storage, Pod scheduling, resource management, upgrades, add-ons, and operational troubleshooting. EKS can reduce a significant amount of infrastructure work—especially with managed node groups or Auto Mode—but it does not remove the Kubernetes operating model or the need to understand scheduling, networking, identity, policy, and workload behavior.
At this point, all three architectures can provide Jenkins with elastic execution capacity.
The question is therefore no longer:
Which option can create dynamic Jenkins Agents?
All three can.
The more important question is:
Which option gives us the right balance of operational complexity, workload flexibility, isolation, scaling behavior, and infrastructure ownership for the Jenkins platform we are building?
That is the comparison we need to make next.
3.4. Comparing the Three Models
| Dimension | Dynamic EC2 Agents | ECS Fargate Agents | EKS Agents |
|---|---|---|---|
| Execution unit | Virtual machine | ECS task / container | Kubernetes Pod |
| Host management | Highest | Lowest | Depends on EKS compute model; lower with managed options such as Auto Mode or EKS Fargate |
| Agent lifecycle | Dynamic VM | Ephemeral task | Ephemeral Pod |
| Startup model | Boot VM + bootstrap + connect Agent | Provision task + pull image + start container + connect Agent | Schedule Pod + pull image + start containers; may also require new node capacity |
| Provisioning latency / Time to ready Executor | Usually the longest path because Jenkins waits for EC2 launch, OS boot, bootstrap, and Agent connection | Typically shorter than a fresh VM path; depends on task provisioning, networking, image pull, and container startup | Low when schedulable cluster capacity already exists; can increase significantly when new worker nodes must be provisioned |
| Capacity dependency | Requires EC2 instance capacity to be launched and initialized | Fargate provides the worker compute; no pre-existing Jenkins worker fleet is required | Requires schedulable Kubernetes capacity; on node-backed EKS, Pods may remain Pending while additional nodes are provisioned |
| Workload isolation | Strong VM boundary | Task boundary | Pod / node architecture dependent |
| Build environment | AMI + bootstrap | Container image | Container image / Pod template |
| Specialized hardware / host access | Best flexibility | More constrained | Strong flexibility with suitable nodes |
| Platform knowledge required | EC2 / Linux | ECS / containers | Kubernetes + EKS |
| Idle worker capacity | Can scale down with automation | No permanent Agent task required | No permanent Agent Pod required |
| Best fit | Host-specific or specialized builds | Container-friendly Jenkins workloads with low infrastructure overhead | Organizations already standardized on Kubernetes |
Provisioning latency matters to Jenkins
Elasticity is not only about whether a platform can scale. It is also about how quickly new capacity becomes usable by Jenkins.
For this comparison, Provisioning latency / Time to ready Executor means the time from Jenkins detecting that it needs additional execution capacity until a matching Agent is Online and an Executor can actually accept the queued build.
From the developer's perspective, that delay becomes part of Jenkins Queue Time.
With dynamic EC2, the path includes launching a virtual machine, booting the operating system, running any bootstrap logic, and connecting the Agent to Jenkins. With ECS Fargate, the path shifts to task provisioning, networking, image pull, container startup, and Agent connection. With EKS, a Pod can start quickly when suitable node capacity already exists, but if the cluster has insufficient capacity, the Pod may remain Pending while new worker nodes are provisioned and become Ready.
That is why a simple fast / medium / slow label would be misleading. Provisioning latency depends on image size, bootstrap work, available regional capacity, networking, cluster headroom, and whether compute must first be created underneath the Agent.
This distinction will become important again later in the series:
Queue Time includes waiting for suitable execution capacity. Build Duration starts only after the workload actually begins executing.
This table is not a universal ranking.
The right option depends on workload requirements and organizational context. A GPU-heavy build platform may strongly favor EC2. A company already operating a mature EKS platform may reasonably choose Kubernetes. A team that wants containerized ephemeral builds without introducing a Kubernetes platform may prefer ECS Fargate.
3.5. Static vs Elastic Is Not the Same as EC2 vs Containers
One distinction is easy to miss.
Static vs elastic describes the Agent lifecycle. EC2 vs Fargate vs EKS describes the compute platform.
EC2 can be static or elastic. Kubernetes Agents can also be kept around unnecessarily. Containerization does not automatically make an architecture demand-driven.
The design goal is therefore not simply:
Move Jenkins from EC2 to containers.
The design goal is:
Make execution capacity disposable, reproducible, workload-specific, and provisioned from demand.
That mental model will be important when we design the Agent lifecycle in Part 6.
4. Our Decision: ECS Fargate for the Target Platform
For the platform built in this series, we will use:
Jenkins Controller on Amazon ECS Fargate + Amazon EFS for JENKINS_HOME + ephemeral Jenkins Agents on ECS Fargate.
This choice gives us the balance we want.
We can version Controller and Agent environments as container images. Agent capacity does not need to exist while the Queue is empty. Different workloads can receive different task sizes, images, labels, and IAM roles. We avoid managing a fleet of EC2 build workers, while also avoiding the additional Kubernetes platform layer that EKS would introduce for this particular use case.
The decision is specific to the goals of this series. It is not a claim that Fargate is universally the best Jenkins platform.
⚖️ If your builds require privileged containers, specialized hardware, deep host customization, or an existing Kubernetes platform is already the organizational standard, EC2 or EKS may be the better architecture.
The Jenkins Amazon ECS plugin can provision build Agents as ECS tasks on preconfigured AWS infrastructure. We will validate the exact plugin configuration, network path, IAM permissions, and Agent lifecycle when we implement ephemeral Agents later in the series.
5. The Target Architecture
The architecture we are moving toward is:
The Controller service remains long-running because Jenkins is stateful and must coordinate the platform continuously. The individual Fargate task is still replaceable; durable Jenkins state lives outside that task.
The Agents are different. They are execution capacity. They can be created for a build, execute the workload, preserve the required output, and disappear.
This gives us two deliberately different lifecycles:
That distinction is the foundation of the next two articles.
6. Fargate Does Not Make Jenkins Stateless
This point deserves its own section because the phrase “serverless Jenkins” can easily create the wrong mental model.
Fargate means we do not manage the servers underneath the ECS tasks. It does not mean that Jenkins suddenly becomes stateless.
The Controller still owns important state associated with jobs, configuration, plugins, credentials, build history, and Pipeline execution. That state needs a durable storage strategy.
For our target architecture, JENKINS_HOME will be stored on Amazon EFS so that replacing the Controller task does not automatically destroy Jenkins state.
But persistent shared storage does not turn multiple Jenkins Controllers into a safe active-active cluster.
The principle from Part 1 still applies:
Persistence solves durability. It does not automatically solve coordination or High Availability.
Later in the series, recovery, failover, backup, restore, and upgrade will be treated as separate production-engineering problems.
7. What Part 4 Intentionally Leaves for Later
Part 4 is an architecture decision point in the series. Its purpose is to explain why elastic Jenkins Agents are useful, compare the main AWS execution models, and choose a direction for the next stage of the series.
We do not need to solve every production concern in order to make that decision.
Topics such as detailed networking, storage design, IAM boundaries, Agent image management, observability, cost optimization, backup, recovery, upgrades, and failure handling will appear later when they become relevant to the component being built or operated.
That is intentional rather than incomplete. Each part in this series focuses on one layer of the Jenkins platform, then carries the important constraints forward into the next layer.
At this point, the decision we need is much simpler:
Do we want Jenkins build capacity to remain permanently provisioned, or should it appear when demand exists and disappear when the work is finished?
For the platform we are building, we have chosen the second model. The following articles will turn that architectural direction into an implementation, one concern at a time.
Key Takeaways
1. Static Agents solved workload placement, not capacity lifecycle.
Our EC2 Agent isolated builds from the Controller, but it still consumed capacity and required maintenance even when Jenkins had nothing to execute.
2. Elasticity means provisioning execution capacity from demand.
The Jenkins Queue should be able to trigger Agent creation rather than depending on workers that already exist.
3. Dynamic EC2 remains a valid architecture.
It provides the most host-level flexibility, especially for specialized builds, but VM lifecycle and OS management remain part of the platform.
4. EKS is powerful when Kubernetes already has organizational value.
It provides a rich ephemeral-Agent model, but introducing Kubernetes only for Jenkins would add platform complexity we do not need in this series.
5. ECS Fargate gives this series the desired middle ground.
It provides containerized, disposable Agent compute without requiring us to manage worker servers or a Kubernetes platform.
6. Serverless compute does not make Jenkins stateless.
The Controller remains a stateful application, and JENKINS_HOME, recovery, backup, and failover must still be designed explicitly.
Next: Part 5 — Building Jenkins Controller on ECS Fargate
We have selected the target architecture. Now we need to build its stateful half correctly.
In Part 5, we will move the Jenkins Controller from EC2 to Amazon ECS Fargate. We will design the network path, expose Jenkins through a controlled HTTPS endpoint, persist JENKINS_HOME on Amazon EFS, package Jenkins as a versioned container image, and separate ECS execution permissions from Jenkins application permissions.
Only after the Controller is stable on the new platform will we make the build layer elastic.
Part 5: Building Jenkins Controller on ECS Fargate
References and Version Notes
- Jenkins — Using Jenkins Agents
- Jenkins — Architecting for Scale
- Jenkins — Amazon EC2 Plugin
- Jenkins — Amazon ECS / Fargate Plugin
- AWS — Amazon EC2 Auto Scaling
- AWS — Architect for AWS Fargate for Amazon ECS
- AWS — Amazon ECS Task Definitions
- AWS — What Is Amazon EKS?
AWS and Jenkins capabilities evolve over time. Before implementing the later hands-on sections, verify current plugin compatibility, Jenkins requirements, Fargate platform constraints, and EKS features against the latest vendor documentation.







Top comments (0)