linux stack size 作用,浅谈linux性能调优之九:改变系统默认限制

看了前两篇,我们都是在想办法节省资源给我们真正的服务。问题:我们的服务真的使用了吗 ? 答案是否定的,因为系统默认会有一些限制,这些限制也导致了我们应用的限制。这节我们说说linux下面的资源限制,我们来看看下面的数据:

[root@localhost Desktop]# 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) 15311

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) 10240

cpu time               (seconds, -t) unlimited

max user processes              (-u) 1024

virtual memory          (kbytes, -v) unlimited

file locks                      (-x) unlimited

这些是系统默认对一些资源或者行为的限制,/etc/security/limits.conf 文件中也有,linux下是使用文件描述符(也称为句柄)来进行操作的,一个进程能够打开文件的次数会影响到应用的并发度,像一些库文件。这个我写过简单 的C程序证明过。像apache,mysql,oracle这样对并发要求高的应用,(oracle在安装时便有这样的建议值)对这些一定要改变默认的限 制:

修改/etc/security/limits.conf

#

* soft nofile NNNNN

* hard nofile NNNNN

#

上面仅仅是例子,也可以使用ulimit添加自定义的限制(很多选项系统默认还开启),可以对一些不同用户进行限制

#

#        - core - limits the core file size (KB)

#        - data - max data size (KB)

#        - fsize - maximum filesize (KB)

#        - memlock - max locked-in-memory address space (KB)

#        - nofile - max number of open files

#        - rss - max resident set size (KB)

#        - stack - max stack size (KB)

#        - cpu - max CPU time (MIN)

#        - nproc - max number of processes

#        - as - address space limit (KB)

#        - maxlogins - max number of logins for this user

#        - maxsyslogins - max number of logins on the system

#        - priority - the priority to run user process with

#        - locks - max number of file locks the user can hold

#        - sigpending - max number of pending signals

#        - msgqueue - max memory used by POSIX message queues (bytes)

#        - nice - max nice priority allowed to raise to values: [-20, 19]

#        - rtprio - max realtime priority

#

建议阅读:http://www.ibm.com/developerworks/cn/linux/l-cn-ulimit/

http://blog.sina.com.cn/s/blog_59b6af6901011ekd.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值