如何防止进程号一直上涨

用的阿里云镜像创建的服务器,开机后,基本上用2天,进程号就到万级别了,有没有办法让系统继续回用之前已经废弃的进程号呢?每次杀进程都要输入一个6位的数字确实听麻烦的,有时候还得输好几个

讨论数量: 8

进程号达到设置上限之后才会从头开始使用未被占用的进程号,你觉得输入麻烦,可以在启动的时候写入进程号到缓存,然后写个脚本kill进程就好了

1年前 评论
poker_face (楼主) 1年前
minororange 1年前
ps -ef | grep process | awk '{print $2}' | xargs kill -9
1年前 评论
poker_face (楼主) 1年前

php-fpm 进程设置的相关参数

pm = dynamic
pm.max_children = 5
pm.start_servers = 3
pm.min_spare_servers = 2
pm.max_spare_servers = 4
pm.max_requests = 200
 ; Choose how the process manager will control the number of child processes.
; Possible Values:
;   static  - a fixed number (pm.max_children) of child processes;
;   dynamic - the number of child processes are set dynamically based on the
;             following directives. With this process management, there will be
;             always at least 1 children.
;             pm.max_children      - the maximum number of children that can
;                                    be alive at the same time.
;             pm.start_servers     - the number of children created on startup.
;             pm.min_spare_servers - the minimum number of children in 'idle'
;                                    state (waiting to process). If the number
;                                    of 'idle' processes is less than this
;                                    number then some children will be created.
;             pm.max_spare_servers - the maximum number of children in 'idle'
;                                    state (waiting to process). If the number
;                                    of 'idle' processes is greater than this
;                                    number then some children will be killed.
;  ondemand - no children are created at startup. Children will be forked when
;             new requests will connect. The following parameter are used:
;             pm.max_children           - the maximum number of children that
;                                         can be alive at the same time.
;             pm.process_idle_timeout   - The number of seconds after which
;                                         an idle process will be killed.
; Note: This value is mandatory.

dynamic 是动态的,来了请求就会创建子进程,最大进程数跟 pm.max_children 有关。比较适合应对突发流量。

static 是静态的,php-fpm 启动的时候就已经把子进程创建好了。比较适合流量均衡的场景。

1年前 评论
poker_face (楼主) 1年前
minororange (作者) 1年前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!