Skip to main content

Serverless

computing allows developers to deploy and run application code without provisioning, configuring, or managing underlying servers. Instead of paying for allocated virtual machine capacity that runs around the clock, you provide your application logic and define event triggers. The cloud platform provisions compute resources on demand, executes your code, and meters billing in millisecond increments strictly for the execution duration. When traffic drops to zero, compute allocation scales down to zero, and billing ceases entirely.

While the financial appeal of paying only for active compute is substantial, serverless architecture fundamentally reshapes how software is engineered. Building effectively on serverless platforms requires understanding execution lifecycles, initialization latencies, runtime limits, and downstream database saturation.

Functions

At the center of serverless compute is the (often referred to as Function-as-a-Service or FaaS). A function is a discrete block of application code with a single entry point, packaged with its runtime dependencies and wired to an event source. Triggers span a wide spectrum: incoming HTTP requests via an API gateway, messages landing on a queue, files uploaded to an object store, change-data-capture records from a database, or scheduled cron timers. When an event fires, the provider instantiates a sandboxed execution environment, passes the event payload to your handler, and releases the resources when execution completes.

Function execution is strictly stateless. Providers make no guarantees that subsequent invocations will execute on the same physical host or reuse the same memory space. Local disk storage is ephemeral and cleared between executions. Any state that must persist across requests—such as user sessions, transactional data, or uploaded assets—must be written to an external database or object bucket.

Cold starts

When a function is invoked after a period of inactivity, or when incoming traffic exceeds existing concurrency, the provider must allocate a microVM, boot the language runtime, download application assets, and execute top-level initialization code before handling the event. This initial latency penalty is a .

Cold start duration varies widely depending on the runtime environment and package footprint: lightweight runtimes like Node.js, Go, or Python often initialize in tens of milliseconds, whereas heavier runtimes like Java or .NET with substantial dependency injection frameworks can take several seconds. Once initialized, an execution environment remains warm for a short window, allowing subsequent invocations to execute almost instantaneously. For latency-sensitive public APIs, providers offer pre-warmed capacity (often called provisioned concurrency or minimum instances), which eliminates cold starts at the expense of reintroducing an idle hourly reservation charge.

Limits

Serverless functions operate within strict guardrails enforced by the provider:

  • Execution timeouts: Functions enforce hard execution ceilings, typically between 5 and 15 minutes. Long-running data imports, extensive video encoding tasks, or persistent background daemons will be abruptly terminated when they reach the timeout threshold.
  • Resource boundaries: Providers enforce fixed limits on maximum memory allocation, virtual CPU shares, and ephemeral disk space.
  • Downstream connection exhaustion: Serverless functions scale horizontally in seconds, rapidly creating hundreds or thousands of concurrent instances in response to traffic spikes. However, traditional relational databases enforce strict connection limits. If a thousand function instances attempt to open dedicated database connections simultaneously, they will overwhelm the database server and trigger widespread connection timeouts. Mitigating this requires intermediate connection poolers or queue-buffered consumer designs.
Choosing a function or a container

Choose serverless functions when workloads meet four criteria. Otherwise, adopt container runtimes.

  1. The execution duration finishes well within the provider's hard function timeout window.
  2. The workload is triggered by asynchronous events or bursty traffic patterns rather than running continuously.
  3. Low or erratic traffic makes scaling down to zero a tangible financial advantage.
  4. Downstream dependencies (such as relational databases) can absorb the rapid concurrency scaling without connection exhaustion.

Managed containers

Between raw serverless functions and full Kubernetes clusters sits an increasingly popular middle tier: the . These services execute standard container images on demand, automatically scaling instances based on incoming request volume while abstracting away underlying server nodes and cluster management.

Managed container runtimes combine the operational simplicity of serverless with the flexibility of containers. Unlike functions, which enforce proprietary packaging formats and rigid language runtimes, managed containers run any binary, library, or framework that can be packaged into an OCI image. Crucially, single container instances can process multiple concurrent HTTP or gRPC requests simultaneously, dramatically reducing connection thrashing against downstream databases while preserving scale-to-zero cost efficiency during idle hours.

Event-driven design

Serverless architectures naturally guide engineering teams toward event-driven topologies. Rather than orchestrating workflows through synchronous HTTP calls between microservices, components communicate by publishing events to topics and queues. An image uploaded to a storage bucket automatically triggers an image resizing function, which emits an event to a topic, which in turn triggers notification and indexing services in parallel.

