このコンテンツは選択した言語では利用できません。
3.2. Configure Page Memory
Page memory configuration to optimize Red Hat JBoss Data Grid's performance must be implement at the operating system level and at the JVM level. The provided instructions are for the Red Hat Enterprise Linux operating system. Use both the operating system level and JVM level instructions for optimal performance.
Procedure 3.1. Configure Page Memory for Red Hat Enterprise Linux
Set the Shared Memory Segment Size
As root, set the maximum size of a shared memory segment in bytes; below we define this to be 32 GB:echo "kernel.shmmax = 34359738368" >> /etc/sysctl.conf
# echo "kernel.shmmax = 34359738368" >> /etc/sysctl.confCopy to Clipboard Copied! Toggle word wrap Toggle overflow Set the Huge Pages
The number of huge pages is set to the total amount of memory the JVM will consume (heap, meta space, thread stacks, native code) divided by theHugepagesize. In Red Hat Enterprise Linux systemsHugepagesizeis set to 2048 MB.- The number of huge pages required can be determined by the following formula:
Heap + Meta space + Native JVM Memory + (Number of Threads * Thread Stack Size)
Heap + Meta space + Native JVM Memory + (Number of Threads * Thread Stack Size)Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Assuming a JVM with a 32 GB Heap, 2 GB of Meta space, a 512 MB native footprint, and 500 threads, each with a default size of 1 MB per thread, we have the following equation.
32*(1024*1024*1024) + 2*(1024*1024*1024) + 512*(1024*1024) + (500 * 1024*1024)
32*(1024*1024*1024) + 2*(1024*1024*1024) + 512*(1024*1024) + (500 * 1024*1024)Copy to Clipboard Copied! Toggle word wrap Toggle overflow - The resulting value can now be converted to hugepages. Since there are 2048 MB in a single hugepage we perform the following:
37568380928 / (2*1024*1024)
37568380928 / (2*1024*1024)Copy to Clipboard Copied! Toggle word wrap Toggle overflow
As root, set the number of huge pages determined from the previous steps to be allocated to the operating system:echo "vm.nr_hugepages = 17914" >> /etc/sysctl.conf
# echo "vm.nr_hugepages = 17914" >> /etc/sysctl.confCopy to Clipboard Copied! Toggle word wrap Toggle overflow Assign Shared Memory Segment Permissions
As root, set the ID of the user group that is allowed to create shared memory segments using thehugetlb_shm_groupfile. This value should match the group id of the user running the JVM:echo "vm.hugetlb_shm_group = 500" >> /etc/sysctl.conf
# echo "vm.hugetlb_shm_group = 500" >> /etc/sysctl.confCopy to Clipboard Copied! Toggle word wrap Toggle overflow Update the Resource Limits
To allow a user to lock the required amount of memory, update the resource limits in the/etc/security/limits.conffile by adding the following:jboss soft memlock unlimited jboss hard memlock unlimited
jboss soft memlock unlimited jboss hard memlock unlimitedCopy to Clipboard Copied! Toggle word wrap Toggle overflow This change allows the userjbossto lock the system's available memory.Configure Authentication using PAM
Linux's PAM handles authentication for applications and services. Ensure that the configured system resource limits apply when usingsuandsudoas follows:Configure PAM for su
Add the following line to the/etc/pam.d/sufile:session required pam_limits.so
session required pam_limits.soCopy to Clipboard Copied! Toggle word wrap Toggle overflow Configure PAM for sudo
Add the following line to the/etc/pam.d/sudofile:session required pam_limits.so
session required pam_limits.soCopy to Clipboard Copied! Toggle word wrap Toggle overflow
- Reboot the system for the changes to take effect. Since Huge Pages allocate a contiguous block of memory these must be allocated at system boot; attempts to claim these dynamically while the system is running may result in system hangs if the memory is unable to be reclaimed.
Procedure 3.2. Configure Page Memory for the JVM
Set the Heap Size
Use the-Xmsand-Xmxparameters to set the minumum and maximum heap sizes for your JVM, as discussed in Chapter 2, Java Virtual Machine Settings.Enable Large Pages
Enabled large pages for the JVM by adding the following parameter, as discussed in Chapter 2, Java Virtual Machine Settings:-XX:+UseLargePages
-XX:+UseLargePagesCopy to Clipboard Copied! Toggle word wrap Toggle overflow