Kubernetes/Requests and Limits, units

From Ever changing code
< Kubernetes
Revision as of 19:27, 8 December 2021 by Pio2pio (talk | contribs)
Jump to navigation Jump to search
Meaning of CPU

Limits and requests

CPU

Limits and requests for CPU resources are measured in cpu units. One cpu, in Kubernetes, is equivalent to 1 vCPU/Core for cloud providers and 1 hyperthread on bare-metal Intel processors.


Meaning of memory

Limits and requests for memory are measured in bytes. You can express memory as a plain integer or as a fixed-point number using one of these suffixes: E, P, T, G, M, k, m (millis). You can also use the power-of-two equivalents: Ei, Pi, Ti, Gi, Mi, Ki.

For example, the following represent roughly the same value: 128974848, 129e6, 129M, 128974848000m, 123Mi


CPU units

The CPU resource is measured in CPU units. 1 CPU, in Kubernetes, is equivalent to:

  • 1 vCPU/Core for cloud providers (1 AWS vCPU, 1 GCP Core, 1 Azure vCore)
  • 1 Hyperthread on a bare-metal Intel processor with Hyperthreading


Fractional values are allowed. A Container that requests 0.5 CPU is guaranteed half as much CPU as a Container that requests 1 CPU. You can use the suffix m to mean milli. For example 100m CPU, 100 milliCPU, and 0.1 CPU are all the same. Precision finer than 1m is not allowed.

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.


Memory Units

Fixed-Point Suffix
  • E = Exabyte. 1E = 1,000,000,000,000,000,000 bytes
  • P = Petabyte. 1P = 1,000,000,000,000,000 bytes
  • T = Terabyte. 1T = 1,000,000,000,000 bytes
  • G = Gigabyte. 1G = 1,000,000,000 bytes
  • M = Megabyte. 1M = 1,000,000 bytes
  • K = Kilobyte. 1K = 1,000 bytes

Note: Use it if you’re mostly used to seeing the units of, files on your computer drives; they just exclude B in the suffix.


Binary, Power-of-Two Suffix
  • Ei = EiB = Exbibyte. 1Ei = 2⁶⁰ = 1,152,921,504,606,846,976 bytes
  • Pi = PiB = Pebibyte. 1Pi = 2⁵⁰ = 1,125,899,906,842,624 bytes
  • Ti = TiB = Tebibyte. 1Ti = 2⁴⁰ = 1,099,511,627,776 bytes
  • Gi = GiB = Gibibyte. 1Gi = 2³⁰ = 1,073,741,824 bytes
  • Mi = MiB = Mebibyte. 1Mi = 2²⁰ = 1,048,576 bytes
  • Ki = KiB = Kibibyte. 1Ki = 2¹⁰ = 1,024 bytes

Note: Both the suffixes with and without the trailing B work for the binary, power-of-two suffixes.


Compare
128974848≈129e6≈129M       # Fixed-point (metric)
128974848≈129e6≈129M≈123Mi # Binary