GithubHelp home page GithubHelp logo

loadbalance's Introduction

loadbalance

介绍

loadbalance实现了常用的负载均衡算法:

标签 说明
轮询 从1开始,直到N,然后重新开始循环
加权轮询 根据相应权值数的轮询循环选择(平滑轮询)
随机 从1-N随机选择一个
加权随机 从相应权值数中随机选择一个

待完成项

  • 继续增加负载均衡算法

使用

1、直接创建

lb := loadbalance.NewRoundRobbinLoadBalance()
		lb.Add(1, "a")
		lb.Add(1, "b")
		lb.Add(1, "c")
		for i := 0; i < 10; i++ {
			t.Log(lb.Select(nil))
		}

1、使用factory

lb := loadbalance.Create(loadbalance.LBRoundRobbin)
		lb.Add(2, "a")
		lb.Add(5, "b")
		lb.Add(10, "c")
		for i := 0; i < 17; i++ {
			t.Log(lb.Select(nil))
		}

loadbalance's People

Contributors

xfali avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.