Skip to content

Set CPU/Memory Limits

Set CPU and Memory Limits

The amount of CPU and memory reserved for each app can be individually tailored to suit the app's requirements. Complex Kelvin SmartApps™ will require more and simpler ones will require less.

By managing these resources manually, you can maximize how many Kelvin SmartApps™ can run on your existing cluster hardware.

You can define the CPU and memory resources for Kelvin SmartApps™ in the app.yaml file. Here is an example of the settings:

spec_version: 4.11.0
kelvin:
  ...

system:
  resources:
    limits:
      cpu: 100m
      memory: 512Mi
    requests:
      cpu: 100m
      memory: 512Mi

And here's the definition of the settings:

  • Limits: This is a maximum resource limit enforced by the cluster. Kelvin SmartApps™ will not be allowed to use more than the limit set.

  • Requests: This is the minimum resources that is allocated to Kelvin SmartApps™. This is reserved for Kelvin SmartApps™ and can not be used by other Kelvin SmartApps™. If there are extra resources available, Kelvin SmartApps™ can use more than the requested resources as long as it does not exceed the Limits.

For example you set the memory allocation for Kelvin SmartApps™ requests at 250 MB and Limits at 1 GB. The cluster will reserve the 250MB exclusively to Kelvin SmartApps™. If Kelvin SmartApps™ needs more memory and it is available, the Cluster will expand the memory available up to a maximum of 1GB.

The reserved CPU and memory allocations might differ from the actual CPU and memory usage. "Reserved" signifies that these resources are allocated within the cluster and aren't available to other Kelvin SmartApps™.

Within any cluster, the total reserved resources cannot exceed the physically available resources. If Kelvin SmartApps™ deployment fails, it might be due to insufficient resources to reserve the necessary amount for the app.

While you might see sufficient resources available based on current usage, remember that this represents the actual usage, not the cumulative reserved resources.

Resource Definitions

CPU

CPU is allocated in absolute quantities only. 1.0 CPU is equivalent to one hyperthread on an Intel core processor. There are two different ways that you can write the allocation. For example 1/10 of one hyperthread is:

  • 0.1
  • 100m

The absolute minimum you can allocate is 1m or 0.001.

Memory

You can allocate memory as either an integer in bytes or in multiples of G, M, k or Gi, Mi, Ki. When defining in the app.yaml do not write the "B" for bytes. For example the number below is approximately the same;

  • 128974848
  • 129e6
  • 129M
  • 123Mi

What is the difference between M and Mi ?

One M is defined as 1000^2 (1,000,000) whereas one Mi is defined as 1024^2 (1,048,576).

Resource Allocation Troubleshooting

Problem Possible Solutions
CPU for Kelvin SmartApps™ is very high, what happens if it reaches the limit ? Kelvin SmartApps™ will continue to run but the CPU will be throttled to the maximum limit of the CPU.
The memory is very high, what happens if it reaches the limit ? Kelvin SmartApps™ will be stopped and restarted. You may lose data. To avoid this raise the Limit of the memory for Kelvin SmartApps™. Add extra physical memory to the cluster computer if required.
I don't know the default settings for the app resource allocation. There are no default settings for resource allocation. If you don't define anything in the app.yaml Kelvin SmartApps™ does not have limits or requests.
Do I need to set a limit ? Is it ok to just set the requests ? Yes. The limits will automatically be the full resources of the computer. If there is a memory leak or a bug you may overwhelm the system. It is strongly advised that you always set a limit.
Can I set the app resource allocation settings without redeploying ? No. You will need to redeploy Kelvin SmartApps™ after changing the configuration settings.