Configuration
The runner is configured with environment variables. On Lambda they are set on
the function; locally you can use an .env file (loaded with
python-dotenv). All values are read once, when the module is imported.
Integers and booleans are validated at start-up: an invalid value (for example
DEBUG_MODE=maybe or CB_FAIL_MAX=five) makes the runner fail immediately
with a clear message instead of misbehaving later.
Runner settings
Name |
Description |
Values |
Default |
|---|---|---|---|
|
Task definition: where each task name runs (see below) |
JSON object |
|
|
DynamoDB region |
A string |
|
|
Backend table name |
A string |
|
|
Seconds a stored result is kept (see Result expiration). |
Integer >= 0 |
|
|
Attempts to invoke a remote Lambda when the invocation itself fails |
Integer |
|
|
Consecutive failures that open the circuit breaker of a remote Lambda |
Integer |
|
|
Seconds before an open circuit breaker lets one call through |
Integer |
|
|
Seconds kept free before the Lambda timeout. A task is stopped (its |
Integer >= 0 |
|
|
Also store |
|
|
|
Records of a batch processed at the same time, in threads. |
Integer >= 1 |
|
|
How results are written; must match the client’s |
|
|
|
Modules imported once when the function starts (to connect signal receivers). Comma separated |
|
empty |
|
Write CloudWatch metrics (Embedded Metric Format) to the log |
|
|
|
CloudWatch namespace of those metrics |
A string |
|
|
Seconds to wait for a remote Lambda to answer |
Integer |
|
Important
CELERY_BACKEND_REGION and CELERY_BACKEND_TABLE must point to the same
table as the result_backend URL of the client.
Logging and debugging
Name |
Description |
Values |
Default |
|---|---|---|---|
|
Log level of the application |
|
|
|
Log format (loguru format string) |
A string |
Coloured, with |
|
Dump local variables in tracebacks. May leak task arguments to the logs |
|
|
|
Send log records through a queue (multiprocessing-safe) |
|
|
|
Wait for a |
|
|
|
Interface |
A host / IP |
|
|
Port |
Integer |
|
Task definition (TASKS)
TASKS is a JSON dictionary. The key is the name of the task as sent by
Celery, and the value is a URL that says where it runs:
URL |
Meaning |
|---|---|
|
Call |
|
Invoke the Lambda function with that ARN (an alias or version suffix is accepted). |
{
"tasks.add": "task://my_tasks/add",
"tasks.multiply": "lambda://arn:aws:lambda:eu-central-1:123456789012:function:multiply"
}
Whatever the route, a task has at most 15 minutes to finish (the AWS Lambda limit; see Execution time limit).
An invalid TASKS (not JSON, not an object, or a value without scheme://)
stops the runner at start-up. A task whose name is not listed is stored as
FAILURE and never runs: TASKS is an allowlist.
Setting TASKS on a function
The value is JSON inside JSON, so avoid shell quoting by using a file:
{
"Variables": {
"TASKS": "{\"tasks.add\": \"task://my_tasks/add\"}",
"CELERY_BACKEND_TABLE": "lambda-runner-tasks",
"CELERY_BACKEND_REGION": "eu-central-1"
}
}
aws lambda update-function-configuration \
--function-name celery-cloud-runner \
--environment file://env.json
Client configuration
The Celery client is configured with Celery’s own settings; the ones that matter for Celery Cloud are:
Setting |
Value |
|---|---|
|
|
|
|
|
Region of the queue |
|
|
|
Name of the queue |
|
Always set it explicitly: it must equal the key used in |
|
|
|
|