While this pattern provides exceptional decoupling and independent scaling, it shifts complexity into system observability. When a business transaction spans multiple decoupled functions and message queues, diagnosing failures requires comprehensive distributed tracing and structured log aggregation. As described on the messaging page, incorporating robust dead-letter queues and workflow orchestrators is essential for maintaining operational visibility across complex event flows.

Terms introduced

  • Serverless: running code without a server you can see, billed per run rather than per hour.
  • Function: a single-entry-point piece of code the provider runs in response to a trigger.
  • Cold start: the delay when a function runs after a quiet period and the provider has to start a container first.
  • Managed container runtime: a service that runs a container image, scaling the copies with traffic, with no cluster to own.

How providers do it

Serverless architectures across AWS, Azure, and Google Cloud have converged around two primary models: event-driven function handlers (FaaS) and serverless container runtimes. While both models provide automated scaling down to zero and sub-second billing increments, the providers take different approaches to concurrency and event routing.

ConceptAWSAzureGoogle Cloud
Function executionAWS LambdaAzure FunctionsCloud Run functions
Managed container runtimeAWS App Runner, Amazon ECS on FargateAzure Container AppsCloud Run services
HTTP ingress endpointAmazon API Gateway, Lambda function URLsHTTP trigger bindingsCloud Run default HTTPS service URL
Event source triggersEvent source mappings (SQS, S3, DynamoDB)Input bindings (Service Bus, Blob, Event Grid)Eventarc triggers
Scheduled cron triggersAmazon EventBridge SchedulerAzure Functions timer triggersGoogle Cloud Scheduler
Pre-warmed instancesProvisioned ConcurrencyAlways-ready instances (Premium/Flex tiers)Minimum instances (--min-instances)
Batch job executionAWS Batch, Fargate standalone tasksAzure Container Apps jobs, Azure BatchCloud Run jobs, Google Cloud Batch
Workflow state machineAWS Step FunctionsAzure Durable Functions, Azure Logic AppsGoogle Cloud Workflows
Centralized event busAmazon EventBridgeAzure Event GridGoogle Cloud Eventarc

Every product name and technical mapping above is confirmed against provider documentation. Specific maximum execution timeouts and warm-instance pricing structures are marked unconfirmed in the provider tabs below.

A fundamental architectural distinction exists in request concurrency:

  • AWS Lambda allocates one isolated execution environment per concurrent request. If 500 requests arrive at the same millisecond, Lambda spins up 500 distinct microVM instances, each opening its own dedicated TCP connections to downstream databases and caches.
  • Google Cloud Run defaults to multiplexed concurrency, allowing a single container instance to process up to 80 (or more) concurrent requests simultaneously over shared memory and connection pools. This drastically reduces the number of container instances required for high-throughput HTTP workloads, preventing downstream database connection exhaustion.

What this maps to: AWS Lambda is the function product. Managed containers come as AWS App Runner or ECS on Fargate. Step Functions orchestrates several of either into a flow.

ConceptOn AWSStatus
FunctionA Lambda function, deployed as a zip or a container imageconfirmed
TriggersAPI Gateway or a Lambda function URL for HTTP; SQS, SNS, S3, EventBridge, DynamoDB Streams, Kinesis for events; EventBridge Scheduler for timersconfirmed
Keeping containers warmProvisioned concurrency, billed for the time the containers are reservedconfirmed
Maximum run timeFifteen minutesunconfirmed; check current quotas
Concurrency limitA per-region account limit, shared across all functions, raisable by request. Reserved concurrency caps one function so it cannot starve the othersconfirmed
Managed container runtimeApp Runner builds and runs a container from an image or a repository, with autoscaling and a public URL. Scale-to-zero pauses compute but still bills for provisioned memoryunconfirmed; check current pricing
OrchestrationStep Functions runs a state machine that calls functions, waits, retries, and branchesconfirmed
Event busEventBridge routes events between services and from SaaS sourcesconfirmed

Their vocabulary

Standard termTheir term
TriggerEvent source, or event source mapping for queues and streams
Warm containerExecution environment
Managed container runtimeApp Runner, or a Fargate service

Where to look

The Lambda console shows invocations, errors, duration, and throttles per function. Each invocation's output ends up in CloudWatch Logs. To follow one request across several functions, use X-Ray.

Last verified: never.


Check your understanding

0 of 4 answered

  1. What is a cold start?
  2. You pay to keep a number of function containers warm so users never see a cold start. What have you given up?
  3. A function scales to a thousand copies in a second. What is the most likely thing to break?
  4. A new HTTP service does not fit a function's run-time limit and the team has never run Kubernetes. Where should it start?