appb.pdf

(256 KB) Pobierz
,appb.27799 Page 312 Friday, November 19, 1999 3:30 PM
Samba Performance
Tuning
Appendix B
This appendix discusses various ways of performance tuning and system sizing
with Samba. Performance tuning is the art of finding bottlenecks and adjusting to
eliminate them. Sizing is the practice of eliminating bottlenecks by spending
money to avoid having them in the first place. Normally, you won’t have to worry
about either with Samba. On a completely untuned server, Samba will happily
support a small community of users. However, on a properly tuned server, Samba
will support at least twice as many users. This chapter is devoted to outlining vari-
ous performance-tuning and sizing techniques that you can use if you want to
stretch your Samba server to the limit.
A Simple Benchmark
How do you know if you’re getting reasonable performance? A simple benchmark
is to compare Samba with FTP. Table B-1 shows the throughput, in kilobytes per
second, of a pair of servers: a medium-size Sun SPARC Ultra and a small Linux
Pentium server. Numbers are reported in kilobytes per second (KB/s).
Table B-1. Sample Benchmark Benchmarks
Command
FTP
Untuned Samba
Tuned Samba
Sparc get
1014.5
645.3
866.7
Sparc put
379.8
386.1
329.5
Pentium get
973.27
N/A
725
Pentium put
1014.5
N/A
1100
If you run the same tests on your server, you probably won’t see the same num-
bers. However, you should see similar ratios of Samba to FTP, probably in the
range of 68 to 80 percent. It’s not a good idea to base all of Samba’s throughput
312
1179974445.331.png 1179974445.342.png 1179974445.353.png 1179974445.364.png 1179974445.001.png 1179974445.012.png 1179974445.023.png 1179974445.034.png 1179974445.045.png 1179974445.056.png 1179974445.067.png 1179974445.078.png 1179974445.089.png 1179974445.100.png 1179974445.111.png 1179974445.122.png 1179974445.133.png 1179974445.144.png 1179974445.155.png 1179974445.166.png 1179974445.177.png 1179974445.188.png 1179974445.199.png 1179974445.210.png 1179974445.221.png 1179974445.232.png 1179974445.243.png 1179974445.254.png 1179974445.265.png 1179974445.276.png 1179974445.287.png 1179974445.298.png 1179974445.309.png 1179974445.310.png 1179974445.311.png 1179974445.312.png 1179974445.313.png 1179974445.314.png 1179974445.315.png 1179974445.316.png 1179974445.317.png 1179974445.318.png 1179974445.319.png 1179974445.320.png 1179974445.321.png 1179974445.322.png 1179974445.323.png 1179974445.324.png 1179974445.325.png 1179974445.326.png 1179974445.327.png 1179974445.328.png 1179974445.329.png 1179974445.330.png 1179974445.332.png 1179974445.333.png 1179974445.334.png 1179974445.335.png 1179974445.336.png 1179974445.337.png 1179974445.338.png 1179974445.339.png 1179974445.340.png 1179974445.341.png 1179974445.343.png 1179974445.344.png 1179974445.345.png 1179974445.346.png 1179974445.347.png 1179974445.348.png 1179974445.349.png 1179974445.350.png 1179974445.351.png 1179974445.352.png 1179974445.354.png 1179974445.355.png 1179974445.356.png 1179974445.357.png
,appb.27799 Page 313 Friday, November 19, 1999 3:30 PM
Samba Tuning
313
against FTP. The golden rule to remember is this: if Samba is much slower than
FTP, it’s time to tune it.
You might think that an equivalent test would be to compare Samba to NFS. In
reality, however, it’s much less useful to compare their speeds. Depending entirely
on whose version of NFS you have and how well it’s tuned, Samba can be slower
or faster than NFS. We usually find that Samba is faster, but watch out; NFS uses a
different algorithm from Samba, so tuning options that are optimal for NFS may be
detrimental for Samba. If you run Samba on a well-tuned NFS server, Samba may
perform rather badly.
A more popular benchmark is Ziff-Davis’ NetBench, a simulation of many users on
client machines running word processors and accessing data on the SMB server.
It’s not a prefect measure (each NetBench client does about ten times the work of
a normal user on our site), but it is a fair comparison of similar servers. In tests
performed by Jeremy Allison in November 1998, Samba 2.0 on a SGI multiproces-
sor outperformed NT Server 4.0 (Patch Level 2) on an equivalent high-end Com-
paq. This was confirmed and strengthened by a Sm@rt Reseller test of NT and
Linux on identical hardware in February 1999.
In April 1999, the Mindcraft test lab released a report about a test showing that
Samba on a four-processor Linux machine was significantly slower than native file
serving on the same machine running Windows NT. While the original report was
slammed by the Open Source community because it was commissioned by
Microsoft and tuned the systems to favor Windows NT, a subsequent test was
fairer and generally admitted to reveal some areas where Linux needed to improve
its performance, especially on multiprocessors. Little was said about Samba itself.
Samba is known to scale well on multiprocessors, and exceeds 440MB/s on a four-
processor SGI O200, beating Mindcraft’s 310MB/s.
Relative performance will probably change as NT and PC hardware get faster, of
course, but Samba is improving as well. For example, Samba 1.9.18 was faster only
with more than 35 clients. Samba 2.0, however, is faster regardless of the number
of clients. In short, Samba is very competitive with the best networking software in
the industry, and is only getting better.
As we went to press, Andrew Tridgell released the alpha-test version suite of
benchmarking programs for Samba and SMB networks. Expect even more work on
performance from the Samba team in the future.
Samba Tuning
That being said, let’s discuss how you can take an already fast networking pack-
age and make it even faster.
1179974445.358.png 1179974445.359.png 1179974445.360.png 1179974445.361.png 1179974445.362.png 1179974445.363.png 1179974445.365.png 1179974445.366.png 1179974445.367.png 1179974445.368.png 1179974445.369.png 1179974445.370.png 1179974445.371.png 1179974445.372.png 1179974445.373.png 1179974445.374.png 1179974445.002.png 1179974445.003.png 1179974445.004.png 1179974445.005.png 1179974445.006.png 1179974445.007.png 1179974445.008.png 1179974445.009.png 1179974445.010.png 1179974445.011.png 1179974445.013.png 1179974445.014.png 1179974445.015.png 1179974445.016.png 1179974445.017.png 1179974445.018.png 1179974445.019.png 1179974445.020.png 1179974445.021.png 1179974445.022.png 1179974445.024.png 1179974445.025.png 1179974445.026.png 1179974445.027.png 1179974445.028.png 1179974445.029.png 1179974445.030.png 1179974445.031.png 1179974445.032.png 1179974445.033.png 1179974445.035.png 1179974445.036.png 1179974445.037.png 1179974445.038.png 1179974445.039.png 1179974445.040.png 1179974445.041.png 1179974445.042.png 1179974445.043.png 1179974445.044.png 1179974445.046.png 1179974445.047.png 1179974445.048.png 1179974445.049.png 1179974445.050.png 1179974445.051.png 1179974445.052.png 1179974445.053.png 1179974445.054.png 1179974445.055.png 1179974445.057.png 1179974445.058.png 1179974445.059.png 1179974445.060.png 1179974445.061.png 1179974445.062.png 1179974445.063.png
,appb.27799 Page 314 Friday, November 19, 1999 3:30 PM
314
Appendix B: Samba Performance Tuning
Benchmarking
Benchmarking is an arcane and somewhat black art, but the level of expertise
needed for simple performance tuning is fairly low. Since the Samba server’s goal
in life is to transfer files, we will examine only throughput, not response time to
particular events, under the benchmarking microscope. After all, it’s relatively easy
to measure file transfer speed, and Samba doesn’t suffer too badly from response-
time problems that would require more sophisticated techniques.
Our basic strategy for this work will be:
• Find a reasonably-sized file to copy and a program that reports on copy
speeds, such as smbclient .
• Find a quiet (or typical) time to do the test.
• Pre-run each test a few times to preload buffers.
• Run tests several times and watch for unusual results.
• Record each run in detail.
• Compare the average of the valid runs to expected values.
After establishing a baseline using this method, we can adjust a single parameter
and do the measurements all over again. An empty table for your tests is provided
at the end of this chapter.
Things to Tweak
There are literally thousands of Samba setting combinations that you can use in
search of that perfect server. Those of us with lives outside of system administra-
tion, however, can narrow down the number of options to those listed in this sec-
tion, which are the most likely to affect overall throughput. They are presented
roughly in order of impact.
Log level
This is an obvious one. Increasing the logging level ( log level or debug level
configuration options) is a good way to debug a problem, unless you happen to
be searching for a performance problem! As mentioned in Chapter 4, Disk Shares ,
Samba produces a ton of debugging messages at level 3 and above, and writing
them to disk or syslog is a slow operation. In our smbclient/ftp tests, raising the
log level from 0 to 3 cut the untuned get speed from 645.3 to 622.2KB/s, or
roughly 5 percent. Higher log levels were even worse.
Socket options
The next thing to look at are the socket options configuration options. These
are really host system tuning options, but they’re set on a per-connection basis,
1179974445.064.png 1179974445.065.png 1179974445.066.png 1179974445.068.png 1179974445.069.png 1179974445.070.png 1179974445.071.png 1179974445.072.png 1179974445.073.png 1179974445.074.png 1179974445.075.png 1179974445.076.png 1179974445.077.png 1179974445.079.png 1179974445.080.png 1179974445.081.png 1179974445.082.png 1179974445.083.png 1179974445.084.png 1179974445.085.png 1179974445.086.png 1179974445.087.png 1179974445.088.png 1179974445.090.png 1179974445.091.png 1179974445.092.png 1179974445.093.png 1179974445.094.png 1179974445.095.png 1179974445.096.png 1179974445.097.png 1179974445.098.png 1179974445.099.png 1179974445.101.png 1179974445.102.png 1179974445.103.png 1179974445.104.png 1179974445.105.png 1179974445.106.png 1179974445.107.png 1179974445.108.png 1179974445.109.png 1179974445.110.png 1179974445.112.png 1179974445.113.png 1179974445.114.png 1179974445.115.png 1179974445.116.png 1179974445.117.png 1179974445.118.png 1179974445.119.png 1179974445.120.png 1179974445.121.png 1179974445.123.png 1179974445.124.png 1179974445.125.png 1179974445.126.png 1179974445.127.png 1179974445.128.png 1179974445.129.png 1179974445.130.png 1179974445.131.png 1179974445.132.png 1179974445.134.png 1179974445.135.png 1179974445.136.png 1179974445.137.png 1179974445.138.png 1179974445.139.png 1179974445.140.png 1179974445.141.png 1179974445.142.png 1179974445.143.png
,appb.27799 Page 315 Friday, November 19, 1999 3:30 PM
Samba Tuning
315
and can be reset by Samba on the sockets it employs by adding socket options
= option to the [global] section of your smb.conf file. Not all of these options
are supported by all vendors; check your vendor’s manual pages on setsockopt (1)
or socket (5) for details.
The main options are:
TCP_NODELAY
Have the server send as many packets as necessary to keep delay low. This is
used on telnet connections to give good response time, and is used—some-
what counter-intuitively—to get good speed even when doing small requests
or when acknowledgments are delayed (as seems to occur with Microsoft
TCP/IP). This is worth a 30–50 percent speedup by itself. Incidentally, in
Samba 2.0.4, socket options = TCP_NODELAY became the default value for
that option.
IPTOS_LOWDELAY
This is another option that trades off throughput for lower delay, but which
affects routers and other systems, not the server. All the IPTOS options are
new; they’re not supported by all operating systems and routers. If they are
supported, set IPTOS_LOWDELAY whenever you set TCP_NODELAY .
SO_SNDBUF and SO_RCVBUF
The send and receive buffers can often be the reset to a value higher than that
of the operating system. This yields a marginal increase of speed (until it
reaches a point of diminishing returns).
SO_KEEPALIVE
This initiates a periodic (four-hour) check to see if the client has disappeared.
Expired connections are addressed somewhat better with Samba’s keepalive
and dead time options. All three eventually arrange to close dead connec-
tions, returning unused memory and process-table entries to the operating
system.
There are several other socket options you might look at, (e.g., SO_SNDLOWAT ),
but they vary in availability from vendor to vendor. You probably want to look at
TCP/IP Illustrated if you’re interested in exploring more of these options for per-
formance tuning with Samba.
read raw and write raw
These are important performance configuration options; they enable Samba to use
large reads and writes to the network, of up to 64KB in a single SMB request. They
also require the largest SMB packet structures, SMBreadraw and SMBwriteraw ,
from which the options take their names. Note that this is not the same as a Unix
raw read . This Unix term usually refers to reading disks without using the files sys-
tem, quite a different sense from the one described here for Samba.
1179974445.145.png 1179974445.146.png 1179974445.147.png 1179974445.148.png 1179974445.149.png 1179974445.150.png 1179974445.151.png 1179974445.152.png 1179974445.153.png 1179974445.154.png 1179974445.156.png 1179974445.157.png 1179974445.158.png 1179974445.159.png 1179974445.160.png 1179974445.161.png 1179974445.162.png 1179974445.163.png 1179974445.164.png 1179974445.165.png 1179974445.167.png 1179974445.168.png 1179974445.169.png 1179974445.170.png 1179974445.171.png 1179974445.172.png 1179974445.173.png 1179974445.174.png 1179974445.175.png 1179974445.176.png 1179974445.178.png 1179974445.179.png 1179974445.180.png 1179974445.181.png 1179974445.182.png 1179974445.183.png 1179974445.184.png 1179974445.185.png 1179974445.186.png 1179974445.187.png 1179974445.189.png 1179974445.190.png 1179974445.191.png 1179974445.192.png 1179974445.193.png 1179974445.194.png 1179974445.195.png 1179974445.196.png 1179974445.197.png 1179974445.198.png 1179974445.200.png 1179974445.201.png 1179974445.202.png 1179974445.203.png 1179974445.204.png 1179974445.205.png 1179974445.206.png 1179974445.207.png 1179974445.208.png 1179974445.209.png 1179974445.211.png 1179974445.212.png 1179974445.213.png 1179974445.214.png 1179974445.215.png 1179974445.216.png 1179974445.217.png 1179974445.218.png 1179974445.219.png 1179974445.220.png 1179974445.222.png 1179974445.223.png 1179974445.224.png
,appb.27799 Page 316 Friday, November 19, 1999 3:30 PM
316
Appendix B: Samba Performance Tuning
In the past, some client programs failed if you tried to use read raw . As far as we
know, no client suffers from this problem any more. Read and write raw default to
yes , and should be left on unless you find you have one of the buggy clients.
Opportunistic locking
Opportunistic locks, or oplocks , allow clients to cache files locally, improving per-
formance on the order of 30 percent. This option is now enabled by default. For
read-only files, the fake oplocks provides the same functionality without actu-
ally doing any caching. If you have files that cannot be cached, oplocks can be
turned off.
Database files should never be cached, nor should any files that are updated both
on the server and the client and whose changes must be immediately visible. For
these files, the veto oplock files option allows you to specify a list of individ-
ual files or a pattern containing wildcards to avoid caching. oplocks can be turned
off on a share-by-share basis if you have large groups of files you don’t want
cached on clients. See Chapter 5, Browsing and Advanced Disk Shares , for more
information on opportunistic locks.
IP packet size (MTU)
Networks generally set a limit to the size of an individual transmission or packet
This is called the Maximum Segment Size, or if the packet header size is included,
the Maximum Transport Unit (MTU). This MTU is not set by Samba, but Samba
needs to use a max xmit (write size) bigger than the MTU, or throughput will be
reduced. This is discussed in further detail in the following note. The MTU is nor-
mally preset to 1500 bytes on an Ethernet and 4098 bytes on FDDI. In general,
having it too low cuts throughput, and having it too high causes a sudden perfor-
mance dropoff due to fragmentation and retransmissions.
If you are communicating over a router, some systems will assume
the router is a serial link (e.g., a T1) and set the MTU to more or less
536 bytes. Windows 95 makes this mistake, which causes nearby cli-
ents to perform well, but clients on the other side of the router to be
noticeably slower. If the client makes the opposite error and uses a
large MTU on a link which demands a small one, the packets will be
broken up into fragments. This slows transfers slightly, and any net-
working errors will cause multiple fragments to be retransmitted,
which slows Samba significantly. Fortunately, you can modify the
Windows MTU size to prevent either error. To understand this in
more detail, see “The Windows 95 Networking Frequently Asked
Questions (FAQ)” at http://www.stanford.edu/~llurch/win95netbugs/
faq.html , which explains how to override the Windows MTU and
Window Size.
1179974445.225.png 1179974445.226.png 1179974445.227.png 1179974445.228.png 1179974445.229.png 1179974445.230.png 1179974445.231.png 1179974445.233.png 1179974445.234.png 1179974445.235.png 1179974445.236.png 1179974445.237.png 1179974445.238.png 1179974445.239.png 1179974445.240.png 1179974445.241.png 1179974445.242.png 1179974445.244.png 1179974445.245.png 1179974445.246.png 1179974445.247.png 1179974445.248.png 1179974445.249.png 1179974445.250.png 1179974445.251.png 1179974445.252.png 1179974445.253.png 1179974445.255.png 1179974445.256.png 1179974445.257.png 1179974445.258.png 1179974445.259.png 1179974445.260.png 1179974445.261.png 1179974445.262.png 1179974445.263.png 1179974445.264.png 1179974445.266.png 1179974445.267.png 1179974445.268.png 1179974445.269.png 1179974445.270.png 1179974445.271.png 1179974445.272.png 1179974445.273.png 1179974445.274.png 1179974445.275.png 1179974445.277.png 1179974445.278.png 1179974445.279.png 1179974445.280.png 1179974445.281.png 1179974445.282.png 1179974445.283.png 1179974445.284.png 1179974445.285.png 1179974445.286.png 1179974445.288.png 1179974445.289.png 1179974445.290.png 1179974445.291.png 1179974445.292.png 1179974445.293.png 1179974445.294.png 1179974445.295.png 1179974445.296.png 1179974445.297.png 1179974445.299.png 1179974445.300.png 1179974445.301.png 1179974445.302.png 1179974445.303.png 1179974445.304.png 1179974445.305.png 1179974445.306.png 1179974445.307.png 1179974445.308.png
Zgłoś jeśli naruszono regulamin