5.3. 如何调整您的系统以获得最佳 Caudium 性能

5.3.1. Linux

在 Linux 专家有时间编写一些好的文档之前,这里有一些来自 PureFtpd 软件的内容


 o Increase your system max descriptors numbers :
 
 # echo 60000 > /proc/sys/fs/file-max
 # echo 180000 > /proc/sys/fs/inode-max
 # ulimit -n 60000
 o mount your filesystems with the "noatime" option
 o make sure your disks holding the logs are "fast enough"

 o You can tweak a bit your TCP/IP stack :
 # echo 0 > /proc/sys/net/ipv4/tcp_syncookies
 # echo 0 > /proc/sys/net/ipv4/tcp_ecn
 # echo 0 > /proc/sys/net/ipv4/tcp_timestamps
 # echo 0 > /proc/sys/net/ipv4/tcp_window_scaling
	

最后,别忘了使用以下命令编译 Pike:--with-max-fd=60000(在 Debian 软件包中已完成)。

Warning来自 Caudium 团队的警告
 

  • 个人建议,禁用窗口缩放似乎不是一个好主意。

  • 这需要进行一些修改。上面的 2.2 和 2.4 选项混合得非常糟糕。此外,关闭 ECN 可能会弊大于利。

另请参阅 LinuxPerf,以及 LinuxPerf 内核调优部分

5.3.2. FreeBSD

以下是您可以在服务器上尝试的优化。它们不提供任何担保。

Note

所有这些都适用于 FreeBSD 4.2 或更高版本。

首先,检查您的文件系统是否使用软更新:

# tunefs -p /dev/da0s1a
tunefs: soft updates:  (-n)                                disabled
tunefs: maximum contiguous block count: (-a)               15
tunefs: rotational delay between contiguous blocks: (-d)   0 ms
tunefs: maximum blocks per file in a cylinder group: (-e)  2048
tunefs: average file size: (-f)                            16384
tunefs: average number of files in a directory: (-s)       64
tunefs: minimum percentage of free space: (-m)             8%
tunefs: optimization preference: (-o)                      time
	
如果软更新设置为禁用启用它们可能是一个好主意。我们不建议您在服务器机器上的 "/" 文件系统上启用它们,因为存在问题,并且 FreeBSD 团队通常不建议这样做。如果可以卸载其他文件系统,请执行此操作并在之后重新挂载它们

# tunefs -n enable /dev/"whatever"
	
如果您无法卸载其他文件系统,请进入单用户模式(执行 shutdown nowboot -s),然后输入

# tunefs -n enable "filesystem"
	
我建议 /usr 或 /var。在 fstab 中,您可以添加,async到所有文件系统的选项中。至于软更新,我们不建议在服务器机器上的根 (/) 文件系统上使用。

/boot/loader.conf添加以下内容

kern.ipc.maxsockets="5000"
kern.ipc.nmbclusters="65536"
	
如果您有 ATA (IDE / UltraDMA) 磁盘,您也可以在/boot/loader.conf:

hw.ata.wc="1"
	
然后在/etc/sysctl.conf您可以添加

vfs.vmiodirenable=1
kern.ipc.maxsockbuf=2097152
kern.ipc.somaxconn=8192
kern.ipc.maxsockets=16424
kern.maxfiles=65536
kern.maxfilesperproc=32768
net.inet.tcp.rfc1323=1
net.inet.tcp.delayed_ack=0
net.inet.tcp.sendspace=65535
net.inet.tcp.recvspace=65535
net.inet.udp.recvspace=65535
net.inet.udp.maxdgram=57344
net.local.stream.recvspace=65535
net.local.stream.sendspace=65535
	
然后重启(或对于/etc/sysctl.conf使用 sysctl(8) 工具手动设置。

另一种获得良好性能的方法是制作自定义内核,其中包含最少的驱动程序和处理器支持。maxuser 大小 = 内存大小(例如,如果您有 512M 内存,则将内核配置变量中的 maxusers 值设置为 512)。使用以下命令将 Posix 1003.1b 实时扩展添加到内核

options         P1003_1B                #Posix P1003_1B real-time extensions
options         _KPOSIX_PRIORITY_SCHEDULING
        
启用 SMP 选项(仅适用于 FreeBSD 4.x,FreeBSD 5.0 现在是自动的)。

对于法语用户,请查看以下 URL

5.3.3. Solaris 2.x

大多数优化值都在/etc/system文件。此文件在内核加载时被读取。请注意,以下优化侧重于具有至少 256M 内存的 Solaris 8 机器。

* A comment is started by a star '*'
* 
* 1 maxusers per mega of ram. This machine has 512M then maxusers = 512
set maxusers=512
set hires_tick=1
set rlim_fd_max=10000
set rlim_fd_cur=4096
*set tcp:tcp_conn_hash_size=8192
* Don't setup this if you don't have more than 256M of RAM
set bufhwm=48000

* Folling are used to delay page reaping with databases.
set fastscan = 32000
set slowscan = 200
set maxpgio =  280
set lotsfree = 1024
set desfree = 512
set minfree = 128
set autoup = 280

*  Hash buffer sizes during Specweb testing
set tcp:tcp_conn_hash_size = 2097152

* Nic Interface
set hme:hme_adv_100fdx_cap=1
set hme:hme_adv_100hdx_cap=0
set hme:hme_adv_10fdx_cap=0
set hme:hme_adv_10hdx_cap=0
set hme:hme_adv_autoneg_cap=0

* To prevent buffer overflow
set noexec_user_stack=1
set noexec_user_stack_log=1
	
请注意,Solaris 需要快速磁盘。如果您有 IDE / UDMA 磁盘,请仔细检查它们是否是新的。例如,Ultra 5 / 10 机器中的磁盘非常慢,并且在您进行读写操作时会拖慢整台机器的速度。请考虑使用更快的磁盘。

此外,如果您使用软件 raid (Solaris Disk Suite),如果您在机器中有多个 SCSI 控制器,您将获得最佳性能。

另一个好的阅读材料是 Adrian Cockroft 关于 Solaris 调优的著名文档。Sunhelp.org 也有关于调优的好的部分。最后,您可以在 http://www.sean.de/Solaris/tune.html 阅读网络指南。