5 releases
Uses new Rust 2024
| 0.4.5 | Oct 21, 2025 |
|---|---|
| 0.4.4 | Oct 21, 2025 |
| 0.3.9 |
|
| 0.3.4 |
|
| 0.1.1 |
|
#1587 in Asynchronous
1,714 downloads per month
Used in jito-client
48KB
1K
SLoC
load-balancer
A set of asynchronous load balancers for Rust, supporting multiple strategies:
- Threshold — limit retries based on failure count.
- Limit — restrict per-node usage per interval.
- Random — randomly choose entries.
- Simple — round-robin sequential allocator.
- Interval — allocate resources on timed intervals.
- Proxy — maintain a proxy connection pool.
Examples
#[tokio::main]
async fn main() {
// Each node can be used at most 2 times, interval 1 second
let lb = LimitLoadBalancer::new(vec![(2, "node 1"), (2, "node 2")]);
let start = tokio::time::Instant::now();
for _ in 0..8 {
let node = lb.alloc().await;
println!("{}s Allocated node: {}", start.elapsed().as_secs(), node);
}
println!("------------------------------");
// Each node can be used at most 4 times, interval 5 second
let lb = LimitLoadBalancer::new_interval(
vec![(3, "node 1"), (1, "node 2")],
Duration::from_secs(5),
);
let start = tokio::time::Instant::now();
for _ in 0..8 {
let node = lb.alloc().await;
println!("{}s Allocated node: {}", start.elapsed().as_secs(), node);
}
}
Output
0s Allocated node: node 1
0s Allocated node: node 1
0s Allocated node: node 2
0s Allocated node: node 2
1s Allocated node: node 1
1s Allocated node: node 1
1s Allocated node: node 2
1s Allocated node: node 2
------------------------------
0s Allocated node: node 1
0s Allocated node: node 1
0s Allocated node: node 1
0s Allocated node: node 2
5s Allocated node: node 1
5s Allocated node: node 1
5s Allocated node: node 1
5s Allocated node: node 2
Dependencies
~7–22MB
~236K SLoC