Skip to main content

Function as a Service

Execute code on demand with automatic scaling and pay-per-execution billing.

Overview

Function as a Service (FaaS) eliminates infrastructure management. Write your function, configure it, and the platform handles scaling, routing, and availability. Ideal for microservices, APIs, event-based tasks, and background jobs.


Prerequisites

  • Dashboard or API access
  • Code packaged (ZIP or container) or linked repository
  • (Optional) Registry access for container deployments
  • (Optional) CI/CD credentials for automated pipelines

Supported Runtimes

LanguageVersions
C#6.0, 7.0
Java11, 17, 21
Node.js18, 19, 20
Python3.8, 3.9, 3.10
Go1.20, 1.21

Step 1: Create Function

  1. Navigate to Compute > Function as a Service
  2. Click Create Function
  3. Configure:
SettingDescription
Function namee.g., processImage
RuntimeSelect from supported versions
Entry pointHandler method (language-specific)
CodeUpload ZIP or link repository
RegionDeployment location
  1. Click Create

Deployment takes seconds. Function is active when status shows Ready.


Step 2: Configure Runtime

SettingDescription
Memory128 MB, 256 MB, etc.
TimeoutMax execution duration (default 60s)
Environment VariablesRuntime config and secrets
ConcurrencyMin/max instances (0 enables scale-to-zero)
TriggerHTTP endpoint, event, or cron schedule

Step 3: CI/CD with GitHub Actions

name: "Deploy Function as a Service"

on:
push:
branches: [ "main" ]

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup runtime (if needed)
uses: actions/setup-node@v5
with:
node-version: "18"

- name: Build/package
run: |
zip -r function.zip .

- name: Deploy function
run: |
curl -X POST https://api.platform.example.com/v1/faas/functions/deploy \
-H "Authorization: Bearer ${{ secrets.FAAS_API_KEY }}" \
-F "name=myfunction" \
-F "runtime=nodejs18" \
-F "file=@function.zip"

Step 4: Invoke Function

HTTP Trigger

curl -X POST https://faas.example.net/functions/myfunction \
-H "Authorization: Bearer <TOKEN>" \
-d '{"key":"value"}'

Check logs to verify output. Scheduled or event triggers execute automatically.


Step 5: Scaling and Optimization

  • Scale-to-zero when no traffic, scale up on demand
  • Monitor invocation count, duration, memory, error rate
  • Optimize memory/time to minimize cost
  • Set minimum instances to reduce cold-start latency

Features Summary

FeatureDescription
Multiple RuntimesC#, Java, Node.js, Python, Go
Flexible TriggersHTTP, events, cron schedules
Zero InfrastructureNo servers or clusters to manage
Auto-scalingScale up on demand, scale-to-zero
Secrets HandlingSecure runtime config injection
CI/CD IntegrationAutomated deployment pipelines
Pay-per-useCharged only for execution time
Full ObservabilityLogging, metrics, monitoring

Code Examples

Python

def handler(event, context):
return "hello world"

Node.js

module.exports = {
handler: function (event, context) {
return 'hello world!';
}
}

Go

package kubeless

func Handler(event map[string]interface{}, context map[string]string) (string, error) {
return "Hello world!", nil
}

Java

public class Module {
public String handler(Map event, Map context) {
return "hello world";
}
}

C#

using System;
using System.Collections.Generic;
using System.Threading.Tasks;

public class module
{
public Task handler(Dictionary k8Event, Dictionary k8Context)
{
return Task.FromResult("hello world");
}
}

Troubleshooting

IssueCauseSolution
Stuck deployingInvalid package or runtimeCheck build logs, verify runtime
Invocation errorBug or missing dependencyTest locally, review logs
High cold-start latencyNo minimum instancesSet min instances > 0
Unsupported versionRuntime not availableChoose supported version
CI/CD failedInvalid credentialsVerify API key and URL