SmartOS uses a Fair Share Scheduler (FSS) for handling allocation of CPU resources to machines provisioned on a compute node. The FSS uses two values to allocate CPU resources:
- CPU cap is the maximum amount of CPU resources a machine can use.
- CPU share the minimum amount of CPU resources a machine can use.
In this topic:
As previously described, the CPU cap is a hard limit. The CPU share is used to determine how the CPU resource pool is allocated among running machines.
Both the CPU cap and the CPU share values are given in the package used to provision the machine. The CPU cap is given explicitly in the package. The CPU share value is equivalent to the RAM allocated to the machine in megabytes. For example, a machine with 1 GB RAM is given 1024 shares. A machine with 8 GB RAM is given 8192 shares.
|SmartOS does not impose a relationship between RAM and shares. The provisioning process simply uses the amount of RAM to ensure that a machine with more memory gets more shares than a machine with less memory.|
The CPU cap is the maximum number of CPUs that a provisioned machine can use. This value is expressed as a percentage, where 100 means one CPU. A CPU cap of 350 means that the provisioned machine can use at most 3.5 CPUs.
The CPU share is used to determine the minimum amount of CPUs that a provisioned machine can use. The share value is relative to the total number of shares for all the provisioned machines running in the compute node.
An example will help illustrate the relationship between CPU caps and shares. Assume that your compute node has 24 CPU cores and that the following SmartOS VMS are provisioned on it.
| Number of
|4||8 GB||8192||200 (2 CPUs)|
|2||4 GB||4096||300 (3 CPUs)|
If all six machines are running, the total number of shares is:
Each of the 8 GB machines has 20% of the shares, so it can get 4.8 CPUs.
And each of the 2 GB machines has 10% of the shares and 2.4 CPUs.
However, since the 8 GB machines are capped at 2 CPUs, that is the maximum CPU resources they will get. The 2 GB machines are capped at 3 CPUs, but the shares allocate only 2.4 CPUs to them, so that's how much CPU time they will get.
Now suppose that one of the 8 GB machines is turned off. In this case, the total number of shares is:
The 8 GB machines now have 25% of the shares, or 6 CPUs.
The 4 GB machines now have 12.5% of the shares, or 3 CPUs.
The 8 GB machines are capped at 2 CPUs, so they still get only 2 CPUs. The 4 GB machines are capped at 3 CPUs, so they can use their full share, which is 3 CPUs.
The section lists some useful SmartOS command that you can use to get information about CPU usage on a compute node and provisioned machines.
Use the psrinfo command to get the total number of CPUs:
|For more information on psrinfo, see the man page.|
Use the prctl command to get the CPU cap of a machine. You can run this command from the compute node's global zone to get the CPU cap value for both SmartMachines and Virtual Machines.
|In the output, usage is the current percentage of CPU used, and privileged is the CPU cap.|
Within a SmartMachine you can use the value of zonename to get the CPU cap of a machine:
Use the prctl command to get the number of shares allocated to a machine. You can run this command from the compute node's global zone to get the share value for both SmartMachines and Virtual Machines.
|In the output, usage means how many shares are being used, and privileged means how many shares are allocated.|
You can also use this command within a SmartMachine to find out how many shares are allocated to it:
|For more information on prctl, see the man page.|