Solaris Zone’s Resource capping – MEMORY-CPU

Solaris Zone’s Resource capping:  Resource capping is nothing but Limiting the system resources like CPU,Memory,SWAP  to local zone.For an example, if you are running local zones without a resource capping,there may be high possibility that one zone will consume all the global zone resources and it will effect other local zones which are running the same global zone.We do not want to put the system in such a situation. It’s better to put resource  capping on  each local zones to avoid such a situation. 

What are the system resource can be capped in Solaris local zones ?
1.Physical Memory & SWAP capping
2.CPU capping

The resource capping daemon(rcapd) is responsible for the resource capping .See the Man page of rcapd.

Assumptions: The below mentioned local  zones are running without any resource capping.

#zoneadm list -cv
0 global running / native shared
1 uarena11103 running /export/zones/uarena11103 native shared
2 uarena11105 running /export/zones/uarena11105 native shared
3 uarena11106 running /export/zones/uarena11106 native shared
4 uarena11107 running /export/zones/uarena11107 native shared
5 uarena11108 running /export/zones/uarena11108 native shared
6 uarena11109 running /export/zones/uarena11109 native shared

Verifying the capping on all the zones,

# cd /etc/zones
# grep -i mem *
# grep -i cpu *

As per above output, no capping has been made on the local zones.

Memory Capping:
To perform the memory capping,Login to global zone and perform the below. Here i am setting capping for physical memory ,SWAP.

zonecfg -z uarena11105
zonecfg:uarena11105> add capped-memory
zonecfg:uarena11105:capped-memory> set physical=24G
zonecfg:uarena11105:capped-memory> set swap=10G
zonecfg:uarena11105:capped-memory> set locked=1G
zonecfg:uarena11105:capped-memory> end

As per the above settings,local zone uarena11105 can use up to 24GB of physical memory from global and it can utilize swap up to 10GB. Locked memory is nothing but a physical memory which is dedicated physical memory to that localzone. 

CPU capping:
As like the memory capping ,we can cap the CPU’s to local zone. CPU is a key resource for applications and its needs to be divided across the local zone according to the requirement.To perform the CPU capping,login to global zone and perform the below.
To determine the no of physical CPU’s in your global zone,use “psrinfo -pv” command.

MYGLOBAL#zonecfg -z uarena11105
zonecfg:uarena11105>add capped-cpu
zonecfg:uarena11105>capped-cpu> set ncpus=16
zonecfg:uarena11105>capped-cpu> end
zonecfg:uarena11105> commit
zonecfg:uarena11105> exit

As per the above command uarena11105 zone can use up to 16 CPU’s.

For CPU resource ,we have an option to assign dedicated CPU’s to the local zones.By doing that global & other local zones can’t use the those dedicated CPU’s which we have assigned to the zone.Here we will see how to perform that.

MYGLOBAL#zonecfg -z uarena11105
zonecfg:uarena11105>add dedicated-cpu
zonecfg:uarena11105>dedicated-cpu> set ncpus=16
zonecfg:uarena11105>dedicated-cpu> end
zonecfg:uarena11105> commit
zonecfg:uarena11105> exit

The above command will set 16 dedicated CPU’s to zone uarena11105.If you want you can set importance to specific CPU by set property “set importance=2” in dedicated-cpu field. 

You can verify the setting using below command.

MYGLOBAL#zonecfg -z uarena11105 info 

For your information this setting will be an immediate effect.You need to reboot the local zone to take effect of these resource allocation.But we can change the resource allocation dynamically using rcapadm & prctl command.

Thank you for reading this article. Please leave a comment if you have any doubt .I will get back to you. 


One comment

  1. If we set importance to specific CPU, “set importance=2”… what happens… What does it mean by importance here.
    Could you please explain me.