29 May 2008

Soft limit & Hard limit

Most of us encountered to increase the limit of file descriptors while installing a high end 3pp(party product).In doing so we will encounter with two different kinds of limits i.e.soft vs hard.

Hard limits are a kernel-configurable item and users can't exceed them. Soft limits are the user defaults and users can change that using the ulimit command.

Basically, soft limits can be changed to anything up to the hard limit. Soft limits are warning barrier. When a user reaches the soft limit they will get an warning message but are still allowed to use more space up to the hard limit.

Since its a kernel tunable we have to define the value in /etc/system and /etc/sysctl.conf for Pre-Solaris 10 and Linux respectively.

E.g.,

To set a hard limit of 4096 and soft limit of 1024 in Solaris 8.

set rlim_fd_max=4096 [Refers Hard limit]
set rlim_fd_cur=1024 [Refers Soft limit]


To raise the allowed limit in Linux based distributions update either /etc/limits.conf or /etc/security/limits.conf

1 comment:

Pranav said...

Hi,

What is the parameter to set in Solaris 10.
Can you also describe the file descriptor for ulimit.

In my server VCS is being used.

Limits configured are given below:
bash-3.2# ulimit -n -S (Soft limit)
256
bash-3.2#
bash-3.2# ulimit -n -H (Hard Limit)
65536

Now the process invoked in my application has 2048 file descriptors.

bash-3.2$ pfiles 22707 | head -2
22707: /opt/java///jre1.6.0_31/bin/amd64/java -server -Xms32m -Xmx512m -Djava
Current rlimit: 2048 file descriptors

I got to know that the value is set by VCS using a file
bash-3.2# grep -i ulimit /opt/VRTSvcs/bin/vcsenv
# Setting ulimit.
ulimit -t unlimited # CPU Time
ulimit -c unlimited # Core File Size
ulimit -d unlimited # Data Seg Size
ulimit -f unlimited # File Size
ulimit -n 2048 # File Descriptor
bash-3.2#

When I changed the File descriptor to ulimit -Sn 32767 in this vcsenv file & restarted veritas,the file descriptors in application process changed to 65536

bash-3.2# pfiles 28180 | head -2
28180: /opt/java///jre/bin/amd64/java -server -Xms32m -Xmx512m -Djava.endorse
Current rlimit: 65536 file descriptors


I want to know how the value changed to 65536 [ i.e.(32767+1)*2 ] when i have defined the soft limit as 32767.


Thanks in advance.