A high-performance, scalable load balancer built with modern distributed systems principles
-
🔄 Multiple Load Balancing Algorithms
- Round Robin
- Weighted Round Robin
- Least Connections
- IP Hash
- Health Check-based routing
-
⚡ High Performance
- Async/non-blocking I/O with ZIO
- Efficient connection pooling
- Minimal latency overhead
-
🔧 Configuration-Driven
- YAML/JSON configuration
- Environment-based configs
-
link to demo Demo
- Java 11+
- SBT 1.x
- Docker (optional)
git clone https://github.com/Yummy-Yums/load-balancer.git
cd load-balancer
sbt compileCreate a application.conf file:
Application {
port = 8080
host = "localhost"
backends=[
"http://127.0.0.1:8081",
"http://127.0.0.1:8082",
"http://127.0.0.1:8083"
]
health-check-interval = 3
}Distributes requests evenly across all healthy backends.
LoadBalancer.roundRobin(backends)Access health status at /health:
curl http://localhost:8080/healthsbt test├── build.sbt
├── lb
├── lb.jar
├── project
│ ├── build.properties
│ ├── metals.sbt
│ ├── plugins.sbt
│ ├── project
│ └── target
├── readme.md
├── src
│ ├── main
│ └── test
libraryDependencies ++= Seq(
"dev.zio" %% "zio" % "2.0.21",
"dev.zio" %% "zio-http" % "3.0.0-RC4",
"dev.zio" %% "zio-config" % "4.0.0-RC16",
"dev.zio" %% "zio-json" % "0.6.2",
"dev.zio" %% "zio-metrics-prometheus" % "2.0.8",
"dev.zio" %% "zio-logging" % "2.1.16"
)We use Scalafmt for code formatting:
sbt scalafmtThis project is licensed under the MIT License - see the LICENSE file for details.