|
1 | 1 | --- |
2 | 2 | myst: |
3 | 3 | html_meta: |
4 | | - description: "The OpenLambda worker — the core node component that handles HTTP requests, manages containers, and scales horizontally." |
5 | | - keywords: "OpenLambda, worker, serverless, Linux containers, HTTP, configuration" |
| 4 | + description: "The OpenLambda worker — the core node component that runs lambdas in SOCK sandboxes and serves HTTP, Kafka, and cron triggers." |
| 5 | + keywords: "OpenLambda, worker, serverless, SOCK, sandbox, HTTP, triggers, ol" |
6 | 6 | --- |
7 | 7 |
|
8 | 8 | # Worker |
9 | 9 |
|
10 | 10 | The OpenLambda **worker** is the core server-side component of a node. It listens for |
11 | | -incoming HTTP requests, manages container lifecycle, and returns responses to callers. |
| 11 | +incoming requests, runs lambdas inside isolated sandboxes, and returns responses to callers. |
| 12 | +The worker is part of the `ol` binary. |
12 | 13 |
|
13 | | -## Overview |
| 14 | +```{note} |
| 15 | +This page is a high-level summary. The authoritative, version-tracked documentation lives in |
| 16 | +the main repository under |
| 17 | +[`docs/worker`](https://github.com/open-lambda/open-lambda/tree/main/docs/worker). |
| 18 | +``` |
14 | 19 |
|
15 | | -Each worker is a standalone Go binary that exposes a single HTTP endpoint: |
| 20 | +## Architecture |
16 | 21 |
|
17 | | -``` |
18 | | -POST /runLambda/<lambda-name> |
19 | | -``` |
| 22 | +A worker is built from three layers, from the bottom up: |
| 23 | + |
| 24 | +1. **Sandbox** — isolates lambdas from one another. This layer is pluggable; the main |
| 25 | + implementation today is **SOCK** (serverless-optimized containers), described in |
| 26 | + [Oakes et al., ATC '18](https://www.usenix.org/conference/atc18/presentation/oakes). |
| 27 | + Early versions used Docker. |
| 28 | +2. **Lambda** — a *lambda instance* is a robust virtual container backed by zero or one |
| 29 | + sandboxes; a *lambda function* routes incoming requests to instances and decides how many |
| 30 | + instances to provision based on load. |
| 31 | +3. **Event** — the trigger sources that invoke lambdas. |
20 | 32 |
|
21 | | -When a request arrives the worker: |
| 33 | +## Triggers |
22 | 34 |
|
23 | | -1. Checks whether the lambda's container image is already present on the node; if not, pulls it from the registry. |
24 | | -2. Starts a Linux container from the image. |
25 | | -3. Passes the request payload to the lambda function running inside the container. |
26 | | -4. Waits for the function to return a result, then forwards that result back to the caller. |
27 | | -5. Optionally keeps the container warm for a short period to reduce cold-start latency on subsequent calls. |
| 35 | +The worker supports three kinds of triggers: |
28 | 36 |
|
29 | | -## Configuration |
| 37 | +- **HTTP** — a request to `http(s)://<worker-addr>:<port>/run/<lambda-name>` invokes a lambda |
| 38 | + directly. |
| 39 | +- **Kafka** — a lambda can be configured to consume messages from a Kafka topic. |
| 40 | +- **Cron** — a lambda can be invoked on a schedule. |
30 | 41 |
|
31 | | -The worker is configured via a JSON file (default `config.json`) in the working directory. |
32 | | -Key fields: |
| 42 | +## Building |
| 43 | + |
| 44 | +OpenLambda is actively tested on **Ubuntu 24.04 LTS**, requires **cgroups v2**, and relies on |
| 45 | +operations that need root privilege. After installing the |
| 46 | +[dependencies](https://github.com/open-lambda/open-lambda/blob/main/docs/worker/getting-started.md#dependencies), |
| 47 | +build the Python-only ("min") deployment: |
| 48 | + |
| 49 | +```bash |
| 50 | +make ol imgs/ol-min |
| 51 | +``` |
33 | 52 |
|
34 | | -| Field | Description | Default | |
35 | | -|---|---|---| |
36 | | -| `worker_port` | Port the HTTP server listens on | `8080` | |
37 | | -| `registry` | URL of the lambda registry | `""` | |
38 | | -| `sandbox` | Container backend (`docker` or `sock`) | `docker` | |
39 | | -| `log_output` | Where to write logs (`stdout` or a file path) | `stdout` | |
| 53 | +## Running a worker |
40 | 54 |
|
41 | | -## Starting the Worker |
| 55 | +The `ol worker` subcommands manage a worker's lifecycle (run `./ol worker --help` for the |
| 56 | +full list): |
42 | 57 |
|
43 | 58 | ```bash |
44 | | -# From the repo root after building: |
45 | | -./bin/worker --config config.json |
| 59 | +# Create a worker directory with a config.json and base image |
| 60 | +./ol worker init -i ol-min |
| 61 | + |
| 62 | +# Start the worker (use -d to run in the background) |
| 63 | +./ol worker up -d |
| 64 | + |
| 65 | +# Check status |
| 66 | +./ol worker status |
| 67 | + |
| 68 | +# Stop the worker |
| 69 | +./ol worker down |
46 | 70 | ``` |
47 | 71 |
|
48 | | -The worker prints its listening address on startup. You can verify it is running with: |
| 72 | +`init` creates a worker directory (named `default-ol` by default) containing the worker |
| 73 | +configuration (`config.json`), the read-only base image shared by all lambda instances, and |
| 74 | +other resources. Per-worker settings such as memory limits are edited in `config.json`: |
| 75 | + |
| 76 | +```json |
| 77 | +"limits": { |
| 78 | + "mem_mb": 512 |
| 79 | +} |
| 80 | +``` |
| 81 | + |
| 82 | +## Deploying a lambda |
| 83 | + |
| 84 | +Functions can be installed directly from a Git repository, with dependencies pinned via a |
| 85 | +`requirements.txt` and behavior configured via an `ol.yaml` file: |
49 | 86 |
|
50 | 87 | ```bash |
51 | | -curl -w "\n" localhost:8080/status |
| 88 | +./ol admin install -c ol.yaml -r requirements.txt https://github.com/<org>/<repo>.git |
| 89 | + |
| 90 | +# Invoke it |
| 91 | +curl http://localhost:5000/run/<lambda-name>/ |
52 | 92 | ``` |
53 | 93 |
|
54 | | -## Deploying Multiple Workers |
| 94 | +See the [Applications](applications/index.md) section and the |
| 95 | +[Ag Forecasting case study](blog/post/2026-05-18-ag-forecasting-case-study.md) for a complete |
| 96 | +worked example, including `ol.yaml` configuration and ASGI entry points. |
| 97 | + |
| 98 | +## Scaling out |
55 | 99 |
|
56 | | -Workers are stateless with respect to routing — each one operates independently. To scale |
57 | | -horizontally, start one worker process per node and place a standard HTTP load balancer |
58 | | -(Nginx, HAProxy, or similar) in front of them. No coordination between workers is required. |
| 100 | +Workers are independent and require no coordination, so you can scale horizontally by running |
| 101 | +one worker per node behind a standard HTTP load balancer (Nginx, HAProxy, or similar). |
59 | 102 |
|
60 | 103 | ```{note} |
61 | | -A centralized **boss** component for cluster-wide management is currently under development. |
62 | | -Until then, manual deployment behind a load balancer is the recommended approach for |
63 | | -multi-node setups. |
| 104 | +A centralized **boss** component for cluster-wide management is under development. Until then, |
| 105 | +manual deployment behind a load balancer is the recommended approach for multi-node setups. |
64 | 106 | ``` |
65 | 107 |
|
66 | | -## Further Reading |
| 108 | +## Further reading |
67 | 109 |
|
68 | | -- [Quickstart guide](https://github.com/open-lambda/open-lambda/blob/main/docs/quickstart.md) — get a single worker running locally in minutes |
69 | | -- [SOCK: Rapid Task Provisioning with Serverless-Optimized Containers](https://www.usenix.org/conference/atc18/presentation/oakes) — the research paper describing the container backend. |
| 110 | +- [Getting started](https://github.com/open-lambda/open-lambda/blob/main/docs/worker/getting-started.md) — build, deploy, and run your first lambda |
| 111 | +- [Lambda configuration](https://github.com/open-lambda/open-lambda/blob/main/docs/worker/lambda-config.md) — the `ol.yaml` format |
| 112 | +- [Deploying applications](https://github.com/open-lambda/open-lambda/blob/main/docs/worker/apps.md) — example app walkthroughs |
| 113 | +- [SOCK: Rapid Task Provisioning with Serverless-Optimized Containers](https://www.usenix.org/conference/atc18/presentation/oakes) — the sandbox research paper |
0 commit comments