Maximum number of processes in linux

LinuxProcessOperating System

Linux Problem Overview


What is the maximum limit to the number of processes possible in a linux system? How can we find it ?

Linux Solutions


Solution 1 - Linux

Your kernel should export this information in procfs:

cat /proc/sys/kernel/pid_max

This is the maximum number of unique process identifiers your system can support.

Since it is a file, /proc/sys/kernel/pid_max can be inspected from any capable programming language.

Solution 2 - Linux

> sysctl kernel.pid_max

or

> cat /proc/sys/kernel/pid_max

As suggested by Ninefingers.

For completeness, you can change it temporarily by writing to /proc/syskernel/pid_max or permanently by adding:

> kernel.pid_max = 4194303

to /etc/sysctl.conf. 4194303 is the maximum limit for x86_64 and 32767 for x86.

Solution 3 - Linux

Short answer to your question : Number of process possible in the linux system is UNLIMITED.

But there is a limit on number of process per user(except root who has no limit).

And you can check your user limits with below command (apposite to "max user processes").

$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 256447
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 128000
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 500000
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

If you want to increase the limit on number of process for a particular user(for eg: hadoop ) , you need to make below entry in /etc/security/limits.conf

hadoop - nproc 500000

Solution 4 - Linux

kernel.pid_max is a limiting factor, but at least as important is kernel.threads-max. It's worth noting that the default nproc ulimit for each user is kernel.threads-max divided by two, and that every thread counts toward a user's nproc limit. Thus, ps -u $USER may make it appear that a user has not exhausted their nproc limit, but ps -L -u $USER could tell a very different story.

Solution 5 - Linux

Did you mean that a mongodb process can only create with max nproc = threads-max / 2 ?

Because i'm trying to increase nproc as unlimited.

I tried to put limits on /etc/security/limits.conf as like this:

mongodb       soft        nproc      unlimited
mongodb       hard      nproc        unlimited
mongodb       soft       nofile      50000
mongodb       hard      nofile      50000
mongodb soft    sigpending      unlimited
mongodb hard    sigpending      unlimited

However it didn'r reflect on mongodb process even after complete reboot.

Then i tried to put ulimit -u unlimited command to /etc/init.d/mongodb but after i tried to start with this file i got

/etc/init.d/mongodb: 67: ulimit: Illegal option -u

error. Is this kernel.threads-max is limiting mongodb max process count?

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionkdexterView Question on Stackoverflow
Solution 1 - Linuxuser257111View Answer on Stackoverflow
Solution 2 - LinuxLester CheungView Answer on Stackoverflow
Solution 3 - LinuxAnkit SinghalView Answer on Stackoverflow
Solution 4 - LinuxAndy GrimmView Answer on Stackoverflow
Solution 5 - Linuxhardc0derView Answer on Stackoverflow