4 releases

0.1.3 Aug 4, 2024
0.1.2 Jul 29, 2024
0.1.1 Jul 29, 2024
0.1.0 Jul 28, 2024

#1003 in HTTP server

MIT license

17KB
243 lines

Ferrugem Load Balancer

A lightweight and efficient load balancer implemented in Rust.

Overview

This project is a load balancer built using the Rust programming language and the Axum web framework. It is designed to be efficient and lightweight, capable of distributing incoming HTTP requests across multiple backend servers.

Features

  • Efficiently handles incoming HTTP requests and routes them to backend servers.
  • Logs incoming requests and responses for easy debugging and monitoring.
  • Configurable logging levels to control the amount of logged information.
  • Utilizes the reqwest library for making HTTP requests to backend servers.
  • Thread-safe, using tokio::sync::Mutex for state management.

Getting Started

Prerequisites

  • Rust (latest stable version recommended)
  • Cargo (Rust package manager)
  • Git

or

  • Docker

Usage with Docker

docker run -p 9999:9999 -v $(pwd)/ferrugem.toml:/usr/local/bin/ferrugem.toml erickcestari/ferrugem

Installation

  1. Clone the repository:

    git clone https://github.com/erickcestari/ferrugem.git
    cd rust-load-balancer
    
  2. Build the project:

    cargo build --release
    
  3. Run the load balancer:

    cargo run --release
    

Configuration

The load balancer can be configured using a ferrugem.toml struct. Below is an example configuration:

port = 9999
log_level = 'info'
algorithm = 'round-robin'

[[servers]]
name = "api1"
url = "https://jsonplaceholder.typicode.com"

[[servers]]
name = "api2"
url = "https://jsonplaceholder.typicode.com"

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests to improve the project.

License

This project is licensed under the MIT License.

Dependencies

~8–19MB
~270K SLoC