nginx

説明

nginxが同時に開けファイル数の制御の設定です。

手順

# ab -c 1024 -n 10240 http://hogehoge.com/
Too many open files
# ps aux | grep nginx
root     13206  0.0  0.0  44720  1184 ?        Ss   18:53   0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx    13207  1.0  0.0  45212  2276 ?        S    18:53   0:00 nginx: worker process 
nginx    13208  0.0  0.0  45108  1916 ?        S    18:53   0:00 nginx: worker process
nginx    13209  0.5  0.0  45212  2276 ?        S    18:53   0:00 nginx: worker process
nginx    13210  0.0  0.0  45108  1864 ?        S    18:53   0:00 nginx: worker process
# cat /proc/プロセスID/limit
# cat /proc/13207/limits
Limit                     Soft Limit           Hard Limit           Units
Max cpu time              unlimited            unlimited            seconds
Max file size             unlimited            unlimited            bytes
Max data size             unlimited            unlimited            bytes
Max stack size            10485760             unlimited            bytes
Max core file size        0                    unlimited            bytes
Max resident set          unlimited            unlimited            bytes
Max processes             30490                30490                processes
Max open files            1024                1024                files
Max locked memory         65536                65536                bytes
Max address space         unlimited            unlimited            bytes
Max file locks            unlimited            unlimited            locks
Max pending signals       30490                30490                signals
Max msgqueue size         819200               819200               bytes
Max nice priority         0                    0
Max realtime priority     0                    0
Max realtime timeout      unlimited            unlimited            us

# cd /etc/nginx/
# cp -p nginx.conf nginx.conf.`date +%Y%m%d`
# vi nginx.conf
--- 追記
worker_rlimit_nofile  8192;  <--ここ

events {
   worker_connections  1024;
}
---
# service nginx configtest
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
# service nginx resrart
# ps aux | grep nginx
root     13282  0.0  0.0  44752  1172 ?        Ss   18:58   0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx    13283  0.0  0.0  45204  1876 ?        S    18:58   0:00 nginx: worker process
nginx    13284  0.0  0.0  45204  1812 ?        S    18:58   0:00 nginx: worker process
nginx    13285  0.0  0.0  45204  1876 ?        S    18:58   0:00 nginx: worker process
nginx    13287  0.0  0.0  45204  1860 ?        S    18:58   0:00 nginx: worker process 
# cat /proc/13287/limits
Max open files            8192                 8192                 files    <-- worker_rlimit_nofileで記述した値が上書きされていることがわかる。

参考URL:http://www.1x1.jp/blog/2013/02/nginx_too_many_open_files_error.html


トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2022-06-30 (木) 01:40:11