Back to HomeAWS Lambda

AWS Lambda Pricing Complete Guide: Free Tier, Billing Model & Cost-Saving Tips [2025]

11 min min read
#AWS Lambda#Lambda Pricing#Free Tier#Cloud Cost Optimization#Serverless#Memory Size#Provisioned Concurrency#AWS Billing#Cost Analysis#Cloud Budget

AWS Lambda Pricing Complete Guide: Free Tier, Billing Model & Cost-Saving Tips [2025]

Introduction: Does Lambda Really Save Money?

"Using Lambda can save you a lot of money!"

You've definitely heard this before. But in reality, Lambda pricing is more complex than you might think.

Some teams using Lambda actually save 80% on costs. Others use it wrong and end up with bills higher than EC2.

What's the difference? Whether you truly understand Lambda's billing logic.

This article will fully analyze Lambda's cost structure, from Free Tier to advanced optimization, helping you find the most cost-effective configuration.

If you're not familiar with Lambda basics, we recommend reading AWS Lambda Complete Guide first.

Illustration 1: Lambda Cost Calculation Concept

AWS Lambda Billing Model

Lambda billing is very straightforward: pay for what you use.

No minimum charges, no upfront payments, purely usage-based billing.

Request Count Billing

Every Lambda function invocation counts as one request.

Pricing: $0.20 USD per 1 million requests

This fee is independent of how long the function runs or how much memory it uses. It purely counts invocations.

Examples:

  • 500,000 requests/month: $0.10
  • 5 million requests/month: $1.00
  • 50 million requests/month: $10.00

Request count fees usually make up a small portion of total costs. The real expense is execution time.

Execution Time Billing (GB-seconds)

This is the main source of Lambda costs.

Billing formula:

Cost = Allocated Memory (GB) × Execution Time (seconds) × Price per GB-second

Price per GB-second: $0.0000166667 USD (x86 architecture)

Converting to more intuitive numbers:

Memory AllocationCost per SecondCost per Minute
128 MB$0.0000021$0.000125
256 MB$0.0000042$0.000250
512 MB$0.0000083$0.000500
1024 MB$0.0000167$0.001000
2048 MB$0.0000333$0.002000

Calculation Example:

An API function with 512MB memory, averaging 200ms execution, processing 1 million requests per month:

  • Request cost: 1 million × $0.0000002 = $0.20
  • Execution time: 1 million × 0.2 seconds × 0.5 GB × $0.0000166667 = $1.67
  • Monthly total: $1.87

This is what makes Lambda attractive. Processing 1 million requests costs less than $2.

Other Costs (Easily Overlooked)

Lambda's own cost is just part of the equation. There are several hidden costs to note:

Provisioned Concurrency

If you use Provisioned Concurrency to solve Cold Start issues, there's additional cost:

  • Provisioned cost: $0.000004463 per GB-hour
  • Example: Provisioning 10 instances at 1GB each costs about $32/month

Data Transfer

  • Lambda to Internet: $0.09 per GB (first 10TB)
  • Lambda to other AWS Regions: $0.02 per GB
  • Within same Region: Free

API Gateway Costs

If used with API Gateway:

  • REST API: $3.50 per million requests
  • HTTP API: $1.00 per million requests

For detailed API Gateway integration information, see Lambda + API Gateway Integration Tutorial.

NAT Gateway Costs

If Lambda in VPC needs internet access:

  • NAT Gateway processing: $0.045 per GB
  • NAT Gateway hourly: $0.045 per hour

This is a common trap. A high-traffic Lambda + VPC + NAT Gateway setup can have NAT costs higher than Lambda itself.

If you want to use Lambda for event-driven tasks, check out Lambda + EventBridge Event-Driven Architecture.


Free Tier Explained

Lambda's Free Tier is permanently valid, not just a 12-month trial.

This is one of the most generous free offerings among all AWS services.

Permanent Free Allowance Overview

ItemMonthly Free Allowance
Request Count1,000,000 requests
Execution Time400,000 GB-seconds

400,000 GB-seconds converted to actual usage:

Memory AllocationFree Execution Time
128 MB3,200,000 seconds (~889 hours)
256 MB1,600,000 seconds (~444 hours)
512 MB800,000 seconds (~222 hours)
1024 MB400,000 seconds (~111 hours)

Free Tier Usage Calculation Examples

Case 1: Small API Service

  • 5,000 requests per day
  • 100ms execution each
  • 256MB memory configured

Monthly usage calculation:

  • Requests: 5,000 × 30 = 150,000 (within free tier)
  • GB-seconds: 150,000 × 0.1 × 0.25 = 3,750 GB-seconds (within free tier)

Result: Completely free

