Zones Capping

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
ID NAME STATUS PATH BRAND IP
0 global running / native shared
1 zone1 running /export/zones/zone1 native shared
2 zone2 running /export/zones/zone2 native shared
3 zone3 running /export/zones/zone3 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 zone1
zonecfg:zone1> add capped-memory
zonecfg:zone1:capped-memory> set physical=24G
zonecfg:zone1:capped-memory> set swap=10G
zonecfg:zone1:capped-memory> set locked=1G
zonecfg:zone1:capped-memory> end
zonecfg:zone1>commit
zonecfg:zone1>exit

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.

#zonecfg -z zone1
zonecfg:zone1>
zonecfg:zone1>add capped-cpu
zonecfg:zone1>capped-cpu> set ncpus=16
zonecfg:zone1>capped-cpu> end
zonecfg:zone1> commit
zonecfg:zone1> 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.

#zonecfg -z zone1
zonecfg:zone1>
zonecfg:zone1>add dedicated-cpu
zonecfg:zone1>dedicated-cpu> set ncpus=16
zonecfg:zone1>dedicated-cpu> end
zonecfg:zone1> commit
zonecfg:zone1> 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.

#zonecfg -z zone1 info

How to create new CPU resource pool in Solaris

Solaris 10 has many resource control model. Here we are going to see how to create new processor pool and how to associate processor set to it.Resource pools enable you to separate workloads so that workload consumption of certain resources does not overlap.

For an example, specific user process or specific application  process are consuming high CPU usage and  if you want to restrict those process to specific processors using pool.

So that specific  high CPU consumption process will not overload other CPU’s since we have bind the process to specific process.
Here we are going to see how to create processor set and how to assign to specific local zone.

Processor information:

karri#psrinfo -p
1
karri#psrinfo
0 on-line since 07/30/2012 01:45:54
1 on-line since 07/30/2012 01:45:58
Checking the current pool configuration:
karri#pooladm
pooladm: couldn't open pools state file: Facility is not active.
Activating the pool using the below command:
karri#pooladm -e
Checking the current pool configuration.

karri#pooladm
system default
string system.comment
int system.version 1
boolean system.bind-default true
string system.poold.objectives wt-load
pool pool_default
int pool.sys_id 0
boolean pool.active true
boolean pool.default true
int pool.importance 1
string pool.comment
pset pset_default
pset pset_default
int pset.sys_id -1
boolean pset.default true
uint pset.min 1
uint pset.max 65536
string pset.units population
uint pset.load 234
uint pset.size 2
string pset.comment
cpu
int cpu.sys_id 1
string cpu.comment
string cpu.status on-line
cpu
int cpu.sys_id 0
string cpu.comment
string cpu.status on-line
#poolcfg -c 'create pset arenazone-pset(uint pset.min=1;uint pset.max = 1)'
poolcfg: cannot load configuration from /etc/pooladm.conf: No such file or directory.

To save the current pool configuration.

karri#pooladm -s
The above command will create /etc/pooladm.conf.
karri#poolcfg -c 'create pset arenazone-pset(uint pset.min=1; uint pset.max=1)'

The above command created the pset with one processor core in the name of karrizone-pset.

Creating  the new pool called karrizone-pool

zone1#poolcfg -c 'create pool karrizone-pool'
Associating the karrizone-pset with karrizone-pool
zone1#poolcfg -c 'associate pool karrizone-pool(pset karrizone-pset)'

Now have processor pool with one CPU core.

Instantiate the configuration

zone1#pooladm -c

To verify the configuration

zone1#pooladm
system default
string system.comment
int system.version 1
boolean system.bind-default true
string system.poold.objectives wt-load
pool pool_default
int pool.sys_id 0
boolean pool.active true
boolean pool.default true
int pool.importance 1
string pool.comment
pset pset_default
pool zone1-pool
int pool.sys_id 2
boolean pool.active true
boolean pool.default false
int pool.importance 1
string pool.comment
pset zone1-pset
pset zone1-pset
int pset.sys_id 1
boolean pset.default false
uint pset.min 1
uint pset.max 1
string pset.units population
uint pset.load 0
uint pset.size 1
string pset.comment
cpu
int cpu.sys_id 0
string cpu.comment
string cpu.status on-line
pset pset_default
int pset.sys_id -1
boolean pset.default true
uint pset.min 1
uint pset.max 65536
string pset.units population
uint pset.load 38
uint pset.size 1
string pset.comment
cpu
int cpu.sys_id 1
string cpu.comment
string cpu.status on-line

Note:In the above output, you can see that one processor core has been removed from pool_default and assigned to zone1-pool.
You can see the changes in /etc/pooladm.conf as well.
Assigning the processor pool to local zone:
Using zonecfg,we can associate an exiting pool to an existing zone using the set pool option.

# zonecfg -z zone1
zonecfg:zone1> set pool=zone1-pool
zonecfg:zone1> verify
zonecfg:zone1> exit
#

By doing this zone will be restricted to use CPU cores which are assigned to that pool.