Function as a Service (FaaS)
Function as a Service (FaaS) is a serverless cloud model that runs individual functions on demand without managing servers.
Function as a Service (FaaS) is a cloud computing execution model where the cloud provider manages the server infrastructure and dynamically allocates resources to run individual functions in response to events or HTTP requests. Developers write discrete pieces of logic -- functions -- and deploy them without provisioning or maintaining servers.
How FaaS works
In a FaaS environment, each function is typically triggered by an event such as an HTTP request, a database change, a message queue event, or a scheduled timer. The cloud provider spins up an execution environment, runs the function, returns the result, and then tears down or freezes the environment. Billing is based on actual execution time and the number of invocations rather than reserved capacity.
Common FaaS platforms include AWS Lambda, Google Cloud Functions, Azure Functions, and Cloudflare Workers. Each differs in supported runtimes, cold start behavior, execution limits, and pricing models, but they share the core principle: the developer supplies code, and the platform handles everything else.
Key characteristics
Event-driven execution: Functions run only when triggered, making FaaS well suited for workloads with variable or unpredictable traffic patterns.
Automatic scaling: The platform scales function instances up and down based on demand, including scaling to zero when there is no traffic.
Pay-per-use pricing: Costs are tied to the number of executions and their duration, which can reduce expenses for infrequent or bursty workloads.
Stateless by default: Each function invocation is independent. Persistent state must be stored externally in a database, cache, or object store.
FaaS and API gateways
An API gateway is a natural companion to FaaS. The gateway receives inbound HTTP requests, applies policies such as authentication and rate limiting, and routes traffic to the appropriate function or backend. This separation lets developers keep business logic in lightweight functions while the gateway handles cross-cutting concerns.
Serverless API Gateway runs on Cloudflare Workers -- itself a FaaS platform -- and can route requests to backend services running on any cloud provider's FaaS offering. Because both the gateway and the backend functions are serverless, the entire request path can operate without fixed infrastructure, scaling on demand and incurring costs only when requests are processed.
When to use FaaS
FaaS is a strong fit for API backends, webhook handlers, scheduled jobs, data transformations, and event processing pipelines. It is less suited for long-running processes, workloads with sustained high throughput where reserved capacity is more cost-effective, or applications that depend heavily on in-memory state between requests.
Related documentation
Getting Started - Deploy your first serverless API gateway
Servers Configuration - Configure upstream servers including FaaS backends
Service Binding - Bind Cloudflare Workers services together
Last updated