Can anyone explain in layman's terms what the difference between soft and hard limit is?
Should I set my soft and hard limit to be the same? Or should soft be significantly lower? Does the system benefit either way?
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
The hard limit is the ceiling for the soft limit. The soft limit is what is actually enforced for a session or process. This allows the administrator (or user) to set the hard limit to the maximum usage they wish to allow. Other users and processes can then use the soft limit to self-limit their resource usage to even lower levels if they so desire.
Users who violate a soft limit quota get an e-mail indicating that they have a few days' grace period before the penalties kick in. Users who cross the hard limit threshold get no such grace period. The penalty differs depending on the particular quota, but usually nearly every command will fail such that the user will want to come into compliance quickly.
User resource limits dictate the amount of resources that can be used for a particular session. The resources that can be controled are:
maximum size of core files maximum size of a process's data segment maximum size of files created maximum size that may be locked into memory maximum size of resident memory maximum number of file descriptors open at one time maximum size of the stack maximum amount of cpu time used maximum number of processes allowed maximum size of virtual memory available
It is important to note that these settings are per-session. This means that they are only effective for the time that the user is logged in (and for any processes that they run during that period). They are not global settings. In other words, they are only active for the duration of the session and the settings are not cumulative. For example, if you set the maximum number of processes to 11, the user may only have 11 processes running per session. They are not limited to 11 total processes on the machine as they may initiate another session. Each of the settings are per process settings during the session, with the exception of the maximum number of processes.
There are two types of limits that can be set for each property listed above, a hard and soft limit.
A hard limit cannot be changed by the user once it is set. Hard limits can only be changed by root user. A soft limit, however, can be changed by the user but cannot exceed the hard limit i.e. It can have minimum 0 value and maximum value as equal to 'hard limit'.
for more info