Case 2: Medium Data Processing

  • 50,000 processes per day
  • 500ms execution each
  • 512MB memory configured

Monthly usage calculation:

  • Requests: 50,000 × 30 = 1,500,000 (500,000 over limit)
  • GB-seconds: 1,500,000 × 0.5 × 0.5 = 375,000 GB-seconds (within free tier)

Costs:

  • Excess request fee: 500,000 × $0.0000002 = $0.10
  • Execution time: $0

Result: $0.10/month

What If You Exceed Free Tier?

No warning when you exceed, billing starts directly.

Recommended to set budget alerts:

  1. Go to AWS Budgets
  2. Create budget, set Lambda service
  3. Set alert thresholds (e.g., $5, $10, $20)
  4. Check usage when you receive alerts

Not sure if your usage will exceed Free Tier? Book Free Bill Review - let us help calculate.


Memory Size and Cost Relationship

Memory Size choice directly affects costs.

But it's not as simple as "smaller is cheaper."

Price Comparison Table

Lambda Memory Size ranges from 128MB to 10,240MB (10GB):

Memory SizePrice per MillisecondRelative to 128MB
128 MB$0.00000000211x
256 MB$0.00000000422x
512 MB$0.00000000834x
1024 MB$0.00000001678x
2048 MB$0.000000033316x
3008 MB$0.000000049324x

Looks like more memory costs more. But wait, there's a key factor.

More Memory = Faster Completion = Possibly Cheaper?

Lambda CPU performance is proportional to memory.

  • 128MB: Minimum CPU allocation
  • 1769MB: Equals 1 full vCPU
  • 10240MB: Equals 6 vCPUs

This means: More memory → Faster execution → Shorter billing time → Possibly cheaper

Real Case:

A data processing function:

ConfigurationExecution TimeCost per Invocation
128 MB3000 ms$0.0000063
256 MB1500 ms$0.0000063
512 MB800 ms$0.0000067
1024 MB400 ms$0.0000067
1536 MB280 ms$0.0000070

In this case, 128MB and 256MB cost the same, but 256MB runs twice as fast.

Faster execution also means better user experience.

When choosing Memory Size, also consider error handling - insufficient memory causes OOM errors. See Lambda Error Handling Complete Guide for details.

Power Tuning Tool to Find Optimal Point

Manual testing is time-consuming. We recommend AWS Lambda Power Tuning.

This is an AWS officially recommended open-source tool that can:

  • Automatically test multiple Memory Size configurations
  • Generate cost vs performance visualization reports
  • Find the optimal cost-efficiency point

How to use:

  1. Deploy via AWS Serverless Application Repository
  2. Execute Step Functions workflow
  3. Input your Lambda ARN and test parameters
  4. Get optimal configuration recommendations

Illustration 2: Lambda Power Tuning Result Analysis Chart

Cost-Saving Tips

After understanding the billing model, let's look at how to actually reduce costs.

Code Optimization

Reduce Cold Start Impact

Cold Start increases execution time, which increases costs.

Optimization methods:

  • Reduce package size (only import needed modules)
  • Use Lambda Layers to separate dependencies
  • Choose languages with faster Cold Start (Python, Node.js beat Java)

Minimize Execution Time

  • Avoid synchronous waiting (use async processing)
  • Cache frequently used data (use /tmp or external cache)
  • Optimize database queries (add indexes, reduce returned columns)

Example: Connection Reuse

# Wrong: Create new connection every execution
def lambda_handler(event, context):
    conn = create_db_connection()  # Takes time every time
    result = conn.query(...)
    return result

# Correct: Create connection outside Handler, reuse
conn = create_db_connection()  # Only during Cold Start

def lambda_handler(event, context):
    result = conn.query(...)  # Reuse existing connection
    return result

Architecture Optimization

Batch Processing vs Single Processing

Processing 1000 records:

  • Single processing: Invoke Lambda 1000 times, higher request fees
  • Batch processing: Invoke Lambda once for 1000 records, lower request fees

Use SQS Batch Size setting to let Lambda process multiple messages at once.

Choose Appropriate Trigger Methods

  • High-frequency small tasks: Consider consolidating
  • Low-frequency large tasks: Can use Lambda directly
  • Very long tasks: Consider Step Functions or Fargate

Avoid Unnecessary VPC Connections

If you don't need access to VPC resources, don't configure VPC connection.

VPC connections will:

  • Increase Cold Start time
  • Require NAT Gateway for internet access (additional cost)

Monitoring and Alert Configuration

Set Up AWS Budgets

  1. Go to AWS Budgets
  2. Create cost budget
  3. Filter Lambda service
  4. Set monthly budget amount
  5. Set alert thresholds (50%, 80%, 100%)

