How vkanaparthy/loadbalancer works
Project type and purpose
• This is a small L4 load-balancer project (“loadbalancer”) that implements both a control plane (configuration via an API server) and a data plane (packet forwarding in Go).
• The README says only “L4 loadbalancer,” and the files show Python for the API/client side and Go for the core balancing logic.
File structure
• Top‐level files:
• apiserver.py – Python service exposing REST endpoints to add/remove backends or change strategy
• client.py – Python CLI or interactive client to call the API server
• main.go – Go entry point: starts the L4 proxy listener and dispatch loop
• strategy.go – Go code implementing various load-balancing algorithms (e.g., round robin)
• go.mod, go.sum – Go module definitions/configuration
• No separate “frontend”/“backend” folders; instead the control plane is in Python and the data plane in Go.
README for additional insights
• Very terse; implies that the core is the L4 proxy and that configuration is dynamic.
Detail
• Strategy module to show that it implements an interface (e.g., “SelectNextBackend()”).
• Concurrency in main.go (e.g., Go routines listening per connection).
• Module boundaries: Python side can be independently tested or extended without touching Go code.