Middleware to distribute traffic evenly across multiple backend servers, improving application scalability and availability. 💖
-
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.
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');
});
- 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.
- 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.
- v1.0.0 : 17 March 2024
- v1.0.1 : 18 March 2024
- v1.0.2 : 31 March 2024
- v5.0.0 : 31 March 2024
- Facebook : Oned Ionys
- Instagram : @onedionys
- Twitter : @onedionys
- LinkedIn : @onedionys
- Copyright © 2024 One Dionys
- One Dionys - Load Balancer Middleware is an open source project licensed under the MIT license
Love One Dionys - Load Balancer Middleware? Support this project by donating or sharing with others in need.
Made with ❤️ One Dionys