#!/bin/sh
# socket queue
# sysctl -w net.ipv4.tcp_max_syn_backlog=4096
sysctl -w net.ipv4.tcp_max_syn_backlog=262144
# sysctl -w net.ipv4.tcp_syncookies=1
sysctl -w net.ipv4.tcp_syncookies=0
sysctl -w net.ipv4.tcp_fin_timeout=3
#TIME_WAIT setting
sysctl -w net.ipv4.tcp_keepalive_time=300
sysctl -w net.ipv4.tcp_tw_reuse=1
sysctl -w net.ipv4.tcp_tw_recycle=1
sysctl -w net.ipv4.tcp_no_metrics_save=1
sysctl -w net.core.somaxconn=262144
sysctl -w net.ipv4.tcp_max_orphans=262144
sysctl -w net.ipv4.tcp_synack_retries=2
sysctl -w net.ipv4.tcp_syn_retries=2
#sysctl -w net.core.wmem_max="262144"
sysctl -w net.core.wmem_max="16777216"
sysctl -w net.core.rmem_max="16777216"
#sysctl -w net.ipv4.tcp_wmem="4096 65536 262144"
sysctl -w net.ipv4.tcp_wmem="4096 65536 16777216"
sysctl -w net.ipv4.tcp_rmem="4096 87380 16777216"
sysctl -w net.core.netdev_max_backlog=30000
# sysctl -w net.ipv4.ip_local_port_range="1024 65536"
sysctl -w net.ipv4.ip_local_port_range="5000 65536"
#redirects
# sysctl -w net.ipv4.conf.all.send_redirects=0
# sysctl -w net.ipv4.conf.all.accept_redirects=0
#Source routing
#Drop all source route packets.
# sysctl -w net.ipv4.conf.all.accept_source_route=0
#Do not forward source routed frames.
# sysctl -w net.ipv4.conf.all.forwarding=0
# sysctl -w net.ipv4.conf.all.mc_forwarding=0
#Broadcast ECHO response
# sysctl -w net.ipv4.icmp_echo_ignore_broadcasts=1
# sysctl -w kernel.shmmax=67108864
# sysctl -w kernel.shmall=33554432
# sysctl -w kernel.shmmni=8388608
ulimit -HSn 51200
张彦的nginx+php经验
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.ip_local_port_range = 5000 65000