Feature/add load balancing#5727
Open
jakubstrama wants to merge 3 commits into
Open
Conversation
|
Docker Image for build 2 is available on DockerHub: Note Ensure you backup your NPM instance before testing this image! Especially if there are database changes. Warning Changes and additions to DNS Providers require verification by at least 2 members of the community! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Nginx supports upstream load balancing via
upstream {}blocks, allowing a proxy host to distribute traffic across multiple backend servers. Currently, NPM only supports a singleforward_host:forward_porttarget per proxy host, with no way to configure multiple servers or a balancing strategy.This PR adds full Nginx upstream load balancing support to proxy hosts.
Balancing methods (mapped to Nginx directives)
least_conn;ip_hash;Per-server parameters
weight— relative request weight for round-robin distributionmax_fails/fail_timeout— passive health check thresholdsbackup— receive requests only when all primary servers are downdown— permanently mark a server unavailable (graceful removal)The Nginx template generates an
upstream npm-<id> {}block at the top of each proxy host configuration file (valid at thehttpcontext level) and switchesproxy_passto target the upstream group when upstream servers are configured.Existing single-target proxy hosts remain unaffected.
API changes
Two new optional fields are accepted when creating or updating a proxy host:
lb_method(enum)upstream_servers(array of objects)Both default to an empty configuration using Round Robin, so existing integrations require no changes.
Constraint enforcement
Nginx does not allow the
backupflag to be used together withip_hash. This constraint is enforced in both the backend and frontend:400 Bad Requestbefore attempting to update the Nginx configuration.Type of Change
AI Usage