Skip to content

Latest commit

 

History

History
115 lines (79 loc) · 3.59 KB

README.md

File metadata and controls

115 lines (79 loc) · 3.59 KB

SmartLoadBalancer

Table of Contents

  1. Overview
  2. Features
  3. Architecture
  4. Getting Started
  5. Heartbeat Mechanism
  6. Handling Failures
  7. Diagrams
  8. Contributing
  9. License

Overview

The SmartLoadBalancer is a robust load balancing system that optimizes server traffic distribution through a two-way communication mechanism known as the "heartbeat tactic." It tracks the health of all available servers and routes requests based on server availability, ensuring enhanced system performance and reduced maintenance burdens.

Features

  • Health Monitoring: Continuously tracks the health of backend servers.
  • Dynamic Routing: Routes requests to available servers based on real-time status.
  • Passive Redundancy: Uses Kafka for checkpointing and data communication to handle server failures.
  • Failure Handling: Detects and manages server crashes efficiently.

Architecture

The SmartLoadBalancer operates as a reverse proxy, distributing communication traffic among multiple servers. This not only boosts system performance but also alleviates server maintenance. Smart Load Balancer

Getting Started

Prerequisites

  • Java Development Kit (JDK)
  • Apache Kafka
  • Integrated Development Environment (IDE) such as IntelliJ IDEA or Eclipse

Installation

Installing Kafka (Windows)

  1. Download and Install Apache Kafka: Apache Kafka Downloads

  2. Start the Zookeeper Service:

    .\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties
  3. Start the Kafka Server:

    .\bin\windows\kafka-server-start.bat .\config\server.properties

Installing Kafka (Mac/Linux)

  1. Download and Extract Kafka:

    $ tar -xzf kafka_2.13-3.6.0.tgz
    $ cd kafka_2.13-3.6.0
  2. Start Kafka:

    $ KAFKA_CLUSTER_ID="$(bin/kafka-storage.sh random-uuid)"
    $ bin/kafka-storage.sh format -t $KAFKA_CLUSTER_ID -c config/kraft/server.properties
    $ bin/kafka-server-start.sh config/kraft/server.properties

Running the Application

  1. Start the HeartBeatReceiver:

    Execute the main function in `HeartBeatReceiverUpdated.java`.
  2. Launch Backend Server 1:

    Run `StartBackend1.java`.
  3. Start the Load Balancer:

    Execute the main function in `LoadBalancerUpdated.java`.
  4. Launch Backend Server 2:

    Run `StartBackend2.java`.

Heartbeat Mechanism

As the servers operate, they send heartbeats to the load balancer at regular intervals. This ensures continuous monitoring and synchronization between the servers and the load balancer.

Heartbeat Mechanism Diagram

Handling Failures

In the event of a server failure, triggered by a random integer value, the server may crash and an error message will be generated. The backend will terminate, but the load balancer will continue running, awaiting new server connections.

The load balancer uses Kafka for checkpointing to manage data and ensure the system remains operational with the most active servers.

Diagram:

Passive Redundancy Functionality Diagram - Lucid