현재 OS상의 제한이 걸려 있는 목록을 볼 수 있는 명령어 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) 7799
max locked memory (kbytes, -l) 16384
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) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 7799
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
위의 리스트 중에서 File open의 제약(Socket connect)을 걸고 있는 것이 바로 open files
ulimit -n 50000
혹은
/etc/security/limits.conf 파일에* soft nofile 16384
을 추가후 껏다 키면 적용된다. (sysctl -p로도 적용될수도..?)
* hard nofile 16384
python에선 resourece 패키지를 통해 해당 스크립트가 실행되는 동안 변경할 수 있다.
import resource
soft, hard = 500000, 500000
resource.setrlimit(resource.RLIMIT_NOFILE, (soft, hard))