gpt4 book ai didi

nomad - nomad 什么时候限制任务?

转载 作者:行者123 更新时间:2023-12-01 00:12:54 24 4
gpt4 key购买 nike

nomad 如何限制任务的资源消耗?如果一个组中有两个任务,每个任务都有 cpu = 100 ,是否有200的共享池这两个任务都可以访问?如果这些任务之一想要访问更多 CPU 滴答,会发生什么?

job "docs" {
group "example" {
task "server" {
resources {
cpu = 100
memory = 256
}
}
task "greeter" {
resources {
cpu = 100
memory = 256
}
}
}
}

看着 /client/allocation/:alloc_id/stats ,我看到 ThrottledPeriods 和 ThrottledTicks 都被分解了 resourcestasks -- 资源和任务都会限制资源使用吗?

最佳答案

这并不能完全回答问题,但 docker driver docs有一些关于它的一部分如何工作的细节:

CPU

Nomad limits containers' CPU based on CPU shares. CPU shares allow containers to burst past their CPU limits. CPU limits will only be imposed when there is contention for resources. When the host is under load your process may be throttled to stabilize QoS depending on how many shares it has. You can see how many CPU shares are available to your process by reading NOMAD_CPU_LIMIT. 1000 shares are approximately equal to 1 GHz.

Please keep the implications of CPU shares in mind when you load test workloads on Nomad.

Memory

Nomad limits containers' memory usage based on total virtual memory. This means that containers scheduled by Nomad cannot use swap. This is to ensure that a swappy process does not degrade performance for other workloads on the same host.

Since memory is not an elastic resource, you will need to make sure your container does not exceed the amount of memory allocated to it, or it will be terminated or crash when it tries to malloc. A process can inspect its memory limit by reading NOMAD_MEMORY_LIMIT, but will need to track its own memory usage. Memory limit is expressed in megabytes so 1024 = 1 GB.

关于nomad - nomad 什么时候限制任务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56338461/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com