Skip to content
EncryptTechBD
Home Industries Our Work Blog Pricing About Contact Discuss Your Project
বাংলা (BN)
Cloud, DevOps & FinOps 6 min read

Serverless architecture cost analysis: a step-by-step guide

A repeatable method for pricing a serverless workload across requests, duration, memory, data transfer, storage, logging and the managed services around it.

E
EncryptTechBD · 0 comments
Exterior of a large data centre building
Photo: Charlie fong / Wikimedia Commons (BY-SA)

Serverless pricing looks simple: pay for requests and for the time your code runs. The bill is rarely that simple. A function calls a managed database, writes to a queue, emits logs, pulls a secret and sends data across a network boundary. Each of those services has its own meter, and a design that is cheap at low volume can become expensive at steady load.

This guide gives you a repeatable way to analyse the cost of a serverless architecture before you commit. It uses variables rather than vendor rates, because rates change by region and contract. Fill in the current published rates from your provider and keep the model with the architecture decision record.

Prerequisites

  • A defined workload with a unit of work, such as one order, one file or one API request.
  • Expected volume: average, peak and seasonal.
  • Latency and availability targets.
  • A data model and retention period for logs, files and events.
  • The current cost of the system you are replacing, if there is one.
  • A named owner for the cost model and the budget.

Step 1: Define the unit of work

Cost per request is meaningless if one request triggers twelve functions, three queue messages and a database write. Define the unit that the business cares about: a completed order, a processed claim, a generated report. Then count every invocation, message and storage operation that unit causes. This is the denominator for unit economics and the only way to compare architectures fairly.

Step 2: Estimate invocation volume

Use three scenarios: average month, peak hour and a launch or campaign spike. Include retries, scheduled jobs, health checks and internal calls. A function that runs every minute is 43,200 invocations a month before any customer traffic. Multiply by the number of environments you run, including staging and preview environments that nobody remembers.

Step 3: Measure duration and memory

Duration is not the same as response time. Measure the billed execution time, including cold starts, retries and time spent waiting on a downstream call. Test at realistic memory settings; more memory can reduce duration enough to lower total cost, but it can also hide an inefficient query. Record the p50 and p95 duration, not only the average.

Step 4: Include the managed services around the function

  • API gateway or load balancer requests.
  • Queue, topic and event bus operations.
  • Managed database compute, storage, backups and connections.
  • Object storage, requests and retrieval.
  • Secrets, configuration and key management.
  • CI/CD minutes and artefact storage.

Functions are often the smallest line. A managed database with a minimum capacity can dominate a low-traffic workload.

Step 5: Add data transfer and network address translation

Data leaving a region, crossing an availability zone or passing through a NAT gateway is billed separately. A function in a private subnet that calls an external API may incur NAT processing charges that never appear in the function estimate. Map the traffic path, not just the compute.

Step 6: Price observability

Logs are a cost line. Calculate the volume per invocation, the retention period and the number of environments sending logs. A verbose debug log left on in production can cost more than the compute it describes. Set sampling, retention and log-level rules before launch, and include the cost of dashboards, traces and alerts.

Step 7: Model retries and failures

Serverless systems retry by design. A downstream timeout can multiply invocations and queue messages. Model a failure scenario: if a meaningful share of requests retry three times, the invocation count rises, and the duplicate writes may cost more than the compute. Idempotency and dead-letter queues are cost controls as well as reliability controls.

Step 8: Build the monthly formula

Use this structure with your provider's current rates:

  • Function cost = requests × price per request + GB-seconds × price per GB-second.
  • Gateway cost = requests × price per gateway request.
  • Data cost = storage volume × storage rate + egress volume × egress rate + request charges.
  • Observability cost = log volume × ingestion rate + retention + trace and dashboard charges.
  • Total = function + gateway + data + observability + queue + database + support and CI/CD.

Calculate the total per unit of work, then multiply by the three volume scenarios. A model that only works at average volume is not a model.

Step 9: Compare with a container or server baseline

Price the same workload on a container service or a small server fleet. Include idle capacity, patching, scaling and operations time. Serverless often wins at spiky or low volume and loses at steady high volume; the crossover depends on your utilization, not on a general rule. Put both numbers in the same document and state the assumptions.

Step 10: Pilot, measure and set guardrails

  1. Deploy a production-like pilot with the same memory, timeout and logging settings.
  2. Run a load test at average and peak volume.
  3. Compare the measured bill with the model and explain the difference.
  4. Set budgets, anomaly alerts and a monthly review owner.
  5. Record the decision and the conditions that would trigger a revisit.

Where serverless costs surprise teams

  • Idle managed databases with a minimum capacity.
  • NAT gateway hours and data processing.
  • Cross-region or cross-zone traffic.
  • Verbose logs with long retention.
  • Retries and duplicate events.
  • Many small functions with a gateway request each.
  • Non-production environments running all month.

Common mistakes

  • Estimating function cost and ignoring the services around it.
  • Using average duration instead of p95.
  • Forgetting staging, preview and disaster-recovery environments.
  • Assuming serverless is always cheaper at scale.
  • Setting a budget without an alert recipient who can change the architecture.

Metrics

  • Cost per unit of work, by environment.
  • Invocation count, duration and memory utilisation.
  • Percentage of spend from non-production environments.
  • Log volume and retention cost per service.
  • Retry rate and dead-letter queue volume.
  • Model versus actual variance.

Where this fits in our work

Serverless cost analysis is an architecture and FinOps exercise, not a pricing-page lookup. Our Managed Technology & Cybersecurity division reviews the workload, the managed services and the operating model together; the pricing page explains how an assessment is scoped. For the broader cost routine, read AWS cost optimisation for SMEs.

Sources

Services that deliver this

Want this implemented properly?

Pricing →

Every engagement starts with a written scope. If a requirement is outside it, we quote it separately before starting.

Responses (0)

No comments yet. Add the first one below.

Leave a response

Your email address will not be published. Required fields are marked *.

Keep reading

More field notes