How akshaynkotkar/calculator-load-balancer works
Project Type & Purpose
• This is a full-stack backend application (with a minimal front-end for demonstration) focused on arithmetic operations performed via REST endpoints.
• The unique aspect is the load balancing mechanism: distributing incoming calculation requests among multiple server instances using various algorithms (round robin, least connections, etc.).
• Important frameworks/technologies include Spring Boot, Spring Cloud LoadBalancer, Maven, and Java (targeting Java 17 or higher).
Main Components
• Clients: External users or applications making HTTP requests (e.g., via a browser or curl).
• Load Balancer: The critical component that encapsulates:
– Health Monitor (Periodic checks of server status)
– Request Distributor (Implements load balancing algorithms to route requests)
– Server Selector (Decides which server instance should handle the incoming request)
• Server Instances: The calculator service running on multiple “instances”. Even though the codebase is the same (as seen in the controller and service packages), the load balancer simulates distribution among them.
• Application layers within the server instance:
– Controller: REST endpoints that expose calculator functions.
– Service: Business logic that performs the actual arithmetic operations.
– Configuration: Setup for load balancing specifics (via the config package).
Relationships and Interactions
• That clients send HTTP requests (for addition, subtraction, etc.) to the Load Balancer.
• The Load Balancer takes these requests, performs health checks and evaluation of the available server instances, then routes the request to one of them.
• Once a request is processed, the response is sent back through the load balancer to the client.
Architectural Patterns & Key Design Principles
• Microkernel with plug-in components: Each part (controller, service, config) works together to support load balancing.
• Separation of Concerns: Different Java packages manage distinct functionality (REST controllers for endpoints, services for computation, and configuration for load balancing algorithm).
• Fault Tolerance: Implementation of the circuit breaker and health checks to ensure high availability.
• Scalability: The ability to register/deregister server instances dynamically contributes to overall system resiliency.
Technologies, Frameworks, and Libraries
• Spring Boot for rapid application development.
• Spring Cloud LoadBalancer for client-side load balancing.
• Maven for dependency and build management.
• Circuit breaker pattern (likely using Resilience4j or similar) for fault tolerance.
• Java 17 as the language/runtime.