Maximum number of threaded processes linux can run

cat /proc/sys/kernel/threads-max

The maximum number of threads supported by the lookup system, which is usually very large, is equivalent to the theoretical value

The command has different values on different machines.
On the centos server: 513845
On ubuntu16.04 pc: 62667

Both machines have different CPU and memory configurations

cat /proc/sys/kernel/pid_max

On the centos server: 32768
On ubuntu16.04 pc: 32768

The system limits the maximum number of processes or threads a user can run
-u Number of processes: The maximum number of processes a user can start.

ulimit

help ulimit

ulimit: ulimit [-SHacdefilmnpqrstuvx] [Restriction]
    Modify shell resource limits.

    On systems that allow this type of control, provide what is available to the shell and the processes it creates
    Control of resources.

    Options:
      -S uses `soft'(soft) resource constraints
      -H uses `hard'(hard) resource constraints
      -a All current restrictions are reported
      -b socket cache size
      Maximum size of core file created by -c
      -d Maximum size of a process's data area
      -e highest scheduling priority (`nice')
      -f has the maximum file size a shell and its subprocesses can write to
      -i Maximum number of signals that can be suspended
      -l Maximum memory size a process can lock
      -m Max Memory Pack Size
      -n Maximum number of open file descriptors
      -p Pipe Buffer Size
      Maximum number of bytes in-q POSIX information queue
      -r Maximum priority for real-time scheduling
      -s maximum stack size
      -t Maximum CPU time in seconds
      -u Max User Processes
      -v Virtual Memory Size
      -x Maximum number of locks

    If a LIMIT variable is provided, it is a new value for the specified resource; the special LIMIT value is
    `soft', `hard'and `unlimited', respectively, represent the current soft, hard, and unlimited constraints.
    Otherwise print the current limit for the specified resource, assuming -f without options

    Values are 1024 bytes, except -t in seconds and -p in 512 bytes.
    -u with no range of processes.

    Exit status:
    Return is successful unless invalid options are used or errors occur.

ulimit -u

Maximum number of processes a user can start.
4096

ulimit -a

Used to display current various user process constraints
Linux limits the maximum number of processes per user.To improve performance, depending on device resources

To set the maximum number of processes for each linux user, let me set the maximum number of processes for a linux user to 10,000:

 ulimit -u 10000 

 For Java applications that require many socket connections and keep them open,

 It is best to modify the number of open files per process by using ulimit-n xx, with a default value of 1024. 

 ulimit -n 4096 

  Increase the number of files that can be opened per process to 4096, defaulting to 1024     

 Some of the other important settings recommended to be unlimited are: 

 Data segment length: ulimit-d unlimited 

 Maximum memory size: ulimit-m unlimited 

 Stack size: ulimit-s unlimited 

 CPU time: ulimit-t unlimited 

 Virtual memory: ulimit-v unlimited 

Temporarily, for the duration of a shell session logged in through the ulimit command.

Ulimit-a parameter analysis

centos:

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

ubuntu:

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

Ali Yun:

[jack@ ~]$ 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) 7284
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 65535
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 4096
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

ulimit -n

Default maximum number of open files

On the centos server: 1000000
On ubuntu16.04 pc: 1024

 

 

57 original articles published, 546 awarded, 4.89 million visits+
His message board follow

Tags: CentOS shell Linux socket

Posted on Tue, 04 Feb 2020 21:12:47 -0500 by lucianbeauty