summaryrefslogtreecommitdiffstats
path: root/src/mds/balancers
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/mds/balancers
parentInitial commit. (diff)
downloadceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz
ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/mds/balancers')
-rw-r--r--src/mds/balancers/greedyspill.lua49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/mds/balancers/greedyspill.lua b/src/mds/balancers/greedyspill.lua
new file mode 100644
index 00000000..20576cdb
--- /dev/null
+++ b/src/mds/balancers/greedyspill.lua
@@ -0,0 +1,49 @@
+local metrics = {"auth.meta_load", "all.meta_load", "req_rate", "queue_len", "cpu_load_avg"}
+
+-- Metric for balancing is the workload; also dumps metrics
+local function mds_load()
+ for rank, mds in pairs(mds) do
+ local s = "MDS"..rank..": < "
+ for _, metric in ipairs(metrics) do
+ s = s..metric.."="..mds[metric].." "
+ end
+ mds.load = mds["all.meta_load"]
+ BAL_LOG(5, s.."> load="..mds.load)
+ end
+end
+
+-- Shed load when you have load and your neighbor doesn't
+local function when()
+ if not mds[whoami+1] then
+ -- i'm the last rank
+ BAL_LOG(5, "when: not migrating! I am the last rank, nothing to spill to.");
+ return false
+ end
+ my_load = mds[whoami]["load"]
+ his_load = mds[whoami+1]["load"]
+ if my_load > 0.01 and his_load < 0.01 then
+ BAL_LOG(5, "when: migrating! my_load="..my_load.." hisload="..his_load)
+ return true
+ end
+ BAL_LOG(5, "when: not migrating! my_load="..my_load.." hisload="..his_load)
+ return false
+end
+
+-- Shed half your load to your neighbor
+-- neighbor=whoami+2 because Lua tables are indexed starting at 1
+local function where(targets)
+ targets[whoami+1] = mds[whoami]["load"]/2
+ return targets
+end
+
+local targets = {}
+for rank in pairs(mds) do
+ targets[rank] = 0
+end
+
+mds_load()
+if when() then
+ where(targets)
+end
+
+return targets