在生产环境(使用 10 节点集群)中,nomad “装箱算法”会导致系统利用率方面的大问题。
可能的解决方案是使用以下规则/策略:
1. 不同的主机
用例:主要用于 LoadBalancer 后面的多个 tcp/udp 侦听器。它工作正常,正是你所期望的。
2.资源限制
Via nomad-client conf as follows:
client {
enabled = true
cpu_total_compute = 12000
reserved {
cpu = 3000
memory = 33000
disk = 1
}
network_speed = 10000
servers = ["127.0.0.1:4647"]
options {
"driver.raw_exec.enable" = "1"
}
}
Painful and limiting
3.传播节
Sounds promising but could not get it to work using NOMAD-SDK.
Nomad java SDK 0.9.0-SNAPSHOT 不支持通过 API 传播节。相反,可以使用方法“addUnmappedProperty”来添加自定义 JSON 结构/数组。
Job jobSpec = nomadContext.getJob();
List<Object> spreads = new ArrayList<>();
Map<String, Object> spreadStanza = new HashMap<>();
spreadStanza.put("Attribute", "${node.unique.id}");
spreadStanza.put("Weight", 100);
// spreadStanza.put("SpreadTarget", null);
spreads.add(spreadStanza);
jobSpec.addUnmappedProperty("Spreads", spreads);
for(TaskGroup taskGroup: jobSpec.getTaskGroups()){
taskGroup.addUnmappedProperty("Spreads", spreads);
}
但不幸的是无法让它工作,详细的工作状态中没有显示分配分布:
另一个示例使用通过命令行参数部署的简单 hcl 作业规范:
job "sleep" {
datacenters = ["dc1"]
spread {
attribute = "${node.unique.id}"
weight = 100
}
group "example" {
count=10
spread {
attribute = "${node.unique.id}"
weight = 100
}
task "server" {
driver = "raw_exec"
config {
command = "/bin/sleep"
args = [
"500"
]
}
resources {
network {
mbits = 10
}
}
}
}
}
在这种情况下,分配扩展被显示
游牧分配状态-详细 1feb7476
Node job-anti-affinity node-reschedule-penalty node-affinity allocation-spread binpack final score
4c4e3bb2-9568-3f5d-3a8c-fd056f258ed0 -0.4 0 0 0.667 0.896 0.387
4b36b048-a24b-e0e9-a789-625764fcfa70 -0.5 0 0 -0.667 0.901 -0.0886
我很感激任何帮助。
谢谢你。