therealak12 / alb

Yet another Load Balancer using BPF

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bfp load balancer

Notes

  1. The project is inspired by lizrice lb from scratch and katran

  2. ALB uses xdp-generic mode. Using xdp-native mode requires extra work such as attaching a dummy xdp_pass program to all involved interfaces. Refer to this for more explanation.

Structure

ALB Structure

Prerequisites

Install bpf2go

go install github.com/cilium/ebpf/cmd/bpf2go@latest

Install libbfp

git clone https://github.com/libbpf/libbpf.git /tmp/libbpf
cd /tmp/libbpf/src
make -j`nproc`
BUILD_STATIC_ONLY=1 NO_PKG_CONFIG=1 make install

Install bpftool

rm /usr/sbin/bpftool

apt update && apt install -y git
cd / && git clone --recurse-submodules https://github.com/libbpf/bpftool.git

cd bpftool/src
make install

ln -s /usr/local/sbin/bpftool /usr/sbin/bpftool

Generate bpf2go boilerplate

make generate

Develop

Setup environment

make setup-dev-env

Run

make run-in-ns NS=alb

Send Request to ALB

Make sure http servers are listening on port 80 in ns1 and ns2, then run:

sudo ip netns exec client curl 172.16.31.2

Clean environment

make clean-dev-env

About

Yet another Load Balancer using BPF


Languages

Language:Go 39.7%Language:C 26.8%Language:Shell 25.9%Language:Makefile 7.6%