OpenFaaS is an open-source framework for running functions as a service on Kubernetes, packaging each function as a standard container image and exposing it through a central gateway. In serverless computing, it lets an organization operate its own function platform on any cloud or on premises instead of relying on a provider-managed service such as AWS Lambda or Azure Functions.
The project, originally named Functions as a Service, focuses on portability and developer simplicity. A developer writes a handler, builds it with a template into an OCI container image, and deploys it with one command; the platform then handles routing, scaling, metrics and asynchronous invocation.
How OpenFaaS runs functions on Kubernetes
OpenFaaS consists of a small set of components that sit on top of a Kubernetes cluster. The OpenFaaS gateway receives every HTTP request, the faas-netes provider translates function deployments into Kubernetes Deployments and Services, and Prometheus collects request metrics that drive scaling decisions.
Inside each function container runs the watchdog, a tiny process that acts as the container’s entry point. The classic watchdog forks a new process for every request and passes data over standard input and output, while the newer of-watchdog keeps a long-running process and proxies HTTP, which avoids per-request startup cost and allows connection pooling.
The following table summarizes the main components and their roles.
| Component | Role | Notes |
|---|---|---|
| Gateway | Routes calls and exposes the REST API | Also serves the web UI |
| faas-netes | Manages functions as Kubernetes objects | faasd replaces it on a single host |
| Watchdog | Bridges HTTP and the handler process | Classic or of-watchdog mode |
| Prometheus | Stores invocation metrics | Feeds alerting and autoscaling |
| NATS queue worker | Processes asynchronous requests | Supports retries and callbacks |
| faas-cli | Builds, pushes and deploys functions | Uses a stack.yaml file |
Invocation modes, triggers and scaling
OpenFaaS supports synchronous and asynchronous invocation. A synchronous call through /function/name waits for the result, whereas a call through /async-function/name returns HTTP 202 Accepted immediately and places the request on a NATS-based queue, optionally posting the result to a callback URL.
Beyond HTTP, connectors act as function triggers by subscribing to external event sources and invoking functions mapped by annotation. Common connectors cover Kafka, cron schedules, MQTT and cloud message queues; several of them are available only in the commercial editions.
Scaling relies on replica counts adjusted by metrics. The table below compares the scaling approaches that teams typically use.
| Mechanism | Signal | Typical use |
|---|---|---|
| Built-in autoscaler | Requests per second, capacity or CPU | Most HTTP functions |
| Kubernetes HPA | CPU or memory utilization | Compute-heavy workloads |
| Scale to zero | Idle period without calls | Rarely used functions |
| Fixed minimum replicas | Configured floor | Latency-sensitive endpoints |
Scale to zero saves cluster resources but introduces a cold start when the first request arrives. Because a pod must be scheduled and the container started, that delay usually ranges from under one second to several seconds, depending on image size and node capacity.
OpenFaaS compared with other serverless platforms
OpenFaaS belongs to the group of self-hosted serverless platforms, which trade operational effort for control and portability. The comparison below places it next to managed and open-source alternatives.
| Platform | Hosting model | Unit of deployment | Key difference |
|---|---|---|---|
| OpenFaaS | Self-hosted on Kubernetes or faasd | Container image | Simple gateway and templates |
| Knative | Self-hosted on Kubernetes | Container image | Richer eventing, heavier install |
| AWS Lambda | Fully managed | Zip package or image | No cluster to operate |
| Google Cloud Run | Fully managed | Container image | Pay per request time |
| Azure Functions | Managed or self-hosted | Code package or image | Deep Azure integration |
The main advantage is avoiding vendor lock-in: the same function image runs on a laptop, in a private data center or on any managed Kubernetes service. The main cost is that the team, not a provider, operates the cluster, patches it and pays for idle nodes.
Editions, templates and practical deployment
OpenFaaS is distributed in a Community Edition for evaluation and smaller use, and in commercial Standard and Enterprise editions that add features such as advanced autoscaling, more connectors, single sign-on, multiple namespaces and support. License terms of the Community Edition have tightened over time, so teams should check the current license before production use.
Developers start from language templates for Python, Node.js, Go, Java and others, or provide any Dockerfile. The faas-cli up command builds the image, pushes it to a registry and deploys it in one step, and secrets are mounted from Kubernetes Secrets rather than environment variables.
For edge or very small installations, faasd runs OpenFaaS on a single virtual machine with containerd instead of Kubernetes. It suits low-cost appliances and labs but lacks multi-node high availability.
Limitations and common mistakes
Most problems with OpenFaaS stem from treating it as a fully managed service. The following table lists frequent issues and their remedies.
| Symptom | Cause | Remedy |
|---|---|---|
| Slow first response | Function scaled to zero | Keep one minimum replica for critical paths |
| Requests time out at the gateway | Timeouts not aligned across layers | Match gateway, watchdog and ingress timeout values |
| Large images start slowly | Heavy base images | Use slim bases and multi-stage builds |
| Lost asynchronous work | Queue worker restarts without retries | Configure retries and persistent streams |
| High cluster cost | Over-provisioned nodes for idle functions | Use a cluster autoscaler |
Functions should also remain stateless and idempotent. Any replica may handle any request, and the queue may deliver a retried message twice, so durable data belongs in an external database or object store rather than on the container file system.
The idea in brief
Many cloud providers let programmers upload a small piece of code, a function, and run it only when needed. OpenFaaS offers the same convenience on hardware a company controls.
It works like a reception desk for small programs. Requests arrive at the desk, which sends each one to the right function, starts more copies when traffic rises and shuts them down when it is quiet. The company keeps freedom to move between clouds, but it must also look after the building.
A practical scenario
A logistics company runs a private Kubernetes cluster in its own data center because shipment data must stay on premises. Its developers need to resize scanned delivery receipts and extract barcodes whenever a driver uploads a photo.
The team deploys two OpenFaaS functions written from the Python template. Uploads trigger asynchronous invocations through the queue, so the mobile app receives an immediate HTTP 202 response. The autoscaler grows each function from one to twelve replicas during the evening peak, when about 30 photos arrive per second, and returns to one replica overnight.
The result is processing within roughly three seconds per receipt at peak, no data leaving the company network and the option to move the same container images to a managed cloud cluster later without code changes.