# /etc/vsftpd.conf
max_clients=200
max_per_ip=20
anon_max_rate=102400
local_max_rate=204800
pasv_min_port=50000
pasv_max_port=60000
# /etc/proftpd.conf
MaxInstances 200
MaxClientsPerHost 20
TransferRate RETR 102400 user anonymous
TransferRate STOR 204800 user *
PassivePorts 50000 60000
调整TCP参数:
echo "net.ipv4.tcp_window_scaling = 1" >> /etc/sysctl.conf
echo "net.core.rmem_max = 16777216" >> /etc/sysctl.conf
echo "net.core.wmem_max = 16777216" >> /etc/sysctl.conf
sysctl -p
使用被动模式(PASV): 减少NAT/防火墙问题
禁用atime更新:
mount -o remount,noatime /
或在/etc/fstab中添加noatime
选项
调整预读值:
blockdev --setra 8192 /dev/sdX
启用TLS/SSL加密: 但会带来性能开销
# vsftpd
ssl_enable=YES
allow_anon_ssl=NO
force_local_logins_ssl=YES
使用sendfile()系统调用:
# vsftpd
use_sendfile=YES
调整线程/进程模型:
通过以上优化措施,可以显著提升Linux FTP服务器的性能和稳定性,根据实际应用场景选择适合的优化组合。