CPU Entitlement

Page last updated:

This topic describes how to CPU entitlements work in VMware Tanzu Application Service for VMs (TAS for VMs) and how to configure them.

Overview

To watch an overview of the topic, see CPU Entitlements in Cloud Foundry on YouTube.

CPU entitlement describes the percentage of host CPU a particular app instance is entitled to use. The CPU entitlement plugin shows that apps have a CPU performance of 100% when they are using exactly the CPU they are entitled. Apps have a CPU performance of less than 100% when their usage is less than their entitlement and greater than 100% when they are above their entitlement.

In TAS for VMs, apps have CPU entitlements that are proportional to their allocated memory by default. For example, an app with access to 256MB of memory on a 512MB machine has access to half of the memory on the machine and is also entitled to half of the CPU of that machine.

CPU Entitlement Plugin

The metric absolute_entitlement shows an app’s CPU usage relative to its entitlement.

To retrieve absolute_entitlement metrics for all instances of an app:

  1. Install the CPU Entitlement Plugin from the cpu-entitlement-plugin repository on GitHub.

  2. In a terminal window, run:

    cf cpu-entitlement APP-NAME
    

    Where APP-NAME is the name of the app.

    The above command returns absolute_entitlement metrics for all instances of the app, similar to the following example:

    Showing CPU usage against entitlement for app dora-example in org example-org / space example-org-staging as dora@example.com ...
    ‚Äč
         avg usage   curr usage
    #0   1.62%       1.66%
    #1   2.93%       3.09%
    #2   2.51%       2.62%
    

After you run the cf cpu-entitlement command, you see two values: avg usage and curr usage. The average usage is used to split the app into two groups, good and bad. Good apps have an average CPU usage that is below 100% of their CPU entitlements, and bad apps have an average CPU usage that is over 100% of their CPU entitlements. In the example above, all values for the average CPU usage are under 100% of their CPU entitlements.

Spare CPU Resources and Throttling

If there are three cores on the Diego Cell to which your app is deployed, 300% CPU can be distributed between all the apps on the Diego Cell. This is the percentage that the cf app command displays. The metrics depend on factors such as the capacity of the Diego Cell and the total number of apps on it that are not visible to the user. This can make it difficult for users and operators to balance CPU resources.

An app always receives 100% of its CPU entitlement, no matter what other apps are on the Diego Cell. If there are spare resources on the machine, an app can consume over 100% CPU.

CPU Burst Optimization is turned off by default. You can check this setting by going to the App Containers tab and checking the property Enable CPU Burst Optimization

Without CPU Burst Optimization

When CPU Burst Optimization is turned off, all apps on the cell share any spare CPU resources.

With CPU Burst Optimization

When CPU Burst Optimization is turned on, “good” apps get bursting priority over “bad” apps. Good apps are apps that, on average, have stayed within their CPU entitlement. Bad apps are apps that, on average, have exceeded their CPU entitlement.

Imagine a Diego Cell with 5 bad apps and 1 good app. Initially the 5 “bad” apps will evenly split all of the spare CPU resources. If the good app needs to burst, it will be given priority to all of the extra CPU it needs. If the good app continues bursting for long enough and on average it exceeds its CPU entitlement, then it will become a bad app. Then all 6 “bad” apps will equally share the spare CPU resources. Likewise, if one of the bad apps stops using so much CPU it will become a good app again.