A HTTP 1.1 load balancer written in Rust using tokio.
Rust
Latest commit 8ddd6ea Feb 25, 2017 @yanns yanns committed on GitHub Merge pull request #77 from yanns/fix_tests
run the tests against the http server & against the proxy

README.md

Build Status

Weldr

A HTTP 1.1 reverse proxy written in Rust using hyper (tokio version).

Design

The goal is to build an AWS ELB-like reverse proxy that works well in the dynamic VM/container environments that are starting to be more common. Of particular focus is the ability to manage origins from the pool via some API.

An eventual goal is to have the pool managed by Raft. This will allow a cluster of redundant weldr servers. This will allow an active/passive setup out of the box. Note: The raft-rs crate does not currently support dynamic membership.

Running Protype

  • RUST_LOG=weldr cargo run --bin weldr - start the proxy
  • cargo run --bin test-server - start test origin server
  • curl -vvv localhost:8080 - send a request
  • curl -vvv localhost:8080/large - send a request and get back a large response

Running Tests

RUST_LOG=test_proxy,weldr cargo test will execute the tests and provide log level output for both the proxy and the integration tests.

High Level Roadmap

  • Initial [0.1.0] release.
  • Currently working on a 0.2.0 release.

Proposed Management API Design

The management API will allow the addition and removal of origins from the pool. It will also allow for the dynamic configuration of other options, such as the health check.

Adding A Server

  • Servers must register with the load balancer using an HTTP POST to the management IP.
    • The POST payload contains the health check information.
  • The load balancer will keep that server active in the pool as long as the health succeeds.
POST /servers

{
   "ip": "120.0.0.1",
   "port": "8080",
}

Example: curl -vvv localhost:8687/servers -d '{"ip":"127.0.0.1", "port":"12345"}'

Removing A Server

Note: It is more common for a server to fall out of the pool after n health checks fail.

DELETE /servers/:ip/:port

Example: curl -vvv -X DELETE localhost:8687/servers/127.0.0.1/12345

Stats

Work in progress.

GET /stats
{
   "client": {
      "success": 34534,
      "failed": 33,
   },
   "server": {
      "success": 33770,
      "failed": 15,
   }
}

Detailed Stats

Work in progress.

GET /stats/detail
[{
   "id": "...",
   "ip": "127.0.0.1",
   "port": "8080",
   "success": 33770,
   "failed": 15,
},{
   ...
}]

Acknowledgements

  • @hoverbear - for talking through some of the design with me early on
  • @Geal - for talking through some of the design with me early on and sharing code samples
  • @yanns - for setting up the integration tests and implementation help

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.