Skip to content

feat: weighted load balancing#816

Merged
levkk merged 1 commit intomainfrom
levkk-weighted-lb
Mar 7, 2026
Merged

feat: weighted load balancing#816
levkk merged 1 commit intomainfrom
levkk-weighted-lb

Conversation

@levkk
Copy link
Collaborator

@levkk levkk commented Mar 7, 2026

fix #575

How it works

Using weighted round robin. Each database host can specify the lb_weight, like so:

[general]
load_balancing_strategy = "weighted_round_robin"

[[databases]]
name = "prod"
host = "10.0.0.1"
lb_weight = 50

[[databases]]
name = "prod"
host = "10.0.0.1"
role = "replica"
lb_weight = 75

The lb_weight can be between 0 and 255. The default value is 255, so if not specified, it'll work like regular round robin. Only the relative weights matter, not total. For example, if you want a 80/20 split, you can do this:

[[databases]]
# [...]
lb_weight = 4

[[databases]]
# [...]
lb_weight = 1

@codecov
Copy link

codecov bot commented Mar 7, 2026

Codecov Report

❌ Patch coverage is 98.47328% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pgdog-config/src/database.rs 75.00% 1 Missing ⚠️
pgdog/src/backend/pool/lb/mod.rs 95.45% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@levkk levkk merged commit a1590eb into main Mar 7, 2026
9 checks passed
@levkk levkk deleted the levkk-weighted-lb branch March 7, 2026 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Weight-based load balancing

1 participant