第 52 章 Web Server Optimization
生活随笔
收集整理的這篇文章主要介紹了
第 52 章 Web Server Optimization
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
系統(tǒng)配置
52.1.?ulimit
查看 ulimit
ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited file size (blocks, -f) unlimited pending signals (-i) 1024 max locked memory (kbytes, -l) 32 max memory size (kbytes, -m) unlimited open files (-n) 1024 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 stack size (kbytes, -s) 2048 cpu time (seconds, -t) unlimited max user processes (-u) 77824 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited52.1.1.?open files
對于linux系統(tǒng),所有設(shè)備都以映射為設(shè)備文件的方式存在,包括硬件(鍵盤,鼠標(biāo),打印機(jī),顯示器,串口,并口,USB,硬盤,內(nèi)存,網(wǎng)卡,聲卡,顯卡,等等....),還有軟件(管道,socket),訪問這些資源,就相當(dāng)與打開一個(gè)文件,
所以"open files"文件數(shù)限制很重要,默認(rèn)值根本不能滿足我們。
查看文件打開數(shù)
$ cat /proc/sys/fs/file-nr3200 0 197957 已分配文件句柄的數(shù)目 已使用文件句柄的數(shù)目 文件句柄的最大數(shù)目查看所有進(jìn)程的文件打開數(shù)lsof |wc -l 查看某個(gè)進(jìn)程打開的文件數(shù)lsof -p pid |wc -l臨時(shí)更改
# ulimit -n 65536 or # ulimit -SHn 65536 or # echo "65535" > /proc/sys/fs/file-max永久更改
/etc/security/limits.conf
nobody soft nofile 40960 root soft nofile 40960 nobody hard nofile 40960 root hard nofile 40960 daemon soft nofile 40960 daemon hard nofile 40960更省事的方法
* soft nofile 40960 * hard nofile 40960最大線程數(shù)限制 threads-max
查看當(dāng)前值
# cat /proc/sys/kernel/threads-max 32624設(shè)置
有多種方法加大Linux的threads數(shù),下買是臨時(shí)更改
sysctl -w kernel.threads-max=65536 echo 65536 > /proc/sys/kernel/threads-max永久修改
編輯/etc/sysctl.conf 增加 kernel.threads-max = 65536 #sysctl -p 馬上生效以上數(shù)值僅供參考,隨著計(jì)算機(jī)發(fā)展,上面的值已經(jīng)不太適合,當(dāng)前流行的服務(wù)器。
原文出處:Netkiller 系列 手札
本文作者:陳景峯
轉(zhuǎn)載請與作者聯(lián)系,同時(shí)請務(wù)必標(biāo)明文章原始出處和作者信息及本聲明。
總結(jié)
以上是生活随笔為你收集整理的第 52 章 Web Server Optimization的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 学习记录 php,PHP进阶篇学习专用记
- 下一篇: java面向对象程序设计董小园_java