是不是觉得你的Ubuntu比别人的慢?是不是并发数不够高?是不是启动个服务慢到怀疑人生?下面是我从网上收集回来的Ubuntu系列的简单性能配置,希望能够帮助到更多的人。

1. 修改/etc/security/limits.conf

* soft nofile 20000
* hard nofile 20000

2. 修改/etc/pam.d/login

session required /lib64/security/pam_limits.so

3. 修改 /etc/sysctl.conf

net.ipv4.ip_local_port_range = 1024 65536
net.ipv4.tcp_rmem=4096 87380 16777216
net.ipv4.tcp_wmem=4096 65536 16777216
net.ipv4.tcp_fin_timeout = 10
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_window_scaling = 0
net.ipv4.tcp_sack = 0
net.ipv4.tcp_no_metrics_save=1
net.ipv4.tcp_syncookies = 0
net.ipv4.tcp_max_orphans = 262144
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
net.core.rmem_max=16777216
net.core.wmem_max=16777216
net.core.netdev_max_backlog = 30000
net.core.somaxconn = 262144

# 使内容生效
/sbin/sysctl -p /etc/sysctl.conf
/sbin/sysctl -w net.ipv4.route.flush=1

4. 增加并发数

echo ulimit -HSn 65536 >> /etc/rc.local
echo ulimit -HSn 65536 >>/root/.bash_profile
ulimit -HSn 65536

经验证,以上配置对于Ubuntu和Linux Mint均有效。

今天太多事情要处理了,先水一期吧。