This repository includes simple L7 round robin loadbalancer implementation, instrumented with metrics.
WARNING
: This is not meant to be production ready L7 loadbalancer. It's missing things like proper retrying, DNS discovery, logging, tracing etc, that might be added in future (:
This implementation was mainly used for presentations that showcase best practices for Prometheus based metrics Go instrumentation like:
- Avoiding globals.
- Middlewares and Tripperwares.
- Histograms usage.
- Avoiding high cardinality.
- Initialising metrics.
- Wrapping registries.
- Naming conventions
- Testing metrics
This demo is runable.
To run loadbalancer and Prometheus in docker run:
make demo
After this, you should be able to go via browser to:
http://localhost:8080/lb
for load balancing endpoint, that loadbalanced to 3 fake endpoints.http://localhost:8080/metrics
for metric pagehttp://localhost:9090
for Prometheus UI that scrapes loadbalancer every second.
To curl loadbalancer every 500ms to generate traffic run in separate terminal:
make demo-test