- Client Conn -> Proxy -> [Backend pool selected server]
- Client Conn <- Proxy <- [Backend pool selected server]
Server handles connection forwarding to pool, based on policy.
- Round robin - Done
- Least Active connection policy
- Location Based Routing
- Layer 4 TCP LB
- Runtime addition and removal of servers from server pool
- Retiring and bringing back servers on transient deaths into active backend pool.
- Topology is managed by using pub sub with redis. This was a workaround for writing a management operations API server for the Load balancer,and being able to use prebuilt clients such as telnet for managing the load balancer.
- Every incoming connection is a fire and forget task on the thread pool.
- Each connection uses a policy to find an active server in the backend pool before proxying traffic.
- Run a Redis Server For config Management on Localhost 6379
- Use telnet or another Redis Client REPL to manage addition, removal, and reading the servers in the backend pool for the load balancer.
- Create an initial key value in Redis for servePool (I use telnet):
set serverPool '["127.0.0.1:6000","127.0.0.1:3000","127.0.0.1:4000"]'
- Run the Load balancer as it's own process.
- Now during runtime to add a new server
publish addServer 127.0.0.1:5000
- To remove a serve during runtime.
publish removeServer 127.0.0.1:5000
- To see the actively being used serverPool during runtime.
get serverPool