AWS Lambda vs ECS Fargate: The Exact RPS Inflection Point Where Serverless Becomes 4x More Expensive Than Containers

A production API can be almost idle all night and busy enough at lunch to exhaust its connection pool. The decision is not simply serverless versus containers: it is whether to pay for each execution or keep enough capacity running to absorb the next burst. A monthly average alone conceals that operating pattern.

This is a compute-cost comparison, not a benchmark or a complete invoice. Throughput and task counts are illustrative assumptions, not measured service results; test your own workload before committing to an architecture.

TCO Crossover Curve — fixed four-task illustration~59 RPS: parity~235 RPS: 4×Fargate: ~$288 / monthLambdaSustained requests per secondMonthly compute cost0400
Illustrative compute-only model; the four-task fleet is held constant, not a load-test result.

Quick Decision Matrix

Traffic patternLambdaECS on Fargate
2 RPS sustainedAbout $9.81; pay per invocationAbout $36 for one 1 vCPU / 2 GB task
50 RPS sustainedAbout $245About $72 for two small tasks or $144 for two large tasks
500 RPS sustainedAbout $2,453About $288 for four 2 vCPU / 4 GB tasks, if load tests support them

The table compares chosen resource shapes, not guaranteed throughput. Four large tasks in the final row are not the same size as the small tasks in the first two rows. A real service may need more tasks, a different memory allocation or a different scaling policy.

The math behind the crossover

A constant one request per second produces 2,628,000 requests in a 730-hour month. At $0.20 per million requests and $0.0000166667 per GB-second, each request consumes 0.1 GB-second, giving an estimated $4.9056 per monthly average RPS before free allowances. The model assumes every request is billed as a separate invocation and 200 ms represents billed duration.

Fargate bills requested CPU and memory while a task runs, including its image download interval. AWS lists a us-east-1 Linux x86 example at $0.000011244 per vCPU-second and $0.000001235 per GB-second. At those rates, a continuously running 1 vCPU / 2 GB task costs roughly $36.04 a month, and a 2 vCPU / 4 GB task costs roughly $72.08.

Those configurations are illustrative, not minimum Fargate sizes: AWS also supports smaller CPU and memory combinations. A service requiring two availability zones or spare deployment capacity may have a higher floor, while scheduled tasks or smaller allocations can lower it. Calculate using the task-hours you actually expect to purchase.

For a fixed fleet of four large tasks, the compute-only crossover is approximately 58.8 RPS: $288.33 divided by $4.9056 per RPS. Lambda reaches four times that fixed fleet cost at about 235.1 RPS, assuming the fleet remains unchanged and handles the load. This is a mathematical threshold for one configuration, not an exact universal inflection point.

The arithmetic is sensitive to execution duration. A function that finishes in 100 ms rather than 200 ms uses half the modeled GB-seconds, though its request charge remains unchanged. Conversely, a slower dependency, a retry storm or a larger memory setting can increase charges even if incoming customer traffic is flat.

Scenario A: a quiet API at 2 RPS

A small SaaS admin API receives about 5.256 million requests in a month at this steady rate. Its Lambda compute consumes approximately 525,600 GB-seconds, or $8.76, and requests add about $1.05. The combined compute and request estimate is $9.81 before free allowances.

One small continuously running Fargate task is about $36.04 using the chosen 1 vCPU / 2 GB shape. On these assumptions Lambda is roughly $26 cheaper per month, without considering other services. The result is even more favorable if eligible free-tier capacity is available and has not been used elsewhere in the account.

A single task is not automatically a sensible production baseline. An outage, deployment or availability-zone failure can take that task away, and a team may choose two or more tasks for resilience. Conversely, a noncritical internal tool can often tolerate interruptions and use a smaller task or a schedule; compare actual availability requirements.

This is where Lambda’s operating model matters as much as its invoice. An infrequent endpoint avoids buying idle application capacity, but a cold invocation can add startup latency and a function still needs dependency management, logs, security controls and a deployment pipeline. Keeping the compute layer small does not eliminate the work around it.

Scenario B: the 50 RPS decision

