寻找负载最少的服务器

发布于 2024-12-25 18:43:44 字数 136 浏览 1 评论 0原文

给定三台服务器 A、B、C,其中 A 可以处理 50% 的流量,B 可以处理 30% 的流量,C 可以处理 20% 的流量,提出一个有效分配负载的公式。服务器的当前负载也是该函数的输入。

我无法想出他所要求的“公式”。这个问题有具体的答案吗?

Given three servers which A , B , C in which A can handle 50% of the traffic , B can handle 30% of the traffic and C can handle 20% of the traffic come up with a formula to distribute load efficiently. The current load of the servers is also an input to the function.

I could not come up with the "formula" he is asking for. Is there any specific answer to this question ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

那伤。 2025-01-01 18:43:44

有几种不同的负载分配方法可能适用于此。

情况 1. 与每个服务器负载成比例的随机分配:

for each request
  let x = uniformly distributed random number between 0 and 1
  if x <= 0.5
    goto A
  else if x <= 0.8
    goto B
  else
    goto C

情况 2. 与每个服务器负载成比例的循环分配:

let x = new list
push A on x 5 times
push B on x 3 times
push C on x 2 times

for each request
  y = pop x
  goto y
  push y to back of x

情况 3. 忘记假定的容量并轮询当前负载

let La = A, load of A
let Lb = B, load of B
let Lc = C, load of C

goto argmin (La,Lb,Lc)

There are a few different ways to distribute load that might be applicable here.

Case 1. Random assignment biased proportionally to each servers load:

for each request
  let x = uniformly distributed random number between 0 and 1
  if x <= 0.5
    goto A
  else if x <= 0.8
    goto B
  else
    goto C

Case 2. Round-Robin biased proportionally to each servers load:

let x = new list
push A on x 5 times
push B on x 3 times
push C on x 2 times

for each request
  y = pop x
  goto y
  push y to back of x

Case 3. Forget about the supposed capacity and poll for current load

let La = A, load of A
let Lb = B, load of B
let Lc = C, load of C

goto argmin (La,Lb,Lc)
简单爱 2025-01-01 18:43:44

基本上,计算每个服务器上的服务相对成本,并在某个小的固定时间内,将发送到所述服务器的请求的总成本相加。像这样的东西:

Cost_A = 20/50
Cost_B = 20/30
Cost_C = 20/20

Running_Total_A = 0 
Running_Total_B = 0
Running_Total_c = 0

while true: 
   If One minute has passed:
     Running_Total_A = 0 
     Running_Total_B = 0
     Running_Total_c = 0

   IF (Min(Running_Total_A,Running_Total_B,Running_Total_C) == Running_Total_A):
     Running_Total_A += Cost_A
     RouteTo(A)
   ELSE IF (Min(Running_Total_A,Running_Total_B,Running_Total_C) == Running_Total_B):
     Running_Total_B += Cost_B
     RouteTo(B)
   ELSE IF (Min(Running_Total_A,Running_Total_B,Running_Total_C) == Running_Total_C):
     Running_Total_C += Cost_C
     RouteTo(C)

Basically, compute a relative cost to serve on each of the servers, and over some small fixed period, sum the total cost of the requests sent to said server. Something like:

Cost_A = 20/50
Cost_B = 20/30
Cost_C = 20/20

Running_Total_A = 0 
Running_Total_B = 0
Running_Total_c = 0

while true: 
   If One minute has passed:
     Running_Total_A = 0 
     Running_Total_B = 0
     Running_Total_c = 0

   IF (Min(Running_Total_A,Running_Total_B,Running_Total_C) == Running_Total_A):
     Running_Total_A += Cost_A
     RouteTo(A)
   ELSE IF (Min(Running_Total_A,Running_Total_B,Running_Total_C) == Running_Total_B):
     Running_Total_B += Cost_B
     RouteTo(B)
   ELSE IF (Min(Running_Total_A,Running_Total_B,Running_Total_C) == Running_Total_C):
     Running_Total_C += Cost_C
     RouteTo(C)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文