← All articles
AWSECS FargateAI AgentsServerless

Fargate vs. EKS vs. Lambda for AI Agents in 2026

Where should your AI agent workload actually run on AWS? A decision-oriented comparison of Fargate, EKS, Lambda and Bedrock AgentCore for agentic workloads.

For most teams shipping their first production AI agent, ECS Fargate is the right answer — it has no execution time limit, keeps containers warm, and doesn't require you to run Kubernetes. Use Lambda when every invocation reliably finishes inside 15 minutes, EKS when you already run Kubernetes or need GPU scheduling, and Bedrock AgentCore when you'd rather not own the runtime at all.

The rest of this post is why, and how to tell which case you're actually in.

Why agents don't fit normal compute assumptions

AI agents have an awkward runtime profile that breaks the usual heuristics:

  • Bursty. Idle for minutes, then a flood of concurrent sessions.
  • Long and unpredictable. A single request might take 800ms or nine minutes, depending on how many tool calls the model decides to make.
  • I/O-bound, not CPU-bound. Most wall-clock time is spent waiting on a model endpoint or an external API. The CPU is idle while you're billed for it.
  • Memory-heavy at import. Frameworks, SDKs and tokenizers make for large images and slow cold starts.

That combination is why "just put it on Lambda" works right up until it doesn't.

The short answer

Workload shapeBest fit
Short, event-driven invocations (reliably < 15 min)Lambda
Long-running or always-warm agents, container-basedECS Fargate
Large fleets, GPU scheduling, existing KubernetesEKS
Managed agent runtime, no infrastructure ownershipBedrock AgentCore

Lambda — cheapest to start, hard ceiling

Lambda is genuinely the best option when it fits: pay per invocation, scale to zero, nothing to operate. An agent triggered by an API call or an SQS message that finishes in seconds is a good Lambda.

Where it breaks for agents:

⚠️

The 15-minute hard timeout is not configurable. An agent that chains tool calls, streams a long response, or waits on a slow external API will eventually exceed it — and it fails mid-conversation, not at deploy time.

  • Cold starts. A container image with an agent framework, an AWS SDK and a tokenizer can take seconds to initialise. For a chat interface that's the difference between usable and not. Provisioned concurrency fixes it, and in doing so removes the scale-to-zero economics that made Lambda attractive.
  • You pay for waiting. Lambda bills GB-seconds of wall clock. An agent blocked on a model response for 30 seconds is billed for 30 seconds of idle memory.
  • No persistent connections. Each invocation reconnects to your database or vector store.

Lambda is right for agents that are functions — classify this ticket, extract these fields, summarise this document. It's the wrong shape for agents that are sessions.

ECS Fargate — the pragmatic middle

Fargate runs your container without you managing nodes or patching hosts. For agent workloads it lands in a useful place:

  • No execution limit. A task runs as long as it runs.
  • Stays warm. No cold start per request, so connections and caches persist.
  • Right-sized. Per-second billing on the CPU and memory you request.
  • Clean IAM. A task role scopes exactly what the agent can call, which matters a great deal when the agent decides its own tool calls.
  • Standard container image. The same image runs locally and in CI.

The cost is that you own the VPC. Subnets, route tables, VPC endpoints, security groups — all yours. That ownership is exactly why Fargate tasks end up stuck in PENDING when the wiring is wrong, and it's the single biggest source of friction for teams arriving from Lambda.

It's worth paying that cost once. The networking model is the same one that underpins nearly everything else you'll run on AWS.

EKS — power you pay for in complexity

EKS earns its place under specific conditions:

  • You already run Kubernetes and have the operational practice for it.
  • You need GPU node pools for self-hosted inference.
  • You're running a large multi-tenant fleet where bin-packing many small agents onto shared nodes is a real cost saving.
  • You need scheduling features — affinity rules, custom autoscalers, service meshes — that ECS doesn't express.

For a single agent service, EKS is overkill. You take on a control plane, node group lifecycle, add-on upgrades and cluster autoscaling to solve a problem Fargate solves with a task definition. The complexity is only worth it when something above genuinely applies.

Note that EKS also has a Fargate mode, which removes node management while keeping the Kubernetes API. It's a reasonable landing spot if the Kubernetes API is what you need and node operations are what you don't.

Bedrock AgentCore — don't own the runtime at all

If you'd rather not manage compute, AgentCore Runtime runs agent code in a managed sandbox with execution windows far longer than Lambda's, and it brings session isolation, memory and tool routing with it.

The trade-off is control. You get less say over the runtime environment, networking and observability than a container gives you, and you're committing to an AWS-managed agent platform rather than a portable image.

It's a strong default for teams whose differentiator is the agent's behaviour rather than its infrastructure.

How cost actually behaves

Exact prices change and vary by region — check the AWS pricing pages for current figures. The shape of the cost is what's stable, and it's what decides this:

  • Lambda bills per request and per GB-second of wall clock. Cheapest at low, spiky volume. Gets expensive when invocations are long and idle, because waiting on a model is billed the same as computing.
  • Fargate bills per vCPU-hour and GB-hour while the task runs. Cheapest when utilisation is steady. A task idling overnight bills all night, so scale to zero off-hours if traffic allows.
  • EKS adds a flat hourly control-plane charge per cluster on top of the compute. That fixed cost is trivial across a large fleet and dominant for a single small service.

The crossover to watch: an agent that idles while waiting on model responses is billed for that wait on every option. Fargate handles it best because one task serves many concurrent sessions, whereas Lambda bills each waiting invocation separately.

How to decide

Four questions, in order. Stop at the first clear answer.

  1. Does every invocation reliably finish in under 15 minutes? If no — Lambda is out. If yes and traffic is spiky, Lambda is likely cheapest.
  2. Do I want to own infrastructure at all? If no — Bedrock AgentCore.
  3. Do I already run Kubernetes, need GPU scheduling, or run a large fleet? If yes — EKS.
  4. Otherwise — Fargate.

Two follow-ups worth answering honestly, because they're what people get wrong:

  • Is my p99 the same shape as my p50? Agents have long tails by nature. If p50 is 4 seconds and p99 is 12 minutes, you have a Fargate workload with a Lambda-shaped average.
  • How much does a cold start cost me? For a background job, nothing. For a chat interface, it's the whole experience.

The boring, correct answer

For most teams shipping their first production agent, Fargate is right — not because it's exciting, but because it removes the timeout question entirely, keeps the container warm, and teaches you the VPC model you'll need regardless of where you end up.

The ECS Fargate workshop builds that end to end in one sitting: VPC, endpoints, task roles and a running service. If you're leaning toward the managed route instead, the AgentCore walkthrough covers what that looks like. More on both under AI Agents.

Keep reading