TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

When Simple Wins: Power of 2 Load Balancing

140 pointsby mattdennewitzalmost 8 years ago

7 comments

alxvalmost 8 years ago
The method is called &quot;Power of Two <i>Random Choices</i>&quot; (<a href="http:&#x2F;&#x2F;www.eecs.harvard.edu&#x2F;~michaelm&#x2F;postscripts&#x2F;handbook2001.pdf" rel="nofollow">http:&#x2F;&#x2F;www.eecs.harvard.edu&#x2F;~michaelm&#x2F;postscripts&#x2F;handbook20...</a>). And the two-choices paradigm is widely applicable beyond load balancing. In particular, it applies to hash table design (e.g. cuckoo hashing) and cache eviction schemes (<a href="https:&#x2F;&#x2F;danluu.com&#x2F;2choices-eviction&#x2F;" rel="nofollow">https:&#x2F;&#x2F;danluu.com&#x2F;2choices-eviction&#x2F;</a>).
评论 #14642253 未加载
评论 #14644443 未加载
评论 #14643213 未加载
zubspacealmost 8 years ago
I&#x27;m not an expert in this field, but an engineer of vimeo went into detail, why this approach did not work for them. [1]<p>Problem with consistent hashing:<p><pre><code> However, consistent hashing comes with its own problem: uneven distribution of requests. Because of its mathematical properties, consistent hashing only balances loads about as well as choosing a random server for each request, when the distribution of requests is equal. But if some content is much more popular than others (as usual for the internet), it can be worse than that. </code></pre> Problem with Power of 2 Load Balancing:<p><pre><code> Why wasn’t there a way to say “use consistent hashing, but please don’t overload any servers”? As early as August 2015, I had tried to come up with an algorithm based on the power of two random choices that would do just that, but a bit of simulation said that it didn’t work. Too many requests were sent to non-ideal servers to be worthwhile. </code></pre> Instead, he used something called <i>Consistent Hashing with Bounded Loads</i>.<p>[1] <a href="https:&#x2F;&#x2F;medium.com&#x2F;vimeo-engineering-blog&#x2F;improving-load-balancing-with-a-new-consistent-hashing-algorithm-9f1bd75709ed" rel="nofollow">https:&#x2F;&#x2F;medium.com&#x2F;vimeo-engineering-blog&#x2F;improving-load-bal...</a>
评论 #14645048 未加载
评论 #14643629 未加载
评论 #14643455 未加载
throwaway13337almost 8 years ago
The simplest load balancing I&#x27;ve done is modulo the user ID by the number of servers then point at that server.<p>This solves caching too since you are only ever receiving and caching user data on a single server. No cache communication required. You can enforce it on the server side for security as well.<p>Doesn&#x27;t require a load balance server - just an extra line of code.<p>Keep it simple.
评论 #14641144 未加载
评论 #14643053 未加载
评论 #14642184 未加载
评论 #14642379 未加载
评论 #14641643 未加载
评论 #14642270 未加载
评论 #14644791 未加载
评论 #14641113 未加载
评论 #14641112 未加载
euph0riaalmost 8 years ago
Regarding the math section, could someone please describe it like you were talking to a 5 year old?<p>1) Θ( log n = log &#x2F; log n )<p>2) Θ(log log n)
评论 #14641300 未加载
评论 #14641233 未加载
评论 #14641344 未加载
评论 #14641477 未加载
gopalvalmost 8 years ago
&quot;Power of 2 Random Choices&quot; ... has nothing to do with the &quot;Power of 2&quot; directly.<p>I like 2Choice because it is not dependent on hash function design &amp; is temporal, but I have a positive aversion to the 2^n hash distributions when it comes to data, specifically for distributed systems which need to flex up&#x2F;down [1].<p>[1] - <a href="http:&#x2F;&#x2F;notmysock.org&#x2F;blog&#x2F;hacks&#x2F;1440" rel="nofollow">http:&#x2F;&#x2F;notmysock.org&#x2F;blog&#x2F;hacks&#x2F;1440</a>
scamealmost 8 years ago
I&#x27;ve seen a paper doing the same thing directly at the network layer using IPv6 extension headers: <a href="http:&#x2F;&#x2F;www.thomasclausen.net&#x2F;wp-content&#x2F;uploads&#x2F;2017&#x2F;06&#x2F;2017-ICDCS-SRLB-The-Power-of-Choices-in-Load-Balancing-with-Segment-Routing.pdf" rel="nofollow">http:&#x2F;&#x2F;www.thomasclausen.net&#x2F;wp-content&#x2F;uploads&#x2F;2017&#x2F;06&#x2F;2017...</a>
adrianratnapalaalmost 8 years ago
Can someone expand on the maths that the OP elided? What is the thing that comes out to O(log n &#x2F; log log n)?