Overview
The HTTP Load Balancer is currently configured through code in the main entry point. All settings including backend URLs, health check intervals, and port configuration are defined insrc/index.ts.
Configuration file support (YAML/JSON) is on the roadmap for future releases. Track progress in the project’s possible extensions.
Backend server configuration
Backend servers are currently hardcoded as an array of URLs in the main application file.Define backend URLs
Edit the
backendUrls array in src/index.ts to specify your backend servers:src/index.ts
Initialize the backend pool
The backend pool is automatically created from the URL array:
src/index.ts
Health check configuration
Health checks are configured when initializing theHealthChecker class.
Check interval
The second parameter toHealthChecker sets the interval between health check cycles (in milliseconds):
src/index.ts
Request timeout
Each health check request has a 3-second timeout, enforced viaAbortController. This is currently hardcoded in src/healthchecker/healthChecker.ts:22:
src/healthchecker/healthChecker.ts
3000 value to your desired timeout in milliseconds.
Port configuration
The load balancer listens on port 3000 by default. To change this, modify thePORT constant:
src/index.ts
Load balancing strategy
The load balancing algorithm is configured via the Strategy Pattern. Currently, only Round Robin is implemented:src/index.ts
LoadBalancer constructor.
Future: Configuration file support
Configuration file support is planned for a future release. The proposed format:config.yaml