At 50 RPS the model produces 131.4 million invocations and 13.14 million GB-seconds per month. Requests contribute approximately $26.28 and duration contributes $219.00, for a combined Lambda estimate of $245.28. This assumes the average billed runtime stays at 200 ms at the stated memory allocation, including variations and retries.

Two continuously running small Fargate tasks cost approximately $72.08, and two large tasks cost approximately $144.16. Under either selected fleet the raw compute line is lower than Lambda at this sustained rate. The range comes from changing task sizes, not uncertainty in arithmetic; other costs and capacity requirements can narrow or reverse the advantage.

It would be misleading to infer that every team crosses over precisely at 50 RPS. A two-small-task fleet matches Lambda at approximately 14.7 RPS, while a two-large-task fleet matches it at approximately 29.4 RPS, if each fleet stays constant and can serve its assigned traffic. When task counts rise with demand, the container line is a staircase rather than a flat line.

Before using a fleet estimate, run a representative concurrency and throughput test with production-like payloads and upstream services. A task can be CPU-bound, memory-bound or waiting on a database long before its theoretical request limit. Record p95 and p99 latency, error rate, throttling, CPU utilization and memory headroom rather than extrapolating from one best-case request.

Also include the operational reserve required during deployments. A rolling replacement may temporarily run more tasks than the steady-state target, and autoscaling reacts after metrics move rather than predicting every surge. Estimate actual task-hours over a month and add shared ingress and observability components to both options where applicable.

Scenario C: sustained 500 RPS

The same formula yields 1.314 billion invocations and 131.4 million GB-seconds in the month. Lambda request charges are about $262.80 and execution charges about $2,190.00, totaling $2,452.80 before allowances. A four-task fleet with 2 vCPU and 4 GB per task costs approximately $288.33, so the illustrated Lambda compute line is about 8.5 times as high.

The qualification is essential: four large tasks must actually serve the workload and meet latency and availability targets. If load testing requires eight such tasks, the compute baseline doubles to about $576.67; if larger or smaller tasks are appropriate, it changes again. The 500 RPS input is a scenario assumption, not evidence that a particular image can sustain that rate.

A persistent service may make more efficient use of warm processes, shared connection pools and caches, especially when the workload has predictable volume. But pooling does not create unlimited database capacity, and caches introduce consistency decisions. The savings calculation belongs beside a capacity plan, not in place of one.

A mixed design is often more practical than a wholesale migration. Keep sporadic jobs, event handlers or infrequent customer-specific workflows on Lambda, and move a consistently busy HTTP path to a container service only after profiling. The boundary can be chosen per endpoint or queue consumer rather than for the entire product.

Hidden costs that can change the answer

NAT gateways and data transfer

A NAT gateway can add both an hourly charge and a data-processing charge. A common us-east-1 baseline is $0.045 per gateway-hour plus $0.045 per GB processed: one gateway running all month costs about $32.85 before data processing, while 1,000 GB adds about $45. Charges and architecture vary by region, availability zone and traffic path.

Neither Lambda nor Fargate universally requires a NAT gateway. The need depends on subnet placement and destinations; VPC endpoints, private routing, public networking and existing shared gateways each have different security and cost consequences. Also examine inter-zone transfer, public IPv4, internet egress and whether the cost should be allocated across several services.

Cold starts and latency

Lambda execution environments can be created or recycled as concurrency changes, so some requests pay initialization latency. Language runtime, package size, initialization work and VPC configuration affect the observed result. Measure the distribution under representative burst patterns rather than quoting a fixed cold-start penalty.

Provisioned concurrency can reduce initialization exposure for selected traffic, but it introduces a separate capacity charge and changes the cost model. Fargate containers also have startup and scaling delays, and a newly launched task may not pass health checks immediately. Reserve capacity is a performance choice with a price on either platform.

Other shared and platform costs

API Gateway, load balancers, CloudWatch logs, tracing, container registry storage, database connections, support and engineering time may matter more than a small compute difference. Some components can exist on both architectures, but they are not necessarily identical or avoidable. Compare incremental costs for the actual design and avoid assigning a shared gateway’s whole bill to one service without a reason.

