Server side load-balancer microservice using Spring Boot
260
A server-side load-balancer for distributing the trafic among the web servers.
A server-side load-balancer for distributing the trafic among the web servers based on the selected server by using dynamic load balancing algorithm(Weighted Least Connections).
For details implementation see š documentationā
Java Spring Spring Boot HibernateInstall Docker in your system (follow the link for Docker Desktop installation) : Docker Desktopā
Pull the image from docker hub :
docker pull santanupal/loadbalancer:latest
Run the docker image you pulled from docker hub :
[P.S: Replace <host-port> by a port-no you want to run it ]
docker run -it -d -p <host-port>:9000 santanupal/loadbalancer
You can see logs of the application. [P.S: Replace <container-id> by a port-no you want to run it ]:
docker logs <container-id>
Now you are all set. [P.S: Replace <host-port> by port-no you used in step 3 ]
your base url will be http://localhost:<host-port>
The load balancer provides various endpoints for managing server cache and balancing web requests.
http://<yout-host-url>
š endpoints To send request for balancing load : /lb
http://<your-host-url>/lb/myexample.comš Other endpoints for managing server cache . . . . .
/api/servers curl -X GET "http://<your-host-url>/api/servers"
/api/servers curl -X POST "http://<your-host-url>/api/servers" -H "Content-Type: application/json" -d '{
"serverIp": "192.168.136.2",
"port" : 8080,
"maxWeight": 10,
"serverUrl": "https://myserver.example.com"
}'
NOTE: Ensure to replace {serverId} with the actual server ID when making requests to the PUT and DELETE endpoints.
/api/servers/{serverId} curl -X PUT "http://<your-host-url>/api/servers/{serverId}" -H "Content-Type: application/json" -d '{
"port" : 5050,
"weight": 15
}'
/api/servers/{serverId} curl -X DELETE "http://<your-host-url>/api/servers/{serverId}"
GitHub: Santanu Palā
Content type
Image
Digest
sha256:ef2e52550ā¦
Size
127.3 MB
Last updated
about 2 years ago
docker pull santanupal/loadbalancer