Git Product home page Git Product logo

lb-from-scratch's Introduction

An eBPF Load Balancer from scratch

As seen at eBPF Summit 2021. This is not production ready :-)

This uses libbpf as a git submodule. If you clone this repo you'll need to run git submodule init and git submodule update to get your copy of that repo.

Load Balancer container

In my demo I'm running all the components as containers. For the Load Balancer component itself I created an image locally by running an ubuntu container and adding dependencies so that it can compile the eBPF code:

sudo apt install clang llvm libelf-dev libpcap-dev gcc-multilib build-essential make

Save this image off with docker commit <running container> ubuntu-working. Running it as privileged gives it permissions to load eBPF programs:

docker run --rm -it -v ~/lb-from-scratch:/lb-from-scratch --privileged -h lb --name lb --env TERM=xterm-color ubuntu-working

Exec into that container, cd lb-from-scratch and then make should build and install the load balancer onto the eth0 interface for that container.

Demo containers

Here's how I started the containers for the two backends and the client:

docker run -d --rm --name backend-A -h backend-A --env TERM=xterm-color nginxdemos/hello:plain-text
docker run -d --rm --name backend-B -h backend-B --env TERM=xterm-color nginxdemos/hello:plain-text
docker run --rm -it -h client --name client --env TERM=xterm-color ubuntu

Exec into one of the backends and install tcpdump with apk add tcpdump if you want to see incoming traffic there.

Run something on the host that tails the output from BPF trace (for example, my hello world eBPF beginners examples)

IP addresses

The IP addresses for the client, load balancer and two backends are hard-coded at the top of the .c file. You'll likely need to change these to match the addresses assigned to the containers you run.

lb-from-scratch's People

Contributors

lizrice avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.