Giter Site home page Giter Site logo

j-p-d-e-v / carapace_lb Goto Github PK

View Code? Open in Web Editor NEW
1.0 0.0 0.0 829 KB

A path based load balancer developed using Cloudflare's Programmable Network System Framework called Pingora.

Home Page: https://crates.io/crates/carapace_lb

License: Apache License 2.0

Rust 89.65% HTML 9.96% JavaScript 0.39%
containerization docker docker-compose load-balancer pingora rust rustlanguage vue websocket alb application-load-balancer

carapace_lb's Introduction

Carapace LB - A Path Based Load Balancer

Carapace LB is a path-based load balancer that leverages the Pingora Framework by Cloudflare to manage and route traffic efficiently.

NOTE: I havent included SNI here because I dont have yet a good understanding on how to apply SNI in pingora.

Configuration

Since the application uses Pingora, it also inherit its configurations. To know more about Pingora related configuration, please refer here: https://github.com/cloudflare/pingora/blob/main/docs/user_guide/conf.md

The configuration uses the TOML format. For more details, refer to the TOML documentation.

High Level Diagram

Diagram

[load_balancer]

Configure the load balancer.

Property Description
host The address of the load balancer.
port The port on which the load balancer will listen.
routes_path The file where routes will be saved during service discovery updates.
enable_tls_ssl Set to true to enable TLS/SSL. Set to false to disable TLS/SSL.
ca_crt_path The certficate path for the .crt file.
ca_pem_path The certficate path for the .pem file.
allow_file_types_pattern The regular expression pattern for matching files in the url path.
debug Set to empty string "". If set to "INFO" it will only print minimal info. such as Upstream Address and the URL Path. If set to "DEBUG" it will only print minimal info. such as Upstream Address and all the request information.

Example

[load_balancer]
host="0.0.0.0"
port=6170
routes_path="routes.json"
enable_tls_ssl=true
ca_crt_path="certs/localhost.crt"
ca_pem_path="certs/localhost.pem"
allow_file_types_pattern="[0-9|_|-|A-Z|a-z]*\\.(js|css|png|jpeg|jpg|ico)"
debug="INFO"

[[proxy_services]]

When enabling use_container please make sure that the load balancer has local access to the docker daemon and to the network of the containers.

Configure the proxy services for container discovery based on container labels.

Property Description
container_label_key The key of the container label (used if use_container is set to true).
container_label_value The value of the container label (used if use_container is set to true).
path The URL path to match. If the URL path matches, traffic is routed to this proxy service.
port The port on which the proxy service listens.
use_container Set to true if upstreams are containers. The load balancer should be containerized and in the same network as the containers. Set to false when targeting specific addresses.
host The specific addresses to load balance. Useful if applications are on separate machines.

Example

[[proxy_services]]
container_label_key="cbl.dev.nginx"
container_label_value="groupA"
path = "/"
port = 3101
use_container=false
host = "0.0.0.0"

[[proxy_services]]
container_label_key="cbl.dev.nginx"
container_label_value="groupC"
path="/"
use_container=false
port = 3102
host = "0.0.0.0"

[health_check]

Configure health checks and service discovery.

For more details, refer to the Pingora LoadBalancer documentation.

Property Description
health_check_frequency The interval (in milliseconds) at which health checks are performed.
update_frequency The interval (in milliseconds) at which service discovery is performed.
parallel_health_check Set to false to perform health checks sequentially.

Example

[health_check]
health_check_frequency=1000
update_frequency=1500
parallel_health_check=false

Build

cargo build

Build Specific Platform

cargo build --target=x86_64-unknown-linux-gnu

See rustup target list for the list of platforms.

Test

cargo test -- --nocapture

Run

cargo run

Developer

carapace_lb's People

Contributors

jpmateo022 avatar

Stargazers

LouieMartin 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.