← Back to Blog
AWS LambdaComparison

AWS Lambda vs Bare Metal: When Serverless Costs More

AWS Lambda changed how developers think about infrastructure. No servers to manage, pay only for what you use, scale to zero. It is a great model — until the bill arrives. At scale, Lambda’s per-invocation pricing turns from cost-effective to cost-prohibitive. Here is when bare metal becomes the smarter choice.

How Lambda Pricing Actually Works

Lambda charges across three dimensions simultaneously, and most developers underestimate the total:

The Three Cost Dimensions

  • Invocations: $0.20 per 1 million requests
  • Duration: $0.0000166667 per GB-second (charged per millisecond)
  • Memory allocation: You pay for the memory you allocate, not what you use. Allocate 1 GB but use 200 MB? You pay for 1 GB.

AWS offers a free tier of 1 million requests and 400,000 GB-seconds per month. Beyond that, every millisecond counts.

Real Cost Example: An API Backend

Consider a typical API backend handling 5 million requests per month. Each request averages 200 ms with 512 MB memory allocated.

  • Invocations: 5M requests × $0.20/1M = $1.00
  • Duration: 5M × 0.2s × 0.5 GB = 500,000 GB-s × $0.0000166667 = $8.33
  • API Gateway: 5M requests × $3.50/1M = $17.50
  • CloudWatch Logs: ~$5–$10/mo
  • Total: ~$32–$37/mo

That same workload runs comfortably on a 2 vCPU / 4 GB bare metal server for $6/mo.

The Hidden Costs Most People Miss

1. Cold Starts Kill User Experience

When Lambda spins up a new execution environment, there is a delay before your code runs. Cold starts range from 100 ms to over 3 seconds depending on runtime and package size:

  • Node.js: 100–500 ms cold start
  • Python: 200–800 ms cold start
  • Java: 1–3+ seconds cold start
  • .NET: 500 ms–2 seconds cold start

Provisioned Concurrency eliminates cold starts but costs $0.0000041667 per GB-second — even when your function is not running. For a 512 MB function with 10 provisioned instances running 24/7, that is an extra $55/mo just to keep functions warm.

2. API Gateway Doubles the Bill

Lambda functions behind API Gateway incur a separate charge of $3.50 per million requests. For many workloads, the API Gateway cost exceeds the Lambda cost itself. This is the line item that shocks teams when they first audit their serverless bill.

3. Vendor Lock-In Is Real

Lambda functions depend on AWS-specific triggers (SQS, DynamoDB Streams, S3 events), IAM roles, Lambda Layers, and environment configurations. Moving to another provider means rewriting, not redeploying. Your “serverless” architecture is actually an AWS-specific architecture.

4. Debugging Is Painful

Local development with SAM or Serverless Framework approximates the Lambda environment but never fully replicates it. Debugging production issues means searching CloudWatch Logs at $0.50 per GB ingested. X-Ray tracing adds another cost layer. A bare metal server gives you SSH, standard logging, and familiar debugging tools.

The Crossover Point: When Bare Metal Wins

Lambda is cost-effective for bursty, low-volume workloads that can tolerate cold starts. Once your Lambda spend exceeds $50/mo, bare metal almost certainly saves money.

Monthly WorkloadLambda CostRAW Cost
500K requests~$8/mo$6/mo
2M requests~$22/mo$6/mo
5M requests~$37/mo$6/mo
20M requests~$140/mo$11/mo
100M requests~$650/mo$21/mo

Lambda estimates include invocations, duration (200 ms avg, 512 MB), and API Gateway. RAW costs are flat monthly pricing for dedicated bare metal.

What You Gain by Moving to Bare Metal

  • Zero cold starts: Your server is always running. Every request gets a fast response.
  • Predictable billing: $6/mo, $11/mo, or $21/mo. No per-request math.
  • No vendor lock-in: Standard Linux server. Run any framework, any language.
  • Better debugging: SSH in, tail logs, use your familiar tools.
  • Run everything together: API, database, cache, background workers — one server, one bill.
  • No API Gateway tax: Nginx handles routing for free.

What You Lose

  • Auto-scaling to zero: Your server runs 24/7 whether it has traffic or not
  • Event-driven triggers: No native S3, SQS, or DynamoDB integrations
  • Managed infrastructure: You handle updates, security, and monitoring
  • Multi-region failover: You need to set up replication yourself

When to Stay on Lambda

  • Your workload is genuinely bursty with long idle periods
  • You process fewer than 1 million requests per month
  • You rely heavily on AWS event-driven integrations
  • Your Lambda bill is under $20/mo and you value zero ops

When to Switch to Bare Metal

  • Your Lambda bill exceeds $50/mo
  • Cold starts are hurting your user experience or API latency
  • You want to run a database alongside your application
  • You are tired of vendor lock-in and AWS-specific patterns
  • You want SSH access and standard debugging tools

How to Migrate from Lambda to Bare Metal

Step 1: Deploy a RAW Server

npx rawhq deploy

Choose your plan. Server is ready in 13 seconds.

Step 2: Convert Your Lambda Functions

# Lambda handler becomes an Express/Fastify route
# Before (Lambda):
# exports.handler = async (event) => { ... }

# After (Express on bare metal):
# app.get('/api/endpoint', async (req, res) => { ... })

# Install your framework
npm init -y
npm install express

Step 3: Set Up Nginx and PM2

# Install Nginx and PM2
apt install nginx -y
npm install -g pm2

# Start your app
pm2 start app.js --name my-api
pm2 save
pm2 startup

Step 4: Point DNS and Decommission

Update your domain to point to the RAW server. Disable API Gateway and Lambda functions once traffic has migrated.

The Bottom Line

Lambda is a brilliant abstraction for small, bursty workloads. But abstractions have a price, and Lambda’s price scales linearly with your traffic. A $6/mo bare metal server handles millions of requests without per-invocation charges, cold starts, or API Gateway fees.

If your Lambda bill has a comma in it, you are almost certainly overpaying for the convenience of not managing a server. And with modern tooling, that server takes 13 seconds to deploy.

Try RAW Free

npx rawhq deploy

7-day free trial. 13 seconds to deploy. No credit card.