잡동사니
CentOS TCP 성능 튜닝 - Apache 성능 최대화
미니렉스
2017. 6. 12. 17:09
개요
웹서버 성능시험중에 발생한 오류 증상에 대하여 다양한(?) 기술검토 끝에 튜닝이 완료 되어 기록으로 남김
- KT VM Server
- OS : CentOS 6.3
- core : 8 core
- MEM : 16 GB
오류증상
- 로드러너 시험시 503 Servce Unavailable 오류가 20% 이상 발생함
- 지속적인 TPS 가 유지되지 않고 널뛰기를 반복
원인분석
- netstat 결과 TIME_WAIT 관련 세션이 28,000 ~ 30,000 여개를 유지
- 정상적인 ESTABLISHED 세션이 더 이상 생기지 못하는 상태 ( 10여개 미만 )
- CPU/MEM 상태는 10% 미만 사용중
- 결론 : OS 단에서 TCP 트래픽 처리 관련 한계치 초과로 Application이 트래픽을 못받는 상태
튜닝 적용후
- netstat TIME_WAIT : 10,000 여개
- ESTABLED 세션 수는 로드러너 Vuser 수와 동일 하거나 많음
- CPU 상태 90에서 100% 때림 ( 오호 이거야 )
- 결론 : 서버 최대 성능을 사용중임
- 최대 처리 이상의 트래픽이 걸리면 CPU 100% 찍으면서 503 오류를 토해냄 : Okay
튜닝적용 방법
/etc/sysctl.conf 파일을 수정한후 sysctl -p 로 적용 (쉽네애~~~)
그러나 시스템 설치 메모리 용량 및 성능에 따라 메모리 최대값은 가변적 이라서 "전문가" 분이 시스템에 맞게 튜닝하셔야...
[root @hostname ~]# uname -a
Linux hostname 2.6 . 32 - 358.14 . 1 .el6.x86_64 # 1 SMP Tue Jul 16 23 : 51 : 20 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
[root @hostname ~]# vi /etc/sysctl.cof
[root @hostname ~]# sysctl -p
|
결론 : diff sysctl -a : Before< , After>
아래 파라미터를 사용중이신 시스템 스펙을 참고하여 조정하시면 될 듯 합니다.
< net.core.somaxconn = 128
> net.core.somaxconn = 8096
< net.core.wmem_max = 229376
> net.core.wmem_max = 8388608
< net.core.rmem_max = 229376
> net.core.rmem_max = 8388608
< net.ipv4.tcp_fin_timeout = 60
> net.ipv4.tcp_fin_timeout = 10
< net.ipv4.tcp_tw_recycle = 0
> net.ipv4.tcp_tw_recycle = 1
< net.ipv4.tcp_tw_reuse = 0
> net.ipv4.tcp_tw_reuse = 1
< net.ipv4.tcp_mem = 1520544 2027392 3041088
> net.ipv4.tcp_mem = 8388608 12582912 16777216
< net.ipv4.tcp_wmem = 4096 16384 4194304
> net.ipv4.tcp_wmem = 8192 65536 8388608
< net.ipv4.tcp_rmem = 4096 87380 4194304
> net.ipv4.tcp_rmem = 8192 87380 8388608
< net.ipv4.udp_mem = 1520544 2027392 3041088
> net.ipv4.udp_mem = 8388608 12582912 16777216
|
history log (참고용)
888 cat /proc/cpuinfo
958 vmstat 1
961 iostat
962 iostat 1
895 netstat -s eth0
896 netstat -S eth0
897 netstat -s
898 netstat -s | more
903 netstat -nupln
942 netstat -ntpl
956 netstat -nutpl
943 netstat -an
944 netstat -tuanp | grep -i time_wait
945 netstat -tuanp | grep -i time_wait | wc -l
947 netstat -tuanp | grep -i time_wait | more
904 ethtool -g eth0
905 ethtool -i eth0
894 vi /etc/sysctl.conf
907 sysctl -a | grep net.core
909 sysctl -a | grep net.ipv4
913 sysctl -a | grep net.ipv4.tcp
927 sysctl -p
918 free -m
928 ethtool -G eth9
929 ethtool -G eth0
930 ethtool -S | more
931 ethtool -s | more
932 ethtool -S
933 ethtool -s
934 ethtool -i
935 ethtool -i eth0
941 ethtool eth0
951 cat /proc/slabinfo | grep tcp_tw_bucket
952 cat /proc/slabinfo | grep tcp_tw_
953 cat /proc/slabinfo
954 cat /proc/slabinfo | grep tcp_*
964 mpstat -P
965 mpstat -P ALL
|