Use Cost Explorer Analysis

Regularly check:

  • Which Lambda functions cost most
  • Any abnormal cost fluctuations
  • Changes compared to last month

Set CloudWatch Alerts

Monitor key metrics:

  • Invocations (call count)
  • Duration (execution time)
  • Errors (error count)
  • Throttles (throttle count)

Cloud bills giving you headaches? Many enterprises can actually save 30-50% on Lambda costs.

Free Bill Review - we'll help find hidden cost traps.


Lambda vs EC2 vs Fargate Cost Comparison

Lambda isn't a universal solution. In some cases, EC2 or Fargate is actually more cost-effective.

Cost Estimates for Different Scenarios

Scenario 1: Low Traffic API (10,000 requests/day)

OptionMonthly Cost Estimate
Lambda + API Gateway$1-5
EC2 t3.micro$8-10
Fargate (minimum config)$15-20

Lambda wins: In low-traffic scenarios, Lambda's pay-per-use advantage is clear.

Scenario 2: Medium Traffic API (1 million requests/day)

OptionMonthly Cost Estimate
Lambda + API Gateway$150-200
EC2 t3.medium$30-40
Fargate (2 tasks)$60-80

EC2 wins: With stable high traffic, EC2's fixed cost is more economical.

Scenario 3: Variable Traffic (10k weekday, 1M weekend)

OptionMonthly Cost Estimate
Lambda + API Gateway$50-80
EC2 (sized for peak)$100-150
EC2 + Auto Scaling$60-90

Lambda wins: With large traffic fluctuations, Lambda's auto-scaling advantage is clear.

When to Choose Lambda? When to Choose EC2?

Choose Lambda when:

  • Large traffic fluctuations (peaks 10x+ average)
  • Short execution times (most requests complete in 1 second)
  • No special system environment needed
  • Want zero operational overhead

Choose EC2 when:

  • Stable high traffic (24/7 continuous requests)
  • Need long-running tasks
  • Need specific system environment or GPU
  • Need finer system control

Choose Fargate when:

  • Need containerization without managing EC2
  • Need longer execution time than Lambda
  • Need larger memory or CPU allocation

If you need low-latency global deployment, consider Lambda@Edge Edge Computing to run code at CDN edge locations.

Illustration 3: Cloud Compute Solution Cost Comparison Chart

FAQ

Is Lambda Free Tier permanently free?

Yes. Lambda's Free Tier (1 million requests + 400,000 GB-seconds per month) is permanently valid and won't expire after 12 months. This is different from EC2 and other services' Free Tier.

How to calculate Lambda costs most accurately?

Use AWS Pricing Calculator or Cost Explorer. When calculating, consider: request count, execution time, Memory Size, and related service costs (API Gateway, NAT Gateway, etc.).

Does higher Memory Size mean higher costs?

Not necessarily. Increasing Memory Size increases CPU performance, which may shorten execution time and actually reduce total cost. We recommend using Lambda Power Tuning tool to find optimal configuration.

How to prevent Lambda bill explosion?

Set AWS Budgets alerts, limit concurrent execution (Reserved Concurrency), regularly check Cost Explorer, avoid infinite recursion calls.


Conclusion: Find Your Optimal Cost Configuration

Lambda cost optimization isn't a one-time task.

As business grows, traffic changes, and code is modified, the optimal configuration will also change.

Recommended Continuous Optimization Process:

  1. Monthly Review: Analyze cost trends with Cost Explorer
  2. Quarterly Tuning: Retest Memory Size with Power Tuning
  3. Architecture Evaluation: Re-evaluate Lambda vs EC2 when traffic patterns change

Remember: Lambda's advantage is flexibility and pay-per-use billing.

If your traffic is stable and utilization is high, traditional compute resources may be more cost-effective. If traffic fluctuates significantly and you want zero ops overhead, Lambda is the better choice.


Need Professional Cloud Cost Management?

If you're:

  • Evaluating Lambda's long-term cost efficiency
  • Want to optimize existing Serverless spending
  • Unsure whether to choose Lambda or EC2

Book Free Consultation - we'll respond within 24 hours.

Many enterprises can actually save 20-40% on cloud spending.


References

  1. AWS Official Documentation: Lambda Pricing
  2. AWS Official Documentation: Lambda Quotas
  3. AWS Official Tool: AWS Lambda Power Tuning
  4. AWS Blog: Operating Lambda: Performance optimization
  5. AWS Pricing Calculator: AWS Pricing Calculator

Need Professional Cloud Advice?

Whether you're evaluating cloud platforms, optimizing existing architecture, or looking for cost-saving solutions, we can help

Book Free Consultation

Related Articles