Saturday, April 06, 2013

Solaris Kernel Tuning

sysdef -i reports on several system resource limits. Other parameters can be checked on a running system using adb -k :

adb -k /dev/ksyms /dev/mem
parameter-name/D
^D
(to exit)

More information on kernel tuning is available in Sun's online documentation.

maxusers

maxusers is the most frequently tuned kernel parameter. Its original use (as an overall limit to the number of concurrent users on a system) is much less important than its role as a basis for calculating other kernel parameters.

The default value is set to either the number of MB of physical memory or MAX_DEFAULT_MAXUSERS, whichever is lower.

For Solaris 2.5.1-7, MAX_DEFAULT_MAXUSERS is 1024. For Solaris 8-10, MAX_DEFAULT_MAXUSERS is 2048.

maxusers can be set explicitly in the /etc/system file, but is limited to 2x MAX_DEFAULT_MAXUSERS.

Several key kernel parameters are set when maxusers is set unless explicitly overridden in the /etc/system file. Some of these formulas differ between different versions of Solaris:

  • max_nprocs: Number of processes = 10 + (16 x maxusers)
  • ufs_ninode: Inode cache size = (17xmaxusers)+90 (Solaris 2.5.1) or 4x(maxusers + max_nprocs)+320 (Solaris 2.6-8). See the Disk I/O page for more information.
  • ncsize: Name lookup cache size = (17xmaxusers)+90 (Solaris 2.5.1) or 4x(maxusers + max_nprocs)+320 (Solaris 2.6-8). See the Disk I/O page for more information.
  • ndquot: Quota table size = (maxusers x 10) + max_nprocs
  • maxuprc: User process limit = max_nprocs - 5

ptys

Solaris 8+ dynamically sizes the number of ptys available to a system, so you are less likely to run into pty starvation than was the case under Solaris 2.5.1-7. There are still hard system limits that are set based upon hardware configuration, and it may be necessary to increase the number of ptys manually as in Solaris 2.5.1-7.

If the system is suffering from pty starvation, the number of ptys available can be increased by increasing pt_cnt above the default of 48. Solaris 2.5.1 and 2.6 systems should not have pt_cnt set higher than 3844 due to limitations with the telnet and rlogin daemons. Solaris 7 does not have this restriction, but there may be other system issues that prevent setting pt_cnt arbitrarily high. Once pt_cnt is increased, a reconfiguration boot (boot -r) is required to build the ptys.

If pt_cnt is increased, some sources recommend that other variables be set at the same time. Other sources (such as the Solaris2 FAQ) suggest that this advice is spurious and results in a needless consumption of resources. See the notes below before making any of these changes; setting the values too high may result in wasted memory. In any case, one form of these recommendations is:

  • npty: Set to pt_cnt (see the note below)
  • nautopush: Set to twice the value of pt_cnt
  • sadcnt: Set to same value as pt_cnt

npty limits the number of BSD ptys. These are not usually used by applications, but may need to be increased on a system running a special service. In addition to setting npty in the /etc/system file, the /etc/iu.ap file will need to be edited to substitute the value npty-1 in the third field of the ptsl line. After both changes are made, a boot -r is required for the changes to take effect. Note that Solaris does not support any more than 176 BSD ptys in any case.

sadcnt sets the number of STREAMS addressable devices and nautopush sets the number of STREAMS autopush entries. nautopush should be set to twice sadcnt. Whether or not these values need to be increased as above depends on the types of activity on the system.

RAM Tuneables

See the Memory/Swapping page for a discussion of parameters related to RAM and paging.

Disk I/O Tuneables

See the Disk I/O page for a full discussion of disk I/O-related tuneables.

IPC Tuneables

Check the IPC Tuning page for InterProcess Communication-related resource parameters.

File Descriptors

See the File Descriptors page for more discussion regarding tuning issues.

File descriptors are retired when the file is closed or the process terminates. Opens always choose the lowest-numbered file descriptor available. Available file descriptors are allocated as follows:

  • rlim_fd_cur: If you are running old code, it is dangerous to set this value higher than 256 due to limitations with the stdio library. If programs require more file descriptors, they should use setrlimit directly.
  • rlim_fd_max: If you are running old code, it is dangerous to set this value higher than 1024 due to limitations with select(). If programs require more file descriptors, they should use setrlimit directly.

(The cautionary notes on both of these items become less important as applications are re-written to use poll() rather than select(), or are developed as native 64-bit applications. Any changes should be tested in a non-production environment before deployment. The Solaris2 FAQ includes a discussion of this issue.)

Misc Tuneables

  • dump_cnt: Size of dumps.
  • rstchown: Posix/restricted chown enabled (default=1)
  • ngroups_max: Maximum number of supplementary groups per user (default=32).

No comments: