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 overcommit_memory temporarily to 1, run:
# 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, you will need to use the sysctl command. For further details, refer to the Deployment Guide, available from http://access.redhat.com/site/documentation/Red_Hat_Enterprise_Linux/.

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.


    This setting is only recommended for systems with swap areas larger than their physical memory.
Specifies the percentage of physical RAM considered when overcommit_memory is set to 2. The default value is 50.
Defines the maximum number of memory map areas that a process may use. In most cases, the default value of 65530 is 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

Each of the following parameters is located under /proc/sys/kernel/ in the proc file system.
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). The default value is 65536.
Defines the maximum size in bytes of a single message queue. The default value is 65536 bytes.
Defines the maximum number of message queue identifiers (and therefore the maximum number of queues). The default value scales with the number of low memory pages, and is calculated by subtracting the number of high memory pages from the total number of pages, dividing the result by 32, multiplying by the page size in bytes, and then dividing by the value of MSGMNB.
Semaphores — counters that help synchronize processes and threads — are generally configured to assist with database workloads. Recommended values vary between databases; consult 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 shmmax divided by the hugepage size. However, Red Hat recommends checking your vendor documentation for recommended values.
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.
Defines the system-wide maximum number of shared memory segments. The default value is 4096 on both 64-bit and 32-bit architectures.
Defines the system-wide maximum number of threads (tasks) to be used by the kernel at one time. The default value is equal to the kernel max_threads value. The formula in use is:
max_threads = mempages / (8 * THREAD_SIZE / PAGE_SIZE )
The minimum value of threads-max is 20.

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_files in 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 /proc/sys/vm/panic_on_oom parameter to 0 instructs the kernel to call the oom_killer function when OOM occurs. Usually, oom_killer can 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_killer function. It is located under /proc/pid/ in the proc file system, where pid is the process ID number.
Defines a value from -16 to 15 that helps determine the oom_score of a process. The higher the oom_score value, the more likely the process will be killed by the oom_killer. Setting a oom_adj value of -17 disables the oom_killer for that process.


Any processes spawned by an adjusted process will inherit that process's oom_score. For example, if an sshd process is protected from the oom_killer function, all processes initiated by that SSH session will also be protected. This can affect the oom_killer function's ability to salvage the system if OOM occurs.