linux 进程数最大值修改
2015-12-30 16:50
573 查看
实际的系统进程数上限收到3个配置项的影响:
1、threads-max (/proc/sys/kernel/threads_max)
这个值表示物理内存决定的系统进程数上限,fork_init中有:
max_threads = mempages / (THREAD_SIZE/PAGE_SIZE) / 8
2、pid_max (/proc/sys/kernel/pid_max)
这个值表示进程ID的上限。为了兼容旧版,默认为32768(即两个字节)。
3、RLIMIT_NPROC (ulimit -u 或者 getrlimit)
这个值表示单个用户允许的最大进程数上限。系统默认为threads-max的一半:
init_task.rlim[RLIMIT_NPROC].rlim_cur = max_threads/2;
init_task.rlim[RLIMIT_NPROC].rlim_max = max_threads/2;
实验:
某环境上:
threads-max = 139264;
pid_max = 32768
RLIMIT_NPROC = 69632
1、此时,使用根用户不断创建进程,最终创建了约32378,考虑到原有的进程数,比较接近pid_max这个值;
2、改pid_max为18000时,最终创建了17612个进程;
3、修改pid_max为80000,换成普通用户,最终创建了67913个进程
1、threads-max (/proc/sys/kernel/threads_max)
这个值表示物理内存决定的系统进程数上限,fork_init中有:
max_threads = mempages / (THREAD_SIZE/PAGE_SIZE) / 8
2、pid_max (/proc/sys/kernel/pid_max)
这个值表示进程ID的上限。为了兼容旧版,默认为32768(即两个字节)。
<code class="hljs ruby has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">echo <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4194303</span> > <span class="hljs-regexp" style="color: rgb(0, 136, 0); box-sizing: border-box;">/proc/sys</span><span class="hljs-regexp" style="color: rgb(0, 136, 0); box-sizing: border-box;">/kernel/pid</span>_max</code>
3、RLIMIT_NPROC (ulimit -u 或者 getrlimit)
这个值表示单个用户允许的最大进程数上限。系统默认为threads-max的一半:
init_task.rlim[RLIMIT_NPROC].rlim_cur = max_threads/2;
init_task.rlim[RLIMIT_NPROC].rlim_max = max_threads/2;
实验:
某环境上:
threads-max = 139264;
pid_max = 32768
RLIMIT_NPROC = 69632
1、此时,使用根用户不断创建进程,最终创建了约32378,考虑到原有的进程数,比较接近pid_max这个值;
2、改pid_max为18000时,最终创建了17612个进程;
3、修改pid_max为80000,换成普通用户,最终创建了67913个进程
相关文章推荐
- 《Linux设备驱动程序开发详解》中的virtualBox下的ubuntu在vmware下使用
- VirtualBox双网卡实现虚拟机Linux CentOS 7上网以及主宿互访
- Linux 运维实践案例-2015年12月20日-12月31日
- 初探CentOS搭建SVN服务器
- linux下用ctrl+r快速搜索history命令
- Linux命令之stty - 显示和修改终端行设置
- linux命令行编辑快捷键
- linux中grep命令
- Linux下PHP扩展编译的通用方法
- CentOS下的SVN服务器搭建过程以及分析
- centos6.7-keepalived-DNS-ntp一主一从服务器端配置
- Embedded Linux 启动时间优化
- yum方式安装MySQL5.7-centos6.4 64位
- Linux下git生成 ssh key 的方法
- CentOS6.5安装Mysql5.5
- 用十条命令在一分钟内检查Linux服务器性能
- Linux 安装、卸载程序
- CentOS 7.2基于Kubernetes部署简单应用示例
- Linux安装
- 我眼中的Linux设备树(六 memory&chosen节点)