sharp
sharp copied to clipboard
Kubernetes resource limits
I am trying to understand what is the correct value to use for Kubernetes pod resource limits.
Kubernetes documentation says:
Limits and requests for CPU resources are measured in cpu units. One cpu, in Kubernetes, is equivalent to 1 vCPU/Core for cloud providers [..] CPU is always requested as an absolute quantity, never as a relative quantity; 0.1 is the same amount of CPU on a single-core, dual-core, or 48-core machine.
– https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-cpu
Meanwhile, I am on a 8 core machine and my configuration is:
resources:
requests:
memory: '1Gi'
cpu: '50m'
limits:
memory: '4Gi'
cpu: '2000m'
However, if I check sharp.concurrency()
, it says that it is using 8 threads. Should I limit concurrency to 2, since Kubernetes resource limit is 2 cores?
Yes, you'll probably want to experiment with sharp.concurrency(2)
in this case to see if it offers better throughput for your given task.
I think cpu: '2000m'
means schedule work on no more than 2 cores at any given point in time, which is not the same thing as how many cores are exposed inside a container and therefore available on which to schedule work.
I think cpu: '2000m' means schedule work on no more than 2 cores at any given point in time, which is not the same thing as how many cores are exposed inside a container and therefore available on which to schedule work.
If I am reading their docs right, 2000m means use at the most the power of 2 CPUs, but it could be spread against any number of CPUs:
CPU is always requested as an absolute quantity, never as a relative quantity; 0.1 is the same amount of CPU on a single-core, dual-core, or 48-core machine.
I am asking here to get clarification from someone who might have experimented with different settings.
I'll close as this hasn't attracted any further discussion but please feel free to reopen with more details if further help is required.