Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

yoonper/wrr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

1 Commit

Repository files navigation

WRR

Weighted Round Robin Balancer


Getting Started

go get -u github.com/yoonper/wrr
package main
import (
	"fmt"
	"github.com/yoonper/wrr"
)
func main() {
	b := wrr.Init()
	b.Add("item1", 2)
	b.Add("item2", 5)
	b.Add("item3", 3)
	count := make(map[string]int)
	for i := 0; i < 100; i++ {
		item := b.Next()
		count[item]++
		// you can increase or decrease item weight
		// b.IncWeight("item3")
		// b.DecWeight("item3")
	}
	fmt.Println(count)
}

Reference

ngx_http_upstream_round_robin.c

About

Weighted Round Robin Balancer

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

AltStyle によって変換されたページ (->オリジナル) /