5.4. Capacity Tuning
Read this section for an outline of memory, kernel and file system capacity, the parameters related to each, and the trade-offs involved in adjusting these parameters.
To set these values temporarily during tuning, echo the desired value to the appropriate file in the proc file system. For example, to set
# echo 1 > /proc/sys/vm/overcommit_memory
Note that the path to the parameter in the proc file system varies depending on the system affected by the change.
To set these values persistently, use the
sysctlcommand. For information on how to use
sysctl, see E.4. Using the sysctl Command in the Red Hat Enterprise Linux 6 Deployment Guide.
Starting with Red Hat Enterprise Linux 6.6, the
/proc/meminfofile provides the
MemAvailablefield. To determine how much memory is available, run:
# cat /proc/meminfo | grep MemAvailable
Capacity-related Memory Tunables
Each of the following parameters is located under
/proc/sys/vm/in the proc file system.
- Defines the conditions that determine whether a large memory request is accepted or denied. There are three possible values for this parameter:
0— The default setting. The kernel performs heuristic memory overcommit handling by estimating the amount of memory available and failing requests that are blatantly invalid. Unfortunately, since memory is allocated using a heuristic rather than a precise algorithm, this setting can sometimes allow available memory on the system to be overloaded.
1— The kernel performs no memory overcommit handling. Under this setting, the potential for memory overload is increased, but so is performance for memory-intensive tasks.
2— The kernel denies requests for memory equal to or larger than the sum of total available swap and the percentage of physical RAM specified in
overcommit_ratio. This setting is best if you want a lesser risk of memory overcommitment.
NoteThis setting is only recommended for systems with swap areas larger than their physical memory.
- Specifies the percentage of physical RAM considered when
overcommit_memoryis set to
2. The default value is
- Defines the maximum number of memory map areas that a process may use. In most cases, the default value of
65530is appropriate. Increase this value if your application needs to map more than this number of files.
- Defines the number of hugepages configured in the kernel. The default value is 0. It is only possible to allocate (or deallocate) hugepages if there are sufficient physically contiguous free pages in the system. Pages reserved by this parameter cannot be used for other purposes. Further information is available from the installed documentation:
/usr/share/doc/kernel-doc-kernel_version/Documentation/vm/hugetlbpage.txt.For an Oracle database workload, Red Hat recommends configuring a number of hugepages equivalent to slightly more than the total size of the system global area of all databases running on the system. 5 additional hugepages per database instance is sufficient.
Capacity-related Kernel Tunables
Default values for the following parameters, located in the
/proc/sys/kernel/directory, can be calculated by the kernel at boot time depending on available system resources.
To determine the page size, enter:
# getconf PAGE_SIZE
To determine the huge page size, enter:
# grep Hugepagesize /proc/meminfo
- Defines the maximum allowable size in bytes of any single message in a message queue. This value must not exceed the size of the queue (
msgmnb). To determine the current
msgmaxvalue on your system, enter:
# sysctl kernel.msgmax
- Defines the maximum size in bytes of a single message queue. To determine the current
msgmnbvalue on your system, enter:
# sysctl kernel.msgmnb
- Defines the maximum number of message queue identifiers (and therefore the maximum number of queues). To determine the current
msgmnivalue on your system, enter:
# sysctl kernel.msgmni
- Semaphores, counters that help synchronize processes and threads, are generally configured to assist with database workloads. Recommended values vary between databases. See your database documentation for details about semaphore values.This parameter takes four values, separated by spaces, that represent SEMMSL, SEMMNS, SEMOPM, and SEMMNI respectively.
- Defines the total number of shared memory pages that can be used on the system at one time. For database workloads, Red Hat recommends that this value is set to the result of
shmmaxdivided by the hugepage size. However, Red Hat recommends checking your vendor documentation for recommended values. To determine the current
shmallvalue on your system, enter:
- Defines the maximum shared memory segment allowed by the kernel, in bytes. For database workloads, Red Hat recommends a value no larger than 75% of the total memory on the system. However, Red Hat recommends checking your vendor documentation for recommended values. To determine the current
shmmaxvalue on your system, enter:
# sysctl kernel.shmmax
- Defines the system-wide maximum number of shared memory segments. The default value is
4096on all systems.
- Defines the system-wide maximum number of threads (tasks) to be used by the kernel at one time. To determine the current
threads-maxvalue on your system, enter:
# sysctl kernel.threads-maxThe default value is the result of:
mempages / (8 * THREAD_SIZE / PAGE_SIZE )The minimum value of
Capacity-related File System Tunables
Each of the following parameters is located under
/proc/sys/fs/in the proc file system.
- Defines the maximum allowed number of events in all active asynchronous I/O contexts. The default value is
65536. Note that changing this value does not pre-allocate or resize any kernel data structures.
- Lists the maximum number of file handles that the kernel allocates. The default value matches the value of
files_stat.max_filesin the kernel, which is set to the largest value out of either
(mempages * (PAGE_SIZE / 1024)) / 10, or
NR_FILE(8192 in Red Hat Enterprise Linux). Raising this value can resolve errors caused by a lack of available file handles.
Out-of-Memory Kill Tunables
Out of Memory (OOM) refers to a computing state where all available memory, including swap space, has been allocated. By default, this situation causes the system to panic and stop functioning as expected. However, setting the
0instructs the kernel to call the
oom_killerfunction when OOM occurs. Usually,
oom_killercan kill rogue processes and the system survives.
The following parameter can be set on a per-process basis, giving you increased control over which processes are killed by the
oom_killerfunction. It is located under
/proc/pid/in the proc file system, where pid is the process ID number.
- Defines a value from
15that helps determine the
oom_scoreof a process. The higher the
oom_scorevalue, the more likely the process will be killed by the
oom_killer. Setting a
oom_killerfor that process.
ImportantAny processes spawned by an adjusted process will inherit that process's
oom_score. For example, if an
sshdprocess is protected from the
oom_killerfunction, all processes initiated by that SSH session will also be protected. This can affect the
oom_killerfunction's ability to salvage the system if OOM occurs.