Price Comparision serverless function over azure, aws, google and cloudflare

Scenario:
Requests: 10 million per month
Response size: 2KB per response

The cost of handling 10 million requests per month, each with a 2 KB response, depends on the pricing model of the cloud provider’s serverless platform. Here’s an estimate for Azure Functions, AWS Lambda, Google Cloud Run, and Cloudflare Workers:


1. Azure Functions

Pricing:

  • Execution Time: Azure charges based on the execution duration in GB-seconds.
  • Free Tier: 1 million requests and 400,000 GB-seconds per month free.

Calculation:

  1. Assume each function execution takes 100 ms on a 128 MB instance:
    • Execution time = 107×0.1 seconds=1,000,000 seconds
    • Memory consumption = 128 MB
    • GB-seconds = 1,000,000×1281024=125,000 GB-seconds
  2. After free tier:
    • Cost = (125,000−400,000)×$0.000016(if free tier exceeded).
  3. Data Transfer:
    • Outbound data = 107×2 KB=20 GB.
    • Outbound data cost: 20 GB × $0.087 = $1.74.

Estimated Total: ~$2 (may vary based on execution time).


2. AWS Lambda

Pricing:

  • Requests: $0.20 per 1 million requests.
  • Execution Time: $0.0000166667 per GB-second.
  • Free Tier: 1 million requests and 400,000 GB-seconds per month free.

Calculation:

  1. Assume 100 ms execution time and 128 MB memory:
    • Execution time = 1,000,000 seconds
    • GB-seconds = 125,000 GB-seconds.
  2. Cost for GB-seconds:
    • 125,000×0.0000166667=$2.08.
  3. Requests cost:
    • (10−1)×0.20=$1.80.
  4. Data Transfer:
    • Outbound data = 20 GB.
    • Cost: 20×$0.09=$1.80.

Estimated Total: ~$5.68 (with free tier).


3. Google Cloud Run

Pricing:

  • Requests: $0.40 per 1 million requests.
  • CPU and Memory: $0.000024 per vCPU-second and $0.0000025 per GB-second.
  • Free Tier: 2 million requests, 360,000 GB-seconds, and 180,000 vCPU-seconds per month free.

Calculation:

  1. Assume 0.1 vCPU and 128 MB memory with 100 ms execution:
    • vCPU-seconds = 1,000,000×0.1=100,000 vCPU-seconds.
    • GB-seconds = 125,000 GB-seconds.
  2. After free tier:
    • vCPU cost = 100,000×$0.000024=$2.40.
    • GB cost = 125,000×$0.0000025=$0.31.
  3. Requests cost:
    • (10−2)×$0.40=$3.20.
  4. Data Transfer:
    • Outbound data: 20 GB × $0.12 = $2.40.

Estimated Total: ~$8.31.


4. Cloudflare Workers

Pricing:

  • Requests: $5 per 10 million requests (flat fee with no free tier on Workers Paid plan).
  • Data Transfer: Free for egress (within Cloudflare limits).

Calculation:

  1. Requests cost: $5.
  2. Outbound data: Free (no cost for 20 GB).

Estimated Total: ~$5.


Comparison Table

ProviderCost
Azure Functions~$2
AWS Lambda~$5.68
Google Cloud Run~$8.31
Cloudflare Workers~$5

Key Notes

  1. Azure Functions is the cheapest when you have efficient code and stay within execution limits.
  2. AWS Lambda offers flexibility and low costs if your app stays within the free tier.
  3. Cloudflare Workers are great for low-latency edge functions with predictable pricing.
  4. Google Cloud Run is ideal for containerized workloads but has higher costs for small workloads.

Let me know if you’d like detailed steps for cost optimization!