Giter Club home page Giter Club logo

spring-load-balancer's Introduction

Spring Boot Load Balancer application

Spring Boot application implementing 3 Load Balancer algorithms: Round Robin, Session Persistence & URL Mapping.

Build

From project root directory

  • Pure Maven: mvn clean package

Run

  • Built jar file (./target dir): java -jar landing-1.0.jar [--port=<port>] [--mode=<mode>] [--config=<filename(s)>]
  • Spring Boot Maven plugin (root dir): mvn spring-boot:run [-Drun.arguments=[--port=<port>],[--mode=<mode>],[--config=<filename(s)>]]

Arguments:

port - application server port. Default: 8080
mode - Load Balancer mode:

  • round_robin - Round Robin
  • session_persistence - Session Persistence (Default mode)
  • url_mapping - URL Mapping

config - Config file with list of endpoints on each line (overrides properties file):

http://localhost:8081 - Round Robin & Session Persistence endpoint example
http://localhost:8081/api/music - URL Mapping endpoint example

Application properties

application.properties

  • spring.profiles.active - application profile. Current: dev. Change to prod if running in Production mode.
  • server.port - application default server port.
  • loadbalancer.mode - Load Balancer mode. See arguments above.

application-dev.properties / application-prod.properties

For the current version this file contains only a list of endpoints:
loadbalancer.endpoints[0].host=localhost
loadbalancer.endpoints[0].port=8081
loadbalancer.endpoints[0].path=/api/music

Application modes

Round Robin

With a new request the next endpoint in the list is fetched (cyclically).

To use this algorithm, provide at least one endpoint with a host & port.

Session Persistence

The same algorithm as Round Robin except that a specific endpoint is saved for each session.
As the result, while session is alive, all user requests are sent to one backend server.

To use this algorithm, provide at least one endpoint with a host & port.

URL Mapping

Backend servers are mapped to URI paths.
For example: every request like curl http://example.com:8080/api/music will be redirected to one backend server while curl http://example.com:8080/api/video will be redirected to another.

To use this algorithm, provide at least one endpoint with a host, port & path.

spring-load-balancer's People

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.