Linux并发连接上百万的配置
To support over 500k users, you *need* - A 64 bits hardware/kernel (AMD64, Opterons) - At least 8GB of ram - A recent linux kernel (2.6.x) About tuning, I prefer to not fully disclose them because servers are targets of many attacks, so it's better not help hackers. The most touchy thing is the IP route cache : You have to tune it or else the machine drops many connections (hint : rhash_entries=... in the boot append string) hints : echo 1 > /proc/sys/net/ipv4/route/gc_interval echo 150 >/proc/sys/net/ipv4/route/gc_timeout echo 2 >/proc/sys/net/ipv4/route/gc_elasticity - Use of hugeTLB pages hint : echo xxx >/proc/sys/vm/nr_hugepages Tune tcp : echo "4096 49152 131072" >/proc/sys/net/ipv4/tcp_wmem echo xxxx >/proc/sys/net/ipv4/tcp_max_syn_backlog echo xxxx >/proc/sys/net/core/somaxconn echo 1200000 > /proc/sys/net/ipv4/tcp_max_tw_buckets echo 7 >/proc/sys/net/ipv4/tcp_retries2 echo "600000 650000 700000" >/proc/sys/net/ipv4/tcp_mem echo 0 >/proc/sys/net/ipv4/tcp_timestamps echo 0 >/proc/sys/net/ipv4/tcp_window_scaling echo 0 >/proc/sys/net/ipv4/tcp_sack echo 330000 >/proc/sys/net/ipv4/tcp_max_orphans echo "10000 62000" >/proc/sys/net/ipv4/ip_local_port_range others : echo 1300000 >/proc/sys/fs/file-max
作者:青茶
免责声明:文章、笔记等仅供分享、探讨、参考等学习之用,因此造成的任何后果概不负责。(如有错误、疏忽等问题,欢迎指正、讨论,谢谢)
本文版权归作者和博客园共有,欢迎转载,但请务必在文章页面明显位置给出原文连接,谢谢配合。
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步