Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between nproc and ulimit?

Tags:

linux

unix

Ulimit and nproc are both used for limiting the system processes and resources for a particular user or application (correct me if I am wrong) in *nix system. What is the major difference between the two?

like image 543
udi Avatar asked Dec 14 '12 08:12

udi


People also ask

What is Nproc in Ulimit?

The maximum user processes (nproc) limit on Linux counts the number of threads within all processes that can exist for a given user. The default value of nproc is 1024 on some versions of Linux, which is generally an insufficient number of threads for all processes.

What is Nproc?

nproc is a simple Unix command which is used to print the number of processing units available in the system or to the current process. This command could be used in system diagnostics and related purposes.

What is Nproc and Nofile?

nproc: -u: processes/threads. MongoDB uses processes to track each internal thread or pthread as a system process. e.g replication thread. MongoDB shows a startup warning if nproc is not set as expected. This is generally set as 1/2 of the nofile for mongodb deployments.

What is Ulimit and Ulimit?

ulimit is a built-in Linux shell command that allows viewing or limiting system resource amounts that individual users consume. Limiting resource usage is valuable in environments with multiple users and system performance issues. In this tutorial, you will learn to use the ulimit command in Linux with examples.


1 Answers

 both are used for limiting the system processes and resources

If you are referring to the nproc parameter in limits.conf then yes it's for limiting the number of processes.

The shell utility ulimit is used for getting/setting resources' limits, too. For example, getting the stack size for each process:

$ulimit -s

Changing the stack size to 1MB:

$ulimit -s 1024

Changing the stack size to unlimited:

$ulimit -s unlimited

There's no difference between setting/changing resources via /etc/security/limits.conf`` andulimit`.

However, the shell utility ulimit changes are only applicable to the current shell. But /etc/security/limits.conf changes will be applicable system-wide for all the specified users. Besides /etc/security/limits.conf typically can be changed only by a privileged users.

But ulimit doesn't require privileges.

So you can think of ulimit as for temporary changes to resource limits just for you, which you can change yourself; whereas /etc/security/limits.conf is for system-wide setting (for one or more users) which you can't usually change (typically your system administrators sets resource limits, if any).


Whereas nproc(1) utliity is totally different which just lists the available number of processors.

like image 67
P.P Avatar answered Sep 23 '22 11:09

P.P