温馨提示×

怎样提升Ubuntu收发速度

小樊
43
2026-07-31 12:26:03
栏目: 智能运维

提升 Ubuntu 的收发速度(网络吞吐、文件传输、系统响应等)可以从网络、磁盘、系统配置、应用层几个方向来优化。下面按常见场景给你一套实用方案。


一、网络收发速度优化(最常见)

1️⃣ 检查当前网络瓶颈

ip a
ethtool eth0        # 查看网卡速率
ping -c 10 8.8.8.8
speedtest-cli       # 网络测速

2️⃣ 调整网卡参数(非常有效)

✅ 开启 GRO / GSO / TSO

sudo ethtool -K eth0 gro on
sudo ethtool -K eth0 gso on
sudo ethtool -K eth0 tso on

✅ 增大网卡队列

sudo ethtool -G eth0 rx 4096 tx 4096

3️⃣ 调整内核网络参数(强烈推荐)

编辑:

sudo nano /etc/sysctl.conf

加入或修改:

net.core.rmem_max = 134217728
net.core.wmem_max = 134217728
net.core.rmem_default = 67108864
net.core.wmem_default = 67108864

net.ipv4.tcp_rmem = 4096 87380 134217728
net.ipv4.tcp_wmem = 4096 65536 134217728

net.ipv4.tcp_congestion_control = cubic
net.ipv4.tcp_sack = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_fastopen = 3

生效:

sudo sysctl -p

4️⃣ 优化 DNS(常被忽略)

sudo nano /etc/systemd/resolved.conf
DNS=8.8.8.8 1.1.1.1
sudo systemctl restart systemd-resolved

二、磁盘读写速度优化(影响文件收发)

1️⃣ 使用 ext4 + noatime

sudo nano /etc/fstab
UUID=xxxx  /  ext4  defaults,noatime  0  1

2️⃣ 调整 IO 调度器

cat /sys/block/sda/queue/scheduler

推荐:

  • SSD:nonemq-deadline
  • HDD:bfq

临时设置:

echo mq-deadline | sudo tee /sys/block/sda/queue/scheduler

3️⃣ 增加 SWAP(防止卡顿)

free -h

如果 swap 太小:

sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

三、系统级性能优化

1️⃣ 调整文件描述符限制

ulimit -n

永久修改:

sudo nano /etc/security/limits.conf
* soft nofile 65535
* hard nofile 65535

2️⃣ 关闭不必要的服务

systemctl list-unit-files --type=service | grep enabled
sudo systemctl disable bluetooth

四、应用层优化(常见场景)

✅ SSH / SCP 加速

sudo nano /etc/ssh/sshd_config
Compression no
sudo systemctl restart ssh

✅ 大文件传输用 rsync

rsync -ah --progress source/ user@ip:/dest/

五、如果是服务器(高并发)

  • 使用 BBR 拥塞控制
echo "net.core.default_qdisc=fq" | sudo tee -a /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

检查:

lsmod | grep bbr

六、快速诊断命令(推荐收藏)

top
htop
iotop
iftop
nload

七、典型场景速查表

场景 建议
下载慢 DNS + TCP 参数
文件传输慢 rsync + MTU
SSH 卡 关闭压缩
高并发 BBR
磁盘慢 IO 调度 + noatime

如果你愿意,可以告诉我:

  • ✅ 是 服务器 / 桌面 / 云主机
  • ✅ 主要用途(下载 / 上传 / SSH / 网站 / 数据库)
  • ✅ 当前速度(如 100Mbps 实际只有 10Mbps)

我可以帮你精准定制一套优化方案

0