What is the maximum limit to the number of processes possible in a linux system? How can we find it ?
-
1Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See [What topics can I ask about here](http://stackoverflow.com/help/on-topic) in the Help Center. Perhaps [Super User](http://superuser.com/) or [Unix & Linux Stack Exchange](http://unix.stackexchange.com/) would be a better place to ask. – jww Dec 16 '17 at 00:33
5 Answers
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.

- 25,033
- 7
- 51
- 90
-
2this may be true, but in most nice distros this is limited by /etc/security/limits.conf which can filter max number of processes on user/group/domain basis. – Tomas Pruzina Feb 20 '12 at 13:27
-
1`ulimit` might limit the max per-user processes to less than the maximum pid, and from a bit of Googling, there's other limitations in play as well (but I couldn't find any definitive sources to confirm, such as LKML or a well known Dev posting it). – Kitsune Feb 20 '12 at 13:28
-
1`int fd = read("/proc/sys/kernel/pid_max");` is not valid, nor is it valid for any other file. – user253751 Jul 10 '16 at 12:52
-
@immibis I edited out the bogus C; hopefully my edit will be approved soon. – Michael Wolf Aug 30 '17 at 17:29
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.

- 1,964
- 16
- 17
-
3just tried `sysctl kernel.pid_max=4194304` and it succeeded (Linux 3.10.25) – zed_0xff May 06 '14 at 21:20
-
@zed_0xff as long as you are aware that the change is not persistent it's all good! – Lester Cheung May 08 '14 at 03:27
-
-
1The actual maximum is 32768 on 32 bit kernels, and 4194304 on 64 bit. However the maximum PID you will see is 1 less. See: https://unix.stackexchange.com/a/162105/23450 – Tino Jun 21 '17 at 10:44
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

- 834
- 7
- 8
-
Sometimes above change requires a restart to get the change in effect. – Ankit Singhal May 19 '14 at 17:32
-
1This begs a citation for the number is 'unlimited', for ulimit means it doesn't have a limit set (unlimited), but the number of processes the scheduler is allowed isn't unlimited ... as in infinite. The ulimit wasn't the question. – hpavc Mar 10 '16 at 04:22
-
-
It can't be unlimited since last but not least the hardware imposes limits. – maxschlepzig Dec 30 '17 at 11:08
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.

- 30,520
- 16
- 123
- 136

- 406
- 4
- 6
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?

- 449
- 2
- 7
- 13