Wednesday, September 8, 2010

controlling cpu usage part 9: Setting capped-cpu for a Zone

Introduced in Solaris 10 05/08 CPU caps allow a fine division of CPU resources. The administrator can allocate CPU resources in 1% increments of a single CPU. The allocation can go from 1% of a single CPU to the of CPU's in the system.
The capped-cpu resource type has a single property ncpus. This holds the amount of CPU allocation for the zone. It is expressed in units of a CPU, so 0.01 would be 1% of a single CPU, 1 would be 1CPU and 3.75 would be 3 3/4 CPU's.
I there are multiple CPU's in the system the allocation can come from any CPU, so multi-threaded code can still run threads in parallel if the scheduler so allocates.
However, unlike pools there is no dynamic balancing. If capped-cpu is enabled the CPU resources are statically divided. Unused CPU cycles in a zone are not available for other zones which have capped-cpu in effect.

To set a zone to use 18% of a single CPU we would enter the following.


 # zonecfg -z test0z1
 zonecfg:test0z1> add capped-cpu
 zonecfg:test0z1:capped-cpu> set ncpus=0.18
 zonecfg:test0z1:capped-cpu> end
 zonecfg:test0z1> exit

One important point to remember is that a single threaded process cannot utilize more than a single CPU irrespective of the value of the value of the capped-cpu resource.
You can check to see the performance of the capped-cpu zone using the prstat -Z command.
The percentage (of the global CPU resource) utilized by each zone will be listed with each zone in its summary line.

No comments:

Post a Comment