# 네트워크 성능 튜닝 이 서버의 커널 네트워크 최적화 설정 문서 ## 설정 파일 `/etc/sysctl.d/99-network-performance.conf` ## 적용된 설정 ### 소켓 버퍼 크기 | 항목 | 값 | 설명 | |------|-----|------| | `net.core.rmem_max` | 16MB | 최대 수신 버퍼 | | `net.core.wmem_max` | 16MB | 최대 송신 버퍼 | | `net.core.rmem_default` | 1MB | 기본 수신 버퍼 | | `net.core.wmem_default` | 1MB | 기본 송신 버퍼 | | `net.core.optmem_max` | 64KB | 옵션 메모리 | ### TCP 버퍼 (min, default, max) | 항목 | 값 | 설명 | |------|-----|------| | `net.ipv4.tcp_rmem` | 4KB / 1MB / 16MB | TCP 수신 버퍼 | | `net.ipv4.tcp_wmem` | 4KB / 1MB / 16MB | TCP 송신 버퍼 | ### 백로그 설정 | 항목 | 값 | 설명 | |------|-----|------| | `net.core.netdev_max_backlog` | 65,535 | 네트워크 장치 큐 크기 | | `net.ipv4.tcp_max_syn_backlog` | 65,535 | SYN 큐 크기 | ### 연결 관리 | 항목 | 값 | 설명 | |------|-----|------| | `net.ipv4.tcp_fin_timeout` | 10초 | FIN-WAIT-2 타임아웃 | | `net.ipv4.tcp_keepalive_time` | 600초 | Keepalive 시작 시간 | | `net.ipv4.tcp_keepalive_intvl` | 30초 | Keepalive 간격 | | `net.ipv4.tcp_keepalive_probes` | 5 | Keepalive 재시도 횟수 | | `net.ipv4.ip_local_port_range` | 1024-65535 | 로컬 포트 범위 | ### 성능 최적화 | 항목 | 값 | 설명 | |------|-----|------| | `net.ipv4.tcp_fastopen` | 3 | TCP Fast Open 양방향 | | `net.core.default_qdisc` | fq | Fair Queue 스케줄러 | | `net.ipv4.tcp_congestion_control` | bbr | BBR 혼잡 제어 | ## 명령어 ### 현재 설정 확인 ```bash # 전체 네트워크 설정 /sbin/sysctl -a | grep -E "net.core|net.ipv4.tcp" # 특정 설정 확인 /sbin/sysctl net.ipv4.tcp_congestion_control /sbin/sysctl net.core.rmem_max ``` ### 설정 재적용 ```bash sudo /sbin/sysctl -p /etc/sysctl.d/99-network-performance.conf ``` ### 설정 수정 ```bash # 파일 수정 sudo nano /etc/sysctl.d/99-network-performance.conf # 적용 sudo /sbin/sysctl -p /etc/sysctl.d/99-network-performance.conf ``` ## BBR 혼잡 제어 BBR (Bottleneck Bandwidth and Round-trip propagation time)은 Google이 개발한 TCP 혼잡 제어 알고리즘입니다. ### 장점 - 높은 처리량 - 낮은 지연 시간 - 패킷 로스에 강함 - 버퍼블로트 방지 ### 확인 ```bash # 현재 사용 중인 알고리즘 /sbin/sysctl net.ipv4.tcp_congestion_control # 사용 가능한 알고리즘 /sbin/sysctl net.ipv4.tcp_available_congestion_control ``` ## 효과 | 항목 | 개선 | |------|------| | 동시 연결 | 더 많은 연결 처리 가능 | | 대용량 전송 | 버퍼 증가로 속도 향상 | | SYN Flood | 큰 백로그로 저항력 증가 | | 지연 시간 | BBR로 latency 감소 | | 연결 정리 | 빠른 타임아웃으로 리소스 회수 | ## 관련 문서 - [XDP Firewall 설정](./xdp-firewall-setup.md) - [Linux Network Tuning Guide](https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt) - [BBR Congestion Control](https://cloud.google.com/blog/products/networking/tcp-bbr-congestion-control-comes-to-gcp-your-internet-just-got-faster)