Skip to content

unimib-datAI/dfaas

Repository files navigation

DFaaS: Decentralized Function-as-a-Service for Federated Edge

This repository holds DFaaS, a novel decentralized FaaS-based architecture designed to automatically and autonomously balance the traffic load across edge nodes belonging to federated Edge Computing ecosystems.

DFaaS implementation relies on an overlay peer-to-peer network and a distributed control algorithm that takes decisions on load redistribution. Although preliminary, our results confirm the feasibility of the approach, showing that the system can transparently redistribute the load across edge nodes when they become overloaded.

Our prototype is based on OpenFaaS and implements the control logic within Go P2P agents.

This research is conducted by the DatAI (formerly Insid&s) and REDS laboratories of the University of Milan-Bicocca.

If you wish to reuse this source code, please consider citing our article describing the first prototype:

@inproceedings{Ciavotta_DFaaS_2021,
    author = {Ciavotta, Michele and Motterlini, Davide and Savi, Marco and Tundo, Alessandro},
    doi    = {10.1109/CloudNet53349.2021.9657141},
    pages  = {1--4},
    series = {2021 IEEE 10th International Conference on Cloud Networking (CloudNet)},
    title  = {{DFaaS: Decentralized Function-as-a-Service for Federated Edge Computing}},
    url    = {https://ieeexplore.ieee.org/document/9657141},
    year   = {2021}
}

Scenario

Scenario

The above figure depicts the considered network scenario. A set of geographically-distributed FaaS-enabled edge nodes (or simply edge nodes) is deployed at the edge of the access network.

Each of these nodes deploys a DFaaS platform for the execution of serverless functions, and is connected to a wireless or wired access point (e.g. a base station, a broadband network gateway, a WiFi access point, etc.).

The edge node can receive functions' execution requests, in the form of HTTP requests, generated by the users served by the access point.

Architecture

Architecture

How to run DFaaS

DFaaS is currently in a prototypal stage. It uses HAProxy for the proxy component and OpenFaaS as the FaaS platform. The only supported deployment method is on Kubernetes.

You can install and deploy the DFaaS prototype on a single node using two options:

You can install and deploy the DFaaS prototype on a single node with two options:

  1. Automated deployment with Ansible (WIP): use the provided Ansible playbook to automatically build and deploy a node. This can be done either on the machine running Ansible or on a remote machine.

  2. Manual deployment: build and deploy the node manually by executing each required command step-by-step.

Regardless of which of the options you choose, the deployment of the DFaaS prototype has been tested with Ubuntu 24.04.2 LTS.

We suggest to spin up a virtual machine from scratch with Ubuntu, with a user with a password and sudo enabled.

Automated deployment with Ansible

Warning

We are rewriting the Ansile playbook, currently this method is not available.

Install Ansible on the control node following the official documentation (use the Ansible PPA). Then use the provided playbook setup_playbook.yaml to deploy a DFaaS node on a specific managed node specified in an inventory file. Note that you can specify multiple managed nodes.

An example of inventory.yaml file is

all:
  hosts:
    <node-name>:
      ansible_host: <ip_address>
      ansible_user: <user>
      ansible_password: <password>
      ansible_become: true

We assume that the managed node has a user with root privileges and can connect via SSH with a password. This is for testing purposes only!

To test the inventory, you can try the example playbook on the official Ansible documentation.

Important: on the control node you need to have the DFaaS Git repository and to build the DFaaS Agent. This can be done with the following:

$ git clone https://github.com/unimib-datAI/dfaas.git
$ sudo apt install golang-go
$ go build -C dfaas/dfaasagent

Then you can run the playbook with ansible-playbook (make sure to be on the DFaaS directory!):

$ ansible-playbook -i inventory.yaml setup_playbook.yaml

This deploys a basic, fully functional DFaaS node using the Node Margin Strategy.

You can make automatic calls to the node with the operator. More information about it in the dedicated directory.

If you have four different VMs it's recommended to deploy the entire system exploiting the playbook and configuration files in test_environment. This is still a work in progress.

Manual deployment

This deployment setup is ideal for a single node on the host machine without using Ansible. The only requirement is Ubuntu. Clone the DFaaS Git repository and run the k8s/scripts/init-k3s.sh script. This will install and start a K3S cluster, Helm, faas-cli, and all Helm charts—but not the DFaaS Agent.

$ git clone https://github.com/unimib-datAI/dfaas.git
$ cd dfaas
$ k8s/scripts/init-k3s.sh

Next, install the Helm chart for the DFaaS Agent. You can overwrite the default values in k8s/charts/agent/values.yaml:

$ sudo helm install dfaas-agent ./k8s/charts/agent/ --values test-node-1.yaml

Deploy functions

Use the k8s/scripts/deploy-functions.sh script to automatically deploy the default function to the local DFaaS instance. If you used the Ansible playbook or the custom init script, this step is not required.

Invoke a function

Each node exposes HAProxy with port 30080 on the node's IP address. Only http protocol is supported. You can use any program to make a call, as example:

$ curl -i http://127.0.0.1:30080/function/figlet -d 'Hello DFaaS world!'

Execute workload to a node using vegeta

Warning

Outdated information. We are rewriting this section!

We provide an example that use vegeta HTTP load testing tool to run workload on a node and demonstrate the load distribution over the federation.

You can install vegeta by executing the following commands:

wget https://github.com/tsenart/vegeta/releases/download/v12.8.4/vegeta_12.8.4_linux_amd64.tar.gz
tar -xf vegeta_12.8.4_linux_amd64.tar.gz && rm vegeta_12.8.4_linux_amd64.tar.gz
sudo mv vegeta /usr/local/bin/

This example uses the vegeta json format and requires jq.

In a nutshell:

  • it runs a vegeta attack (duration: 5 minutes, rate: 50 req/s) to the figlet function on the first node
  • it saves the results and produces report ever 200ms
# Create the vegeta results directory
mkdir -p vegeta-results
export VEGFOLDER="vegeta-results/$(date +%Y-%m-%d-%H%M%S)"
mkdir -p $VEGFOLDER

jq -ncM '{method: "GET", url: "http://localhost:8081/function/figlet", body: "Hello DFaaS world!" | @base64, header: {"Content-Type": ["text/plain"]}}' | \
  vegeta attack -duration=5m -rate=50 -format=json | \
  tee $VEGFOLDER/results.bin | \
  vegeta report -every=200ms

You can also start multiple parallel Vegeta attacks exploiting operator functionalities.

Create plots from vegeta results

You can produce some plots from vegeta results by exploiting the vegeta plot command or our plot-results.py script, which is automatically executed after tests execution with the operator. To use our script, you need to install the required Python packages listed in plot-requirements.txt.

# Encode results as JSON
cat $VEGFOLDER/results.bin | vegeta encode > $VEGFOLDER/results.json

# Create plot with vegeta
cat $VEGFOLDER/results.bin | vegeta plot > $VEGFOLDER/plot.html

# 1st arg: path  results.json
# 2nd arg: path output folder
# 3rd arg: rate req/s used for the attack (if merged is True specify rate=0)
# 4th arg: boolean merged (is the input file merged from multiple attacks?)
./operator/docker/files/plot-results.py $VEGFOLDER/results.json $VEGFOLDER/plots 50 False

Forwarding traffic as a malicious node

You can impersonate a malicious node that is not part of the federation by adding the header Dfaas-Node-Id with a value that is not a valid peer id of the network (e.g., Dfaas-Node-Id: malicious-id). All of its requests will be rejected.

Troubleshooting

See and follow the logs of the DFaaS Agent on the local instance:

$ POD=$(sudo kubectl get pods -l app=dfaas-agent -o jsonpath="{.items[0].metadata.name}")
$ sudo kubectl logs --follow $POD

Emulator

For a complex setup running several emulated edge nodes with different topologies see emulator directory. We provide instructions and examples to execute DFaaS nodes via Containernet emulator.

Simulator

We also provide a simulator to test and compare different load balancing techniques. The simulation code is available into the simulation directory. Data gathered by the DFaaS system used for simulation are available here.

For more information read associated README file.

License

Copyright © 2021-2025 The DFaaS Authors.

The source code in this repository is licensed under the GNU Affero General Public License (AGPL), version 2.0 or later. See the LICENSE file for more information.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

The complete list of The DFaaS Authors can be fond in the AUTHORS file or in the contributors page on the DFaaS GitHub repository.

About

Decentralized FaaS platform

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 10