Discounts and free allowances deserve their own line item. The Lambda free tier includes one million requests and 400,000 GB-seconds per month, shared across eligible usage, while Savings Plans and Fargate Spot can change other effective rates. Do not apply a free tier twice across workloads or treat interruptible Spot capacity as equivalent to uninterrupted on-demand capacity.

A practical migration checklist

First, export request counts by short interval, not just a monthly total, and calculate the mean plus peak concurrency. Second, measure billed duration and memory distribution for the Lambda path, including failures and retries. Third, identify which ingress, database, network and telemetry components are shared and which change with the design.

Build a container and run repeatable load tests with the same payloads and downstream dependencies. Choose a task size, minimum count, maximum count, scaling threshold and deployment buffer that meet the service-level objective. Turn those observations into task-hours, add noncompute charges, and compare the resulting monthly range with the Lambda bill.

Finally, run a small canary and verify the result against actual billing and latency after deployment. Compare measured usage against the forecast, retain a rollback path, and revisit the model after a meaningful change in traffic mix or application duration. A fast code optimization can move the Lambda crossover just as surely as a pricing change.

Model the shape of demand, not just the average

Two services can average 50 RPS and produce very different capacity bills. One may receive a steady stream throughout the month, while the other sees traffic only during a short business window and remains idle overnight. Lambda follows the number and duration of invocations; a container fleet charges for its provisioned CPU and memory during the time it remains running.

For the second service, use hourly or finer traffic samples and estimate the minimum fleet needed for each interval. Multiply the task count in each interval by its duration, then add deployment overlap and a suitable safety margin. If the service must remain available at night, do not assume its minimum count can be zero just because requests fall to zero.

The same method helps when workloads have seasonal spikes. Examine the database and network limits during the peak, not merely the container CPU graph. If the required headroom differs substantially between ordinary hours and peak hours, an autoscaling fleet, scheduled scaling or a hybrid design may be worth comparing with the flat-rate examples above.

When reporting results to finance, separate observed inputs from assumptions. Request counts and historical billed duration can come from production telemetry; a proposed four-task fleet is a hypothesis until a representative test establishes capacity and resilience. Present the cost as a range with its chosen availability policy, and include the engineering effort required to migrate and operate it.

FAQ

Is Lambda always cheaper at low traffic?

No. Low utilization often favors per-invocation billing, but free allowances, a smaller scheduled container, shared infrastructure and required integrations can change the result. Calculate the whole incremental bill for the actual traffic pattern.

At exactly what RPS is Lambda four times more expensive?

In the fixed four-large-task example, the model reaches that ratio at approximately 235.1 sustained average RPS before free allowances and other costs. It is not a universal threshold because required task capacity, runtime, memory, pricing and traffic distribution vary.

Does 500 RPS require only four Fargate tasks?

Not necessarily. Four 2 vCPU / 4 GB tasks are an illustrative cost assumption, not a capacity guarantee. Test the application, downstream systems, deployment strategy and failure scenarios to determine the fleet you need.

Should I subtract the Lambda free tier?

Yes, if the account is eligible and the allowance remains available after other functions use it. Apply the account-level free request and GB-second allowances once to the combined eligible usage, not separately to each function.

Does a VPC always mean NAT gateway charges?

No. NAT requirements depend on where workloads run and which destinations they must reach; private endpoints, public networking or an existing shared gateway may be alternatives. Evaluate security and data-transfer charges for the actual route.

Bottom line: these figures are planning estimates, not a quote or a performance guarantee. Check current AWS prices and validate capacity, availability and total operating costs for your own workload before deciding.

Sources: AWS Lambda pricing; AWS Fargate pricing; Amazon VPC pricing.

Comments

Popular posts from this blog

Zapier vs n8n: How Workflow Execution Differences Cut Automation Costs by Over 80%

ChatGPT Plus vs Claude Pro vs Cursor: When Does Direct API Routing Actually Beat $20 Subscriptions for Engineering Teams?