Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ideas for improving the loadbalancer #13

Open
benediktkr opened this issue Sep 24, 2014 · 0 comments
Open

Ideas for improving the loadbalancer #13

benediktkr opened this issue Sep 24, 2014 · 0 comments

Comments

@benediktkr
Copy link
Owner

Currently the load balancer is implemented (on the Model level) at `model.NodeList.best()'.

It works like this:

def best(cls, n=3):
    all_nodes = cls.get()
    candidates =  [a for a in all_nodes if a.alive and a.enabled]
    by_score = sorted(candidates, key=lambda a: a.score)[:n]
    random.shuffle(by_score)
    return cls(by_score)

This is then exposed through two calls, POST /node?filter=best (requiers authentication and gives full info on the nodes) and GET /lokun/loadbalancer?count=n (exposes IP and name).

  • What happens to this if there are only 0, 1 or 2 nodes alive and enabled?

This has one minor problem. The best n nodes are picked and then shuffled around. I would like to pick the best nodes, even though the score varies by maybe 1-2, then shuffle them and return the n best ones. Something like this (in pythonic psuedo code):

def best(cls, n=3):
    all_nodes = cls.get()
    candidates = [a for a in all_nodes if a.alive and a.enabled]
    min_score = min(a.score for a in candidates)
    by_score = [a for a in candidates if a.score.within_logscale(min_score)]
    random.shuffle(by_score)
    return by_score

This would be less exclusive of nodes that are very close in score.

@benediktkr benediktkr changed the title How the load balancer works Ideas for improving the loadbalancer Sep 27, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant