网络服务器内核优化生产案例
2024年4月1日...小于 1 分钟
网络服务器内核优化生产案例
内核参数
/etc/sysctl.conf.d/99-sysctl.conf
kernel.perf_event_max_sample_rate=100000
net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr
net.core.optmem_max = 81920
net.core.rmem_default = 327680
net.core.rmem_max = 327680
net.core.wmem_default = 327680
net.core.wmem_max = 3276800
net.core.netdev_budget = 600
net.core.netdev_max_backlog = 262144
net.core.somaxconn = 65535
net.ipv4.ip_local_reserved_ports="3344,4444,5554,7063,9995,9996,1026,11211,53831,30754,42793,49393"
net.ipv4.tcp_mem = 7864320 7864320 7864320
net.ipv4.tcp_rmem = 4096 87380 2097152
net.ipv4.tcp_wmem = 4096 262144 2097152
net.ipv4.udp_mem = 4096 262144 2097152
net.ipv4.udp_rmem_min = 4096
net.ipv4.udp_wmem_min = 4096
net.ipv4.ip_forward = 1
net.ipv4.conf.all.forwarding = 1
net.ipv4.conf.default.forwarding = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.route.max_size = 2147483647
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_tw_buckets = 36000
net.ipv4.tcp_sack = 1
net.ipv4.tcp_slow_start_after_idle = 0
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_no_metrics_save=1
net.ipv4.tcp_no_delay_ack=1
net.ipv4.tcp_tw_recycle=0
net.ipv4.tcp_retries2 = 5
net.ipv4.tcp_max_orphans = 3276800
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 1
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 2
net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_keepalive_probes = 3
net.ipv4.tcp_keepalive_intvl = 15
net.ipv4.neigh.default.base_reachable_time = 3600
net.ipv4.neigh.default.gc_stale_time = 60
net.ipv4.neigh.default.gc_thresh1 = 1024
net.ipv4.neigh.default.gc_thresh2 = 4096
net.ipv4.neigh.default.gc_thresh3 = 8192
#fs.conf
fs.nr_open=6553500
fs.file-max=3276800
fs.inotify.max_queued_events=99999999
fs.inotify.max_user_watches=99999999
fs.inotify.max_user_instances=65535
#kernel.conf
kernel.ctrl-alt-del = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.pid_max = 65536
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
kernel.sysrq = 0
kernel.perf_cpu_time_max_percent = 5
kernel.perf_event_max_sample_rate=100000
#netfilter.conf
# memory_size = $(free -m)
# nf_conntrack_max = 64255*1024*1024 / 16384 / 2
#net.netfilter.nf_conntrack_max = 2056160
# nf_conntrack_buckets = nf_conntrack_max / 4
net.netfilter.nf_conntrack_buckets = 514040
net.netfilter.nf_conntrack_tcp_timeout_established = 3600
net.netfilter.nf_conntrack_tcp_timeout_close_wait = 10
net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 20
net.netfilter.nf_conntrack_tcp_timeout_time_wait = 20
#vm.conf
vm.min_free_kbytes = 1048576
vm.vfs_cache_pressure = 100
vm.swappiness = 0
vm.dirty_background_ratio = 1
vm.dirty_expire_centisecs = 500
vm.dirty_ratio = 10
vm.dirty_writeback_centisecs = 100
#ipv6.conf
net.ipv6.conf.default.disable_ipv6 = 0
net.ipv6.conf.default.disable_policy = 0
net.ipv6.conf.default.forwarding = 1
net.ipv6.conf.default.max_addresses = 2
net.ipv6.route.max_size = 2147483647
net.ipv6.neigh.default.base_reachable_time = 3600
net.ipv6.neigh.default.gc_stale_time = 60
net.ipv6.neigh.default.gc_thresh1 = 1024
net.ipv6.neigh.default.gc_thresh2 = 4096
net.ipv6.neigh.default.gc_thresh3 = 8192
你认为这篇文章怎么样?
- 0
- 0
- 0
- 0
- 0
- 0
Powered by Waline v3.3.2