Continue to optimize the Nginx WRR load balancing algorithm

The owner of Wenzhou Leather Shoe Factory told me a new WRR algorithm based on array hashing, but it is still a bit over-designed. I said that for 3 elements with weights such as 3, 2, and 1, make 3 elements 1, 2 elements 2, 1 element 3, a total of 6 elements are kneaded into a handful, randomly thrown into 6 grids to finish , as long as it is random enough, this algorithm should be the best! It is not the best for granted, it is necessarily the best, because it is the conclusion of maximum entropy, the universe is lazy, and the maintenance of low-entropy bodies requires effort!

  Well, I admitted it later, I used this algorithm for reuseport optimization, just adding a little flavor of consistent hashing!


Now to the second question.

  A load balancer does not refer to a single machine, otherwise it is a single point! It may itself be load-balanced or self-loading. We assume 3 load balancers X AND WITH separate load set G = { A : a , B : b , C : c } , as I wrote in my previous post O ( n ) change O ( 1 ) The preprocessing method of , assuming a set G The sequence is generated under the action of the WRR algorithm S = ( a a b c a b c a b a a b c a b c )

  then the 3 load balancers will share this sequence S , the flow direction a The pressure will be from the sequence S of 2 rise to 2 × 3 , as the number of load balancers increases to n , this number will become 2 × n . A random result can never stand up to stacking. How to do?

  easy to do! Random again!

  Then according to the number of load balancers n generate a random sequence S 2 = ( m 1 , m 2 , . . . . m n ) ,in m i just the sequence S The starting element index in . In this way, requests received by different load balancers will undergo different polling orders. Although it is only a Caesar cipher change, it is better than using it directly!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325552952&siteId=291194637
Recommended