根据性能分批拆分数据(负载均衡)
Splitting data in batches based on performance (load balancing)
我希望编写一个小型负载平衡算法来根据每个服务器的性能指标(它的权重)确定要发送给每个服务器的数据量。我的问题与这个类似:Writing a weighted load balancing algorithm
然而,对于获得源源不断的数据流的服务器来说,这种方式更适用。我的案例将是 运行 一次,并在多个系统之间拆分(当时 2 个)。需要拆分负载,以便同时处理和完成所有数据。
Example 1:
We get a zip with 1,000 images
System #1: 3 s/img
System #2: 6 s/img
Since sys1 is 50% faster, it should receive double the data.
Sys1 receives: 667 images
Sys2 receives: 333 images
我在 python 中执行此操作,接受数字列表并根据重量拆分批次的方程式是什么?前任。接收权重 = [4.1, 7.3, 2.5]
和 img_count = 5000
?
你只需要计算单位重量可以做多少功,然后用你的重量乘以单位做功。 python.
中有几行
w = [4.1, 7.3, 2.5]
total = 5000
unit = total / sum(w)
res = [unit * i for i in w]
print res // [1474.820143884892, 2625.8992805755397, 899.2805755395684]
最后做一些舍入,你就得到了你想要的
我希望编写一个小型负载平衡算法来根据每个服务器的性能指标(它的权重)确定要发送给每个服务器的数据量。我的问题与这个类似:Writing a weighted load balancing algorithm
然而,对于获得源源不断的数据流的服务器来说,这种方式更适用。我的案例将是 运行 一次,并在多个系统之间拆分(当时 2 个)。需要拆分负载,以便同时处理和完成所有数据。
Example 1:
We get a zip with 1,000 images
System #1: 3 s/img
System #2: 6 s/img
Since sys1 is 50% faster, it should receive double the data.
Sys1 receives: 667 images
Sys2 receives: 333 images
我在 python 中执行此操作,接受数字列表并根据重量拆分批次的方程式是什么?前任。接收权重 = [4.1, 7.3, 2.5]
和 img_count = 5000
?
你只需要计算单位重量可以做多少功,然后用你的重量乘以单位做功。 python.
中有几行w = [4.1, 7.3, 2.5]
total = 5000
unit = total / sum(w)
res = [unit * i for i in w]
print res // [1474.820143884892, 2625.8992805755397, 899.2805755395684]
最后做一些舍入,你就得到了你想要的