Skip to content

Serverless architecture: costs, limits and use cases

B2Bnetwork team · · 6 min

Technology and trends

In brief

Serverless architecture is a model in which code runs in response to an event, and the cloud provider allocates servers, scales them and shuts them down on its own. You pay for the number of invocations and the execution time, not for machines that are always on. The model pays off for irregular traffic and event-driven jobs: file processing, integrations, scheduled tasks. Under constant high load it can cost more than containers, and limits on time, memory and cold starts rule out some uses.

How serverless works and how cost is calculated

In the functions as a service (FaaS) model you write a function and the platform runs it when an event arrives: an HTTP request, a file in object storage, a message in a queue or a scheduled trigger. The most widely used platforms are AWS Lambda and Azure Functions.

AWS bills Lambda for two things: the number of requests and the duration measured in gigabyte-seconds, meaning allocated memory multiplied by execution time. According to the AWS documentation, the charge also covers the time spent initializing the environment. The free tier is one million requests and 400,000 GB-seconds per month. Allocated memory also controls CPU power: at 1,769 MB a function has the equivalent of one vCPU.

Three practical conclusions follow:

  • cost grows linearly with traffic, so with low, irregular traffic it is very low, and with high, steady traffic it can exceed the cost of containers or virtual machines;
  • more memory does not always mean more expensive, because a function with a larger allocation gets more CPU and may finish sooner;
  • cost depends on the whole chain, not just the function: the API gateway, queues, logs and data transfer often cost more than the invocations themselves.

Keeping those line items under control is covered in the article on FinOps.

Limits to know before you design

Functions have hard limits. The most important ones according to the AWS Lambda and Azure Functions documentation (as of November 2026):

ParameterAWS LambdaAzure Functions
Maximum duration of one invocationup to 30 minutesFlex Consumption and Premium: 30 minutes by default, no hard maximum; legacy Consumption plan: up to 10 minutes
Response to an HTTP requestdepends on the gateway in front of the functionat most 230 seconds regardless of plan
Memory128 MB to 10,240 MBFlex Consumption: 512 MB, 2,048 MB or 4,096 MB instances
Invocation payload size6 MB synchronous, 1 MB asynchronousdepends on the trigger
Default concurrency limit1,000 concurrent executions per Region, can be raisedFlex Consumption: up to 1,000 instances

Limits change, so check the current documentation before you design. Microsoft now labels the Consumption plan as legacy and recommends Flex Consumption for new apps.

The concurrency limit has another side too. A function that scales to a thousand instances can open a thousand connections to a database that accepts a few hundred. With serverless you have to plan a connection pool or a connection proxy.

Cold starts and how to reduce them

A cold start is the delay on the first invocation in a new environment: the platform downloads the code, starts the environment and runs the initialization code outside the main handler. AWS states that cold starts typically affect fewer than 1% of invocations and last from under 100 ms to over a second. The Lambda initialization phase is limited to 10 seconds.

Ways to reduce cold starts:

  1. A smaller package. Import only the libraries you need, because the size of dependencies lengthens initialization.
  2. Connections in initialization code. A database client or SDK created outside the handler stays in memory between invocations in the same environment.
  3. Environments kept ready. Lambda offers provisioned concurrency, meaning pre-initialized environments, and for some runtimes also SnapStart, which starts from a snapshot. Azure Functions has always ready instances in the Flex Consumption and Premium plans. Both options cost money even when there is no traffic.
  4. Asynchrony where possible. If the user is not waiting for the result, a cold start stops mattering.

What serverless fits and what it does not

Use caseFitWhy
Processing files after upload (thumbnails, text extraction from PDF)goodevent-driven, short task, irregular traffic
Partner integrations and webhooksgoodtraffic depends on the partner, easy scaling
Scheduled jobs (nightly report, data cleanup)goodyou pay only for execution time
Queue consumer during peaksgoodthe platform scales instances with queue length
API with constant high trafficit dependscalculate the cost and compare with containers
Long computations and batch processingpoortime limits, containers or batch jobs fit better
Systems needing low, predictable latency, such as payment authorizationwith carecold starts and network dependency require environments kept ready
Stateful services and long-lived connectionspoora function does not keep state between invocations

A pattern that often works well is a function as a queue consumer: it accepts work during the peak while the database receives a steady, controlled load. Details are in the article on queues and asynchronous processing.

Testing, observability and vendor lock-in

A system made of many functions is a distributed system, so it needs the same tools as microservices: a request ID in logs, distributed traces and alerts on errors and timeouts. More on this in the article on observability.

Testing works best in three layers. Keep business logic in ordinary modules and unit test it without the platform. Test integration with queues, storage and the database on a real test account in the cloud, because emulators do not reproduce every limit. Before a peak, run a load test that checks concurrency limits and database behavior.

Vendor lock-in is real: triggers, permissions and configuration differ between AWS and Azure. You limit it by separating logic from the event handler code and describing the infrastructure as code. B2Bnetwork engineers design and test cloud systems for banks, telecom operators and manufacturers; see What we do.

Questions and answers

Is serverless cheaper than containers?

With low, irregular traffic usually yes, because you do not pay for idle servers. Under constant high load, containers or reserved virtual machines are often cheaper. Compare the cost for your real traffic profile across the whole chain (API gateway, queues, logs and data transfer), not just the price of function invocations.

How long can a single AWS Lambda function run?

According to the AWS documentation as of November 2026, a single invocation can run for up to 30 minutes. Lambda limits change, so check the value in the current documentation rather than in older write-ups. Jobs that take longer or are hard to predict are better split into steps with a queue between them, or run as a batch job in a container.

What is a function cold start?

It is the extra time on the first invocation in a new execution environment. The platform has to download the code, start the environment and run the initialization code. Subsequent invocations in the same environment are faster. You reduce cold starts with a smaller package, by moving connections into initialization, or with environments kept ready.

Is serverless suitable for a bank or an insurer?

Yes, in selected areas: integrations, document processing, scheduled jobs, events from systems. A financial institution also has to meet supervisory requirements for the cloud, including vendor assessment and an exit plan. For low-latency paths such as payment authorization, you need to quantify the impact of cold starts and use environments kept ready.

What it looks like in a project

Considering a new technology for your system? Talk to an engineer.

Let's talk

Read more: Technology and trends