projects
/
Pman.Core
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
00f28d9
)
distribute queue
author
Alan
<alan@roojs.com>
Mon, 16 Oct 2023 05:33:03 +0000
(13:33 +0800)
committer
Alan
<alan@roojs.com>
Mon, 16 Oct 2023 05:33:03 +0000
(13:33 +0800)
DataObjects/Core_notify_server.php
patch
|
blob
|
history
diff --git
a/DataObjects/Core_notify_server.php
b/DataObjects/Core_notify_server.php
index
ed1aec7
..
09db236
100644
(file)
--- a/
DataObjects/Core_notify_server.php
+++ b/
DataObjects/Core_notify_server.php
@@
-216,13
+216,15
@@
class Pman_Core_DataObjects_Core_notify_server extends DB_DataObject
$target_len = floor( ($totalq + $total_add) / $num_servers );
foreach($in_q as $sid => $cq) {
$target_len = floor( ($totalq + $total_add) / $num_servers );
foreach($in_q as $sid => $cq) {
- if ( $
target_len - $cq < 1
) {
+ if ( $
cq > $target_len
) {
continue;
}
$up[ $sid ] = array_slice($to_add, 0, $target_len - $cq);
}
continue;
}
$up[ $sid ] = array_slice($to_add, 0, $target_len - $cq);
}
- foreach($to_add as $i) {
- $up[ $ids[0] ][] = $i;
+
+ // add the reminder evently
+ foreach($to_add as $n=>$i) {
+ $up[ $ids[$n % $num_servers] ][] = $i;
}
// distribution needs to go to ones that have the shortest queues. - so to balance out the queues
}
// distribution needs to go to ones that have the shortest queues. - so to balance out the queues