-
Start the loadbalancer by running the file
lb.py
python3 lb.py
-
Start the backend servers by running the file
be.py
python3 be.py <port>
-
You can start multiple instances of the server by running it on different ports
-
Make a request to the loadbalancer
lb.py
contains the loadbalancer that runs a TCPServer and forwards the requests to the list of healthy serversbe.py
contains a demo backend server that again starts a TCPServer at the specified port and responds to requests with a generic messagehealth.py
contains the health check loop that checks the health of the available servers every x secondsstrategy
Contains theServerSelectionStrategy
base class to choose the next server from the list of availabe ones