onedionys-load-balancer-middleware

5.0.0 • Public • Published

Welcome to One Dionys - Load Balancer Middleware! 👋

Middleware to distribute traffic evenly across multiple backend servers, improving application scalability and availability. 💖

💾 Requirements

  • Web Browser - Can be used as an emulator to build applications. Example [Chrome, Firefox, Safari & Opera].
  • Internet - Because many use CDN and to make it easier to find solutions to all problems.

🎯 How To Use

Example Syntax

const express = require('express');
const loadBalancerMiddleware = require('./src/loadBalancerMiddleware');

const app = express();

const servers = [
    { url: 'http://server1.com', weight: 1 },
    { url: 'http://server2.com', weight: 2 },
    // Add more servers as needed
];

app.use(loadBalancerMiddleware(servers));

// Add your routes and other middleware here

app.listen(3000, () => {
    console.log('Server is running on port 3000');
});

Explanation

  • This middleware implements a basic load balancing algorithm to distribute incoming requests among multiple servers. It takes an array of server objects, each containing the server URL and its weight. The middleware then routes requests to the servers based on their weights.

Return Value

  • The middleware function returns an Express middleware function that can be used in an Express application. This middleware should be placed early in the middleware stack to ensure that all requests are properly load balanced before reaching other middleware or route handlers.

📆 Release Date

  • v1.0.0 : 17 March 2024
  • v1.0.1 : 18 March 2024
  • v1.0.2 : 31 March 2024
  • v5.0.0 : 31 March 2024

🧑 Author

📝 License

  • Copyright © 2024 One Dionys
  • One Dionys - Load Balancer Middleware is an open source project licensed under the MIT license

☕️ Suppport & Donation

Love One Dionys - Load Balancer Middleware? Support this project by donating or sharing with others in need.

Made with ❤️ One Dionys

Package Sidebar

Install

npm i onedionys-load-balancer-middleware

Weekly Downloads

2

Version

5.0.0

License

ISC

Unpacked Size

12.5 kB

Total Files

6

Last publish

Collaborators

  • onedionys