5 <firstname>Paul</firstname><surname>Cochrane</surname>
7 <orgname>Dundee Limb Fitting Centre</orgname>
8 <address><email>paulc@dth.scot.nhs.uk</email></address>
15 <title>Samba Performance Tuning</title>
18 <title>Comparisons</title>
21 The Samba server uses TCP to talk to the client. Thus if you are
22 trying to see if it performs well you should really compare it to
23 programs that use the same protocol. The most readily available
24 programs for file transfer that use TCP are ftp or another TCP based
29 If you want to test against something like a NT or WfWg server then
30 you will have to disable all but TCP on either the client or
31 server. Otherwise you may well be using a totally different protocol
32 (such as Netbeui) and comparisons may not be valid.
36 Generally you should find that Samba performs similarly to ftp at raw
37 transfer speed. It should perform quite a bit faster than NFS,
38 although this very much depends on your system.
42 Several people have done comparisons between Samba and Novell, NFS or
43 WinNT. In some cases Samba performed the best, in others the worst. I
44 suspect the biggest factor is not Samba vs some other system but the
45 hardware and drivers used on the various systems. Given similar
46 hardware Samba should certainly be competitive in speed with other
53 <title>Socket options</title>
56 There are a number of socket options that can greatly affect the
57 performance of a TCP based server like Samba.
61 The socket options that Samba uses are settable both on the command
62 line with the <option>-O</option> option, or in the &smb.conf; file.
66 The <parameter>socket options</parameter> section of the &smb.conf; manual page describes how
67 to set these and gives recommendations.
71 Getting the socket options right can make a big difference to your
72 performance, but getting them wrong can degrade it by just as
73 much. The correct settings are very dependent on your local network.
77 The socket option TCP_NODELAY is the one that seems to make the
78 biggest single difference for most networks. Many people report that
79 adding <parameter>socket options = TCP_NODELAY</parameter> doubles the read
80 performance of a Samba drive. The best explanation I have seen for this is
81 that the Microsoft TCP/IP stack is slow in sending tcp ACKs.
87 <title>Read size</title>
90 The option <parameter>read size</parameter> affects the overlap of disk
91 reads/writes with network reads/writes. If the amount of data being
92 transferred in several of the SMB commands (currently SMBwrite, SMBwriteX and
93 SMBreadbraw) is larger than this value then the server begins writing
94 the data before it has received the whole packet from the network, or
95 in the case of SMBreadbraw, it begins writing to the network before
96 all the data has been read from disk.
100 This overlapping works best when the speeds of disk and network access
101 are similar, having very little effect when the speed of one is much
102 greater than the other.
106 The default value is 16384, but very little experimentation has been
107 done yet to determine the optimal value, and it is likely that the best
108 value will vary greatly between systems anyway. A value over 65536 is
109 pointless and will cause you to allocate memory unnecessarily.
115 <title>Max xmit</title>
118 At startup the client and server negotiate a <parameter>maximum transmit</parameter> size,
119 which limits the size of nearly all SMB commands. You can set the
120 maximum size that Samba will negotiate using the <parameter>max xmit = </parameter> option
121 in &smb.conf;. Note that this is the maximum size of SMB requests that
122 Samba will accept, but not the maximum size that the *client* will accept.
123 The client maximum receive size is sent to Samba by the client and Samba
128 It defaults to 65536 bytes (the maximum), but it is possible that some
129 clients may perform better with a smaller transmit unit. Trying values
130 of less than 2048 is likely to cause severe problems.
134 In most cases the default is the best option.
140 <title>Log level</title>
143 If you set the log level (also known as <parameter>debug level</parameter>) higher than 2
144 then you may suffer a large drop in performance. This is because the
145 server flushes the log file after each operation, which can be very
151 <title>Read raw</title>
154 The <parameter>read raw</parameter> operation is designed to be an optimised, low-latency
155 file read operation. A server may choose to not support it,
156 however. and Samba makes support for <parameter>read raw</parameter> optional, with it
157 being enabled by default.
161 In some cases clients don't handle <parameter>read raw</parameter> very well and actually
162 get lower performance using it than they get using the conventional
167 So you might like to try <parameter>read raw = no</parameter> and see what happens on your
168 network. It might lower, raise or not affect your performance. Only
169 testing can really tell.
175 <title>Write raw</title>
178 The <parameter>write raw</parameter> operation is designed to be an optimised, low-latency
179 file write operation. A server may choose to not support it,
180 however. and Samba makes support for <parameter>write raw</parameter> optional, with it
181 being enabled by default.
185 Some machines may find <parameter>write raw</parameter> slower than normal write, in which
186 case you may wish to change this option.
192 <title>Slow Logins</title>
195 Slow logins are almost always due to the password checking time. Using
196 the lowest practical <parameter>password level</parameter> will improve things.
205 LDAP can be vastly improved by using the
206 <ulink url="smb.conf.5.html#LDAPTRUSTIDS"><parameter>ldap trust ids</parameter></ulink> parameter.
213 <title>Client tuning</title>
216 Often a speed problem can be traced to the client. The client (for
217 example Windows for Workgroups) can often be tuned for better TCP
218 performance. Check the sections on the various clients in
219 <link linkend="Other-Clients">Samba and Other Clients</link>.
225 <title>Samba performance problem due changing kernel (2.4.20 Linux kernel)</title>
228 Hi everyone. I am running Gentoo on my server and samba 2.2.8a. Recently
229 I changed kernel version from linux-2.4.19-gentoo-r10 to
230 linux-2.4.20-wolk4.0s. And now I have performance issue with samba. Ok
231 many of you will probably say that move to vanilla sources...well I ried
232 it too and it didn't work. I have 100mb LAN and two computers (linux +
233 Windows2000). Linux server shares directory with DivX files, client
234 (windows2000) plays them via LAN. Before when I was running 2.4.19 kernel
235 everything was fine, but now movies freezes and stops...I tried moving
236 files between server and Windows and it's trerribly slow.
240 Grab mii-tool and check the duplex settings on the NIC.
241 My guess is that it is a link layer issue, not an application
242 layer problem. Also run ifconfig and verify that the framing
243 error, collisions, etc... look normal for ethernet.
249 <title>Corrupt tdb Files</title>
252 Well today it happend, our first major problem using samba.
253 Our samba PDC server has been hosting 3 TB of data to our 500+ users
254 [Windows NT/XP] for the last 3 years using samba, no problem.
255 But today all shares went SLOW; very slow. Also the main smbd kept
256 spawning new processes so we had 1600+ running smbd's (normally we avg. 250).
257 It crashed the SUN E3500 cluster twice. After alot of searching I
258 decided to <command>rm /var/locks/*.tbl</command>. Happy again.
262 Q1) Is there any method of keeping the *.tbl files in top condition or
263 how to early detect corruption?
267 A1) Yes, run <command>tdbbackup</command> each time after stoping nmbd and before starting nmbd.
271 Q2) What I also would like to mention is that the service latency seems
272 alot lower then before the locks cleanup, any ideas on keeping it top notch?
276 A2) Yes! Samba answer as for Q1!