linux 进程线程限制,LINUX停每进程限制线程数量

参考:

http://stackoverflow.com/questions/344203/maximum-number-of-threads-per-process-in-linux

理论上相关限制的配置文件为:

/proc/sys/kernel/threads-max

/proc/sys/vm/max_map_count

实际上最大线程数计算为:

number of threads = total virtual memory / (stack size*1024*1024)

比如当前机器ulimit为:

socol@ubuntu:/etc/php5$ ulimit -a

core file size          (blocks, -c) unlimited

data seg size           (kbytes, -d) unlimited

scheduling priority             (-e) 0

file size               (blocks, -f) unlimited

pending signals                 (-i) 23963

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 (= 8k)

cpu time               (seconds, -t) unlimited

max user processes              (-u) 23963

virtual memory          (kbytes, -v) unlimited

file locks                      (-x) unlimited

内存大小为:

socol@ubuntu:/etc/php5$ top

top - 12:51:21 up 1 day,  6:44,  2 users,  load average: 0.02, 0.12, 0.17

Tasks: 189 total,   1 running, 185 sleeping,   0 stopped,   3 zombie

Cpu(s):  3.2%us,  1.3%sy,  0.0%ni, 95.5%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st

Mem:   3082008k total,  1606356k used,  1475652k free,   128260k buffers

Swap:   783356k total,     3512k used,   779844k free,   723588k cached

最大线程数为:

3082008k/(8*1024*1024) 约等于 376个线程,与实际测试结果相符。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值