CPU Limitation Per Database Instance
CPU Limitation Per Database Instance
Resource management always is a best tools for DBA to control consumption of databases that
live together in same server.
Resource consumption and limiting databases and PDBs can control on i/o, memory, cpu by
traditional or new features in oracle such as applying limit on PGA, SGA using pga aggregate
target and sga_target, sga_min_size and for controlling I/O usage we can use max_iops.
Using dbms_resource_manager package we can apply plan directives to handles cpu utilization.
In this post I demonstrate a another way to specify control CPU usage for databases that live side
by side on the same machine.
PURPOSE
This document provides a step-by-step guide for binding a database instance to a subset of a
server's CPUs and memory, using Linux cgroups. Cgroups provide a way to create a named set
of CPUs and memory.
A database instance that is associated with this cgroup can only use its CPUs and memory.
Using Linux cgroups, a DBA that is consolidating multiple database instances on a single server
can:
-Physically isolate database instances onto di erent CPUs
-Bind instances to speci c NUMA nodes to improve performance on NUMA-based systems.
First, check the number of CPUs, the NUMA con guration, and the existing cgroups (if any) for
your system:
setup_processor_group.sh –show
Next, prepare the system to use cgroups (this command can be repeated):
fi
fi
ff
fi
fi
setup_processor_group.sh –prepare
To check if the system is indeed ready:
setup_processor_group.sh –check
To create a new cgroup "mycg" for user "oracle" in group "dba" with CPUs 0 and 1, use the "-
create" option. With the "-cpu" option, you can provide either a comma-separated list or a range,
e.g. "–cpus 0-7,16-23".
You cannot use the "-create" option with both "–cpus" and "–numa_nodes".
In the output, you should see the cgroup name after the string "cpuset:/".
cat /proc/<pid>/cgroup
Use this Linux command to see all processes that are running in the cgroup (substitute <mycg>
with your cgroup name).
cat /mnt/cgroup/<mycg>/tasks
Best Practices
(1) Note that Linux cgroups allow databases and applications that are not associated with the
cgroup to use its CPU and memory.
(2) For processors with hyper-threading (e.g. x-86), con gure cgroups out of CPU threads, using
the "-cpus" option, from the minimum number of CPU cores and sockets. Do not assign the CPU
threads on a core to more than one cgroup.
These best practices enable much better isolation and performance since CPUs on a core share
many common resources, such as parts of the execution pipeline, caches, and TLBs.
For a list of the CPU threads, cores, and sockets, use the following commands:
The "-numa_nodes" option will ensure that the database instance allocates local memory for both
SGA and PGA, resulting in improved database performance.
-When consolidating a large number of databases, consider creating a few cgroups and binding
multiple database instances to each cgroup.
For example:
◦Create one cgroup per NUMA node. Bind multiple database instances to each NUMA node's
cgroup.
◦Create 2 cgroups, one for test databases and one for standby databases.
fi
fi
Linux Cgroups vs Virtualization
Linux cgroups and virtual machines (VMs) are both e ective tools for consolidating multiple
databases on a server.
Both tools provide resource isolation by dedicating CPU and memory to a database instance.
Database instances on VMs are isolated in a similar way as database instances on separate
physical servers. While this isolation o ers many obvious advantages, it also has the following
disadvantages:
◦Oracle Clusterware must be installed for each virtual machine. Databases in cgroups can share
one instance of the Oracle Clusterware.
Using Linux cgroups does not reduce Oracle database licensing costs. The license is based on
the number of CPUs on the server, not the database's cgroup size.
Regarding,
Alireza Kamrani
Senior RDBMS Consultant
ff
ff