preforkのサーバは制限できてるけど、workerでは効いてないぽいので調べた。
設定
## 120 second RLimitCPU 120 ## 64M byte RLimitMEM 67108864
確認用のcgi
とりあえず無限ループするだけのcgi。RlimitCPUはプロセス生存時間じゃなくてCPU利用時間の制限なので sleep 1000 とかしても、CPUは使わないから制限の対象にはならないので。
#!/usr/bin/perl use strict; use warnings; use CGI; use CGI::Carp qw(fatalsToBrowser); my $q = CGI->new(); local $| = 1; print $q->header, $q->start_html, "\n"; my $num; $num++ while 1; print $q->end_html, "\n"; exit;
prefork
$ sudo cat /proc/26878/limits Limit Soft Limit Hard Limit Units Max cpu time 120 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 32752 32752 processes Max open files 1024 1024 files Max locked memory 32768 32768 bytes Max address space 67108864 unlimited bytes Max file locks unlimited unlimited locks Max pending signals 32752 32752 signals Max msgqueue size 819200 819200 bytes Max nice priority 0 0 Max realtime priority 0 0
Max cpu timeがRlimitCPUの120, Max address spaceがRlimitMemの64Mになっている。
workerのサーバ
$ sudo cat /proc/32281/limits Limit Soft Limit Hard Limit Units Max cpu time unlimited unlimited ms Max file size unlimited unlimited bytes Max data size unlimited unlimited bytes Max stack size 8388608 unlimited bytes Max core file size 0 unlimited bytes Max resident set unlimited unlimited bytes Max processes unlimited unlimited 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 16382 16382 signals Max msgqueue size 819200 819200 bytes Max nice priority 20 20 Max realtime priority 0 0
Max cpu timeとMax address spaceがunlmitedだ。