Linux web server kernel 권고 파라미터
Linux OS 권고 파라미터
파라미터 | 설명 | 권고값 |
nofile | Resource Limit으로 인한 장애 방지 ( OS 유저별로 설정 ) ulimit 및 /etc/security/limits.conf 와 /etc/security/limits.d/20-nproc.conf 로 제어 |
8192 |
nproc | 8192 | |
net.ipv4.tcp_keepalive_intvl | TCP TIME_WAIT 상태를 줄이기 위한 설정 | 15 |
net.ipv4.tcp_keepalive_probes | 손실된 TCP 상태 감지 시간 설정 | 5 |
net.ipv4.tcp_keepalive_time | keep alive 시간을 설정 | 30 |
net.ipv4.ip_local_port_range | 사용할 수 있는 포트 범위를 설정 | 1024 - 65000 |
net.core.netdev_max_backlog | 백로그에 들어오는 소켓 개수를 설정 | 2500 |
net.ipv4.tcp_rmem |
212992 212992 6291456 |
|
net.ipv4.tcp_retries1 | TCP 연결에 문제가 있을 때 연결을 재시도하는 횟수 | 3 |
net.ipv4.tcp_retries2 | TCP 연결을 끊기 전에 재시도하는 횟수 | 3 |
net.core.rmem_max | TCP 수신 버퍼크기 최대값 설정 | 6291456 |
net.ipv4.tcp_wmem | 212992 212992 4194304 |
|
net.core.rmem_default | TCP 수신 버퍼크기 기본값 설정 | 212992 |
net.core.wmem_max | TCP 전송 버퍼크기 최대값 설정 | 4194304 |
net.core.wmem_default | TCP 전송 버퍼크기 기본값 설정 | 212992 |
net.ipv4.tcp_tw_reuse | Time Wait 상태의 TCP 연결 재활용하여 다량의 연결 필요 시 성능 향상 가능 | 1 |
net.core.netdev_max_backlog |
네트워크 장치 별로 커널이 처리하도록 쌓아두는 queue의 크기
|
16384 |
net.core.somaxconn |
accept()을 기다리는 ESTABLISHED 상태의 소켓(즉, connection completed)을 위한 queue
|
8192 |
net.ipv4.tcp_max_syn_backlog |
SYN_RECEIVED 상태의 소켓(즉, connection incompleted)을 위한 queue
|
8192 |
net.ipv4.tcp_fin_timeout | FIN 타임아웃을 시간을 줄여 FD를 빠르게 확보 | 15 |
반영 방법
vi /etc/sysctl.conf
# Update Kernel Parameter
net.ipv4.tcp_keepalive_time=30
net.ipv4.ip_local_port_range=1024 65000
net.core.netdev_max_backlog=2500
net.ipv4.tcp_retries1=3
net.ipv4.tcp_retries2=3
net.core.rmem_max=56777216
net.core.rmem_default=16777216
net.core.wmem_max=56777216
net.core.wmem_default=16777216
net.ipv4.tcp_window_scaling=1
net.ipv4.tcp_orphan_retries=0
net.ipv4.tcp_sack=0
net.ipv4.tcp_fin_timeout=10
vi /etc/security/limits.conf
apache hard nofile 65536
apache soft nofile 65536
ulimit –n 값 확인 (max number of open files )
- max number of open files값이 디폴트값이 1024이며, 최소 8192 이상으로 설정 권고함
- 아래와 같이 /etc/security/limits.conf 파일에서 수정하면 영구적으로 적용
[확인방법] test:/home/nrson> ulimit -a : (생략) max number of open files (-n) 65536 max user processes (-u) 65536 [변경방법] /etc/security/limits.conf를 추가하는 방법이 있다. |
/etc/security/limits.conf에 아래의 내용을 추가한다. # nofile tunning - max number of open files apache hard nofile 65536 apache soft nofile 65536 apache soft npoc 2047
apache hard npoc 16384 |
/etc/sysctl.conf 파일을 아래와 같이 수정
바로 적용하기 위해서 root권한에서 sysctl -p 명령을 실행
적용된 내용을 확인하는 방법 sysctl –a