Sign inSign up

santanupal/loadbalancer

By santanupal

•Updated about 2 years ago

Server side load-balancer microservice using Spring Boot

Image
Networking
Web servers
0

260

santanupal/loadbalancer repository overview

⁠LoadBalancer Microservice

A server-side load-balancer for distributing the trafic among the web servers.


⁠About The Project

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⁠

⁠Built With
  • Java Spring Spring Boot Hibernate

⁠Table of Contents

⁠Features

  • Dynamic load balancing algorithm for better efficiency .
  • Secured endpoints to manage server-cache (add, update, delete server info) .
  • Continuously monitored servers' health .
  • Supported multithreading and concurrency for handling incoming web requests .
  • Achieved containerization for scalability and portability .
  • Deployed on cloud for real-time use .

⁠Installation

⁠Using Docker šŸ‘‡ :
  1. Install Docker in your system (follow the link for Docker Desktop installation) : Docker Desktop⁠

  2. Pull the image from docker hub :

    docker pull santanupal/loadbalancer:latest
    
  3. 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
    
  4. 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>
    
  5. 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>

⁠Usage

The load balancer provides various endpoints for managing server cache and balancing web requests.

  • The base URL for sending requests to the load balancer is:
 http://<yout-host-url>
⁠Endpoints šŸ‘‡

šŸ‘‰ endpoints To send request for balancing load : /lb

  • example: http://<your-host-url>/lb/myexample.com

šŸ‘‰ Other endpoints for managing server cache . . . . .

  1. Retrieve All Servers: GET /api/servers
  • Returns a list of all servers in the cache.
  • For terminal usage, to make a GET request :
 curl -X GET "http://<your-host-url>/api/servers"
  1. Add a Server: POST /api/servers
  • Add a new server to the cache.
  • For terminal usage, to make a POST request :
 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.

  1. Update a Server: PUT /api/servers/{serverId}
  • Updates an existing server's information in the cache.
  • For terminal usage, to make a PUT request :
 curl -X PUT "http://<your-host-url>/api/servers/{serverId}" -H "Content-Type: application/json" -d '{
  "port" : 5050,
  "weight": 15
}'
  1. Delete a Server: DELETE /api/servers/{serverId}
  • Deletes an existing server's information in the cache.
  • For terminal usage, to make a DELETE request :
 curl -X DELETE "http://<your-host-url>/api/servers/{serverId}"

ā šŸ¤ Author

GitHub: Santanu Pal⁠

Tag summary

Content type

Image

Digest

sha256:ef2e52550…

Size

127.3 MB

Last updated

about 2 years ago

docker pull santanupal/loadbalancer