A simple API Gateway built with round-robin and least connection load balancing algorithms. This gateway includes Prometheus for monitoring and Grafana for visualization.
- Round-robin load balancing: Distributes requests evenly across backend services.
- Least connection load balancing: Routes requests to the backend service with the fewest active connections.
- Prometheus integration: Exposes metrics for monitoring.
- Grafana integration: Visualizes Prometheus metrics.
- Health checks: Regular health checks for backend services.
- API Gateway: Custom gateway written in [Golang].
- Load Balancer Algorithms: Round-robin and least connection.
- Monitoring:
- Prometheus: Metrics collection from the API gateway.
- Grafana: Visualization of metrics.
- Containerization: Docker and Docker Compose.
- Docker: Make sure you have Docker installed. Install Docker.
- Docker Compose: Ensure Docker Compose is installed. Install Docker Compose.
.
├── docker-compose.yml # Docker Compose configuration file
├── etc/prometheus.yml # Prometheus configuration\
└── README.md # Project documentation
-
Clone the repository:
git clone https://github.com/zakirkun/yae-miko.git cd yae-miko
-
Update configuration files:
- Adjust any settings inside
etc/prometheus.yml
if needed.
- Adjust any settings inside
-
Start services using Docker Compose:
docker-compose up --build
This will start:
- The API Gateway with round-robin and least connection load balancing
- Prometheus for monitoring the gateway
- Grafana for visualizing metrics
-
Access services:
- API Gateway:
http://localhost:3333
- Prometheus:
http://localhost:9090
- Grafana:
http://localhost:3000
- API Gateway:
- Round-robin: Distributes incoming requests in a circular order to the available services.
- Least connection: Routes the request to the server with the least number of active connections.
Prometheus is used to scrape metrics from the API gateway. Metrics are available at the /metrics
endpoint of the gateway.
- Prometheus URL:
http://localhost:9090
- Default scrape interval: 15s
- Configuration file:
etc/prometheus.yml
Grafana is set up to visualize Prometheus metrics. Pre-configured dashboards can be customized according to your needs.
- Grafana URL:
http://localhost:3000
- Default credentials:
admin/admin
- You can import dashboards using the Grafana UI or add custom ones.
The docker-compose.yml
defines three services:
- yae_miko_cluster: The main gateway application.
- prometheus: Prometheus service for collecting metrics.
- grafana: Grafana service for visualizing the metrics.
- Configure the load balancing algorithms (round-robin, least connection) in the gateway's configuration file.
You can test the API gateway with a simple curl
command:
curl -X GET http://localhost:3333/
Grafana dashboards are set up to visualize:
- Request rates
- Latency per backend
- Active connections (least connection)
- Gateway response codes
Feel free to submit issues or contribute by creating pull requests. Contributions are always welcome!
This project is licensed under the MIT License - see the LICENSE file for details.