-
-
Notifications
You must be signed in to change notification settings - Fork 36
Least connections algorithm #128
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
base: master
Are you sure you want to change the base?
Conversation
1b02912
to
2f02ab0
Compare
I really wish we had a way in Varnish-Cache to add backends to directors other than from VCL 1, such that dynamic could be given an instance of another director to use as the next layer. This way, we would not need to reinvent the wheel whenever we want to add another load balancing method, avoiding the otherwise unavoidable path towards "unidirectors" and keeping the separation of concerns... Footnotes |
52a9196
to
f7139d9
Compare
@nigoroll thank you, and thanks for that explanation. I really clearly understand what you're thinking and I agree... we don't want to reinvent wheels, especially as they'll end up buggy (see my several additional commits!). This sounds like a joyful change to Varnish but well outside of my wheel-house. Can you point me to a spot to look into what supporting this kind of effort looks like? |
@karlvr I am sorry for having overlooked your question
I am not sure if you mean by throwing money at it or technically. Regarding the former, I added the respective link, regarding the latter, my broad ideas are the following:
One open question is what we do for per-backend parameters. Take, as an example, shard with its sub vcl_init {
new shard = directors.shard();
}
# called when dyn creates or removes backends
sub dyn_add_shard_mem {
shard.add_backend(dyn.new_backend(), weigt=std.random(0,100));
shard.reconfigure();
}
sub dyn_del_shard_mem {
shard.remove_backend(dyn.dying_backend());
shard.reconfigure();
}
sub vcl_init {
new dyn = dynamic.director(add_backend=dyn_add_shard_mem, remove_backend=dyn_del_shard_mem);
} hmmm... |
Perhaps to reopen the conversation from #71, I have ported just the least connections algorithm to the master branch. We have abandoned the weighted and slow start that complicated the previous implementation. We have been using
LEAST
in production for > 5 years. We've tried switching back to the defaultRR
implementation but experience issues when one of our backends runs slowly.As you noted in #71 it isn't a guarantee of least connections (as the connection is not reserved) however we are treating it as a heuristic, and as such it has worked really well for us.
Again, if you're interested, I am happy to work this code to get it into a shape you like. I've tried to reproduce the basic logic from
dom_find
indom_find_leastconn
without worrying about thealt
behaviour as it usesdom_find
as a fall-back anyway. I look forward to hearing your thoughts when you have the time & energy!