Functions
Serverless function deployment, invocation, and management
Overview
Scalix Functions let you deploy and invoke serverless functions with multiple runtime support. Functions scale to zero when idle. Warm invocations return in ~15ms; a cold start (full Firecracker microVM boot) takes ~1.6s.
Quick Start
Create a function:
typescript
// handler.ts
export default async function handler(req: Request) {
const body = await req.json();
return new Response(JSON.stringify({ result: body.x + body.y }), {
headers: { "Content-Type": "application/json" },
});
}Deploy:
bash
scalix-cloud fn deploy add --source . --runtime node --handler handler.handlerfn deploy requires either --source <path> or --image <image>.
Invoke:
bash
scalix-cloud fn invoke add --data '{"x": 1, "y": 2}'REST API
Deploy a Function
bash
curl -X POST https://api.scalix.world/v1/functions \
-H "Authorization: Bearer $SCALIX_API_KEY" \
-d '{
"name": "process-order",
"runtime": "node",
"image_ref": "registry.scalix.world/my-org/process-order:latest",
"handler": "index.handler",
"timeout_ms": 30000,
"memory_mb": 256,
"env": { "STRIPE_KEY": "sk_..." }
}'Invoke a Function
bash
curl -X POST https://api.scalix.world/v1/functions/{id}/invoke \
-H "Authorization: Bearer $SCALIX_API_KEY" \
-d '{"order_id": "ord_123"}'List Functions
bash
scalix-cloud fn listView Invocation Logs
bash
curl https://api.scalix.world/v1/functions/{id}/invocations \
-H "Authorization: Bearer $SCALIX_API_KEY"Supported Runtimes
| Runtime | Value |
|---|---|
| Node.js | node |
| Python | python |
Scheduled Functions
Deploy the function, then schedule it with a cron job that invokes it. Create the schedule with Cron:
bash
# Deploy the function
scalix-cloud fn deploy daily-report --runtime node --source <git-url>
# Schedule it: <name> <cron-expression>, targeting the function
scalix-cloud cron create daily-report "0 6 * * *" \
--action-type function \
--config '{"function_id":"daily-report"}'Resource Limits
| Setting | Default | Max |
|---|---|---|
| Timeout | 30s | 300s |
| Memory | 128 MB | 4 GB |
| vCPUs | 0.25 | 2 |
| Payload | 6 MB | 6 MB |