Skip to content

heysubinoy/cutelb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cutelb 🐰

A cute, lightweight HTTP load balancer written in Haskell.

Features

  • Multiple Load Balancing Strategies

    • Round Robin
    • Weighted Round Robin
    • Least Connections
    • Random
    • Least Response Time
  • Flexible Routing

    • Exact path matching
    • Prefix matching
    • Regex matching
  • Configuration

    • YAML-based configuration
    • Multiple upstream definitions
    • Optional access and error logging

Installation

Requires GHC and Cabal. Using Nix is recommended:

# With Nix
nix-shell

# Build
cabal build

# Run
cabal run cutelb -- config.yaml

Configuration

server:
  listen: 3000
  access_log: ./access.log  # optional
  error_log: ./error.log    # optional

upstreams:
  my_backend:
    strategy: round_robin  # or: weighted_round_robin, least_conn, random, least_response_time
    servers:
      - host: localhost
        port: 8001
      - host: localhost
        port: 8002
        weight: 2  # optional, for weighted_round_robin

routes:
  - path: /api
    upstream: my_backend
    match_type: prefix  # or: exact, regex

Usage

# Run with default config.yaml
cabal run cutelb

# Run with custom config
cabal run cutelb -- path/to/config.yaml

Testing

Start test backend servers:

python3 test/test_servers.py --test

Then run the load balancer:

cabal run cutelb -- test/config.yaml

Test with curl:

curl localhost:3000/api

License

MIT

About

A Haskell-based Load Balancer

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors