在FreeBSD下做mail系统的性能调整!很好!

原创 2004年09月04日 14:29:00
http://www.daemonnews.org/200108/benchmark.html

The Effects of Tuning a FreeBSD Box for High Performance
Gilbert Gong, <ggong@cal.alumni.berkeley.edu>
Introduction

A stock FreeBSD installation delivers a system which is designed to meet the needs of most users, and strives to provide the best balance of safety, reliability, and performance in a multi-user environment. It is therefore not optimized for use as a high performance dedicated network server. In this article, I will investigate the effect of tuning a FreeBSD for use as a dedicated network server.

System and Methodology
The test server was a Pentium III 600 MHz with 512MB of RAM, installed in a Super Micro P6SBU motherboard. The on-board Adaptec Ultra2 SCSI adapter was connected to an IBM DNES-309170W SA30 (8GB SCSI HDD), and the network card was a 3Com 3c905B-TX. All filesystems were standard UFS

A Celeron 400 with 128MB of RAM was used as a network client when needed. The test server was installed with FreeBSD 4.3-RELEASE. The client was installed with several versions of FreeBSD 1.

The two machines were connected with a Cisco Catalyst 2924-XL running at 100Mbit/Full Duplex.

I ran three different benchmarks against the test server, in both tuned and untuned state. The benchmark results are not meant as a real world performance measurement of the system, but only a means of comparing the relative performance of the tuned and untuned state. The benchmarks were http_load to measure http performance, postmark to measure file system performance, and postal to measure SMTP performance.

Tuning
Most of the following techniques are derived from the tuning(7) man page.

Recompile the kernel
Perhaps the first step in tuning a FreeBSD box is to recompile the Kernel. Remove the options not needed by your system, and increase maxusers and the NMBCLUSTERS option. A copy of the kernel config file I used is here


Turn on soft updates
One of the most critical steps in tuning a FreeBSD box is turning on soft updates (and here). Soft updates is a method of improving filesystem metadata update performance. The following commands were entered in single user mode:
tunefs -n enable /
tunefs -n enable /usr
tunefs -n enable /var
tunefs -n enable /tmp


sysctl
A few sysctl variables should be tuned for maximum performance. The following lines were added to /etc/sysctl.conf:
vfs.vmiodirenable=1
kern.ipc.somaxconn=4096
kern.maxfiles=65536


misc
A few other tweaks included setting the "noatime" parameter on most of the filesystems, and paying attention to partition layout.
http_load Results

For the http_load test, I installed apache 1.3.19 from the ports collection, making a change to set HARD_SERVER_LIMIT to 2048. The untuned configuration would not allow 2048 processes to run, so I set Apache to create 128 initial, and max 1024 processes. For the tuned configuration, I set Apache to have 2048 processes running at all times.

I ran http_load against the server with different numbers of concurrent requests, varying from 10 to 1000. I configured the server to respond to 10 different IP addresses, and strobed over those 10 different IP addresses. This is the page which http_load ran against. The results are graphed here.

The tuned configuration outperformed the untuned configuration by over an order of magnitude. The untuned configuration maxed out at around 17 fetches/sec, as a result of running out of network mbufs. The tuned configuration kept increasing in performance as the load was increased, from 333 fetches/sec to 509 fetches/sec (1800% to 2900% increase over untuned). The tuned configuration also had a lower percentage of errors, as shown here.

postmark Results
The postmark benchmark was run with a variety of settings. First, it was run with some of the configurations documented on the home page. Those results are reported here, including a run on the FreeBSD MFS (Memory File System) for comparison. The system was then put through a series of postmark runs with different file sizes, with initial 1000 files and 20000 files. The improvement in performance is quite drastic in all cases, and ranges from a 40% to 860% increase in performance by this benchmark.

postal Results
For the postal benchmark, the postfix mailer was installed from the Ports collection (postfix-20010228-pl01). The postal benchmark was then run for half hour periods with a range of parallel simultaneous connection settings. Around 15000 accounts were created on the test server, and postal was given the list of accounts to send mail to. The test runs were made back to back, with only a small break between them. This means that mail which was enqueued in an earlier run may have remained enqueued for a later run, slowing things down even more. Since this is only meant as a comparative test, the results are still good indications of the performance difference between the two configurations. The results of the postal benchmark are here. The improvement ranges from a 40% increase to a 650% increase.

Conclusion
In conclusion, we can see that a default FreeBSD installation, while optimized for safety and integrity, is not optimized for maximum performance as a dedicated network server. Particularly in cases of serving many simultaneous connections, reliably supporting large numbers of processes, and filesystem performance, one needs to take steps to improve the performance of the system over the default configuration. The gains that can be realized from this are great, often at least doubling the performance of the system.


--------------------------------------------------------------------------------
Footnotes
1 A security enhancement in 4.3 Release unintentionally slows the rate at which two servers may communicate with one another. It also does not allow a way to turn that behavior off, though a patch has been released which does allow that behavior to be changed.
收藏助手
不良信息举报
您举报文章:在FreeBSD下做mail系统的性能调整!很好!
举报原因:
原因补充:

(最多只允许输入30个字)