Use the Samba DTD rather then the original DocBook one. This step will
[Samba.git] / docs / Samba-HOWTO-Collection / Speed.xml
blob74c6ec2b7394b3781390e19a6d1117f14d283def
1 <?xml version="1.0" encoding="iso-8859-1"?>
2 <!DOCTYPE book PUBLIC "-//Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc">
3 <chapter id="speed">
5 <chapterinfo>
6         <author>
7                 <firstname>Paul</firstname><surname>Cochrane</surname>
8                 <affiliation>
9                         <orgname>Dundee Limb Fitting Centre</orgname>
10                         <address><email>paulc@dth.scot.nhs.uk</email></address>
11                 </affiliation>
12         </author>
13         &author.jelmer;
14         &author.jht;
15 </chapterinfo>
17 <title>Samba Performance Tuning</title>
19 <sect1>
20 <title>Comparisons</title>
22 <para>
23 The Samba server uses TCP to talk to the client. Thus if you are
24 trying to see if it performs well, you should really compare it to
25 programs that use the same protocol. The most readily available
26 programs for file transfer that use TCP are ftp or another TCP-based
27 SMB server.
28 </para>
30 <para>
31 If you want to test against something like an NT or Windows for Workgroups server, then
32 you will have to disable all but TCP on either the client or
33 server. Otherwise, you may well be using a totally different protocol
34 (such as NetBEUI) and comparisons may not be valid.
35 </para>
37 <para>
38 Generally, you should find that Samba performs similarly to ftp at raw
39 transfer speed. It should perform quite a bit faster than NFS,
40 although this depends on your system.
41 </para>
43 <para>
44 Several people have done comparisons between Samba and Novell, NFS or
45 Windows NT. In some cases Samba performed the best, in others the worst. I
46 suspect the biggest factor is not Samba versus some other system, but the
47 hardware and drivers used on the various systems. Given similar
48 hardware, Samba should certainly be competitive in speed with other
49 systems.
50 </para>
52 </sect1>
54 <sect1>
55 <title>Socket Options</title>
57 <para>
58 There are a number of socket options that can greatly affect the
59 performance of a TCP-based server like Samba.
60 </para>
62 <para>
63 The socket options that Samba uses are settable both on the command
64 line with the <option>-O</option> option, or in the &smb.conf; file.
65 </para>
67 <para>
68 The <smbconfoption><name>socket options</name></smbconfoption> section of the &smb.conf; manual page describes how
69 to set these and gives recommendations.
70 </para>
72 <para>
73 Getting the socket options correct can make a big difference to your
74 performance, but getting them wrong can degrade it by just as
75 much. The correct settings are very dependent on your local network.
76 </para>
78 <para>
79 The socket option TCP_NODELAY is the one that seems to make the biggest single difference
80 for most networks. Many people report that adding
81 <?latex \linebreak ?><smbconfoption><name>socket options</name><value>TCP_NODELAY</value></smbconfoption>
82 doubles the read performance of a Samba drive. The best explanation I have seen for
83 this is that the Microsoft TCP/IP stack is slow in sending TCP ACKs.
84 </para>
86 <para>
87 There have been reports that setting <parameter>socket options = SO_RCVBUF=8192</parameter> in smb.conf
88 can seriously degrade Samba performance on the loopback adaptor (IP Address 127.0.0.1). It is strongly
89 recommended that before specifying any settings for <parameter>socket options</parameter> the effect
90 first be quantitatively measured on the server being configured.
91 </para>
93 </sect1>
95 <sect1>
96 <title>Read Size</title>
98 <para>
99 The option <smbconfoption><name>read size</name></smbconfoption> affects the overlap of disk
100 reads/writes with network reads/writes. If the amount of data being
101 transferred in several of the SMB commands (currently SMBwrite, SMBwriteX and
102 SMBreadbraw) is larger than this value, then the server begins writing
103 the data before it has received the whole packet from the network, or
104 in the case of SMBreadbraw, it begins writing to the network before
105 all the data has been read from disk.
106 </para>
108 <para>
109 This overlapping works best when the speeds of disk and network access
110 are similar, having little effect when the speed of one is much
111 greater than the other.
112 </para>
114 <para>
115 The default value is 16384, but little experimentation has been
116 done as yet to determine the optimal value, and it is likely that the best
117 value will vary greatly between systems anyway. A value over 65536 is
118 pointless and will cause you to allocate memory unnecessarily.
119 </para>
121 </sect1>
123 <sect1>
124 <title>Max Xmit</title>
126 <para>
127         At startup the client and server negotiate a <parameter>maximum transmit</parameter> size,
128 which limits the size of nearly all SMB commands. You can set the
129 maximum size that Samba will negotiate using the <smbconfoption><name>max xmit</name></smbconfoption> option
130 in &smb.conf;. Note that this is the maximum size of SMB requests that 
131 Samba will accept, but not the maximum size that the client will accept.
132 The client maximum receive size is sent to Samba by the client and Samba
133 honors this limit.
134 </para>
136 <para>
137 It defaults to 65536 bytes (the maximum), but it is possible that some
138 clients may perform better with a smaller transmit unit. Trying values
139 of less than 2048 is likely to cause severe problems.
140 In most cases the default is the best option.
141 </para>
143 </sect1>
145 <sect1>
146 <title>Log Level</title>
148 <para>
149 If you set the log level (also known as <smbconfoption><name>debug level</name></smbconfoption>) higher than 2
150 then you may suffer a large drop in performance. This is because the
151 server flushes the log file after each operation, which can be quite
152 expensive. 
153 </para>
154 </sect1>
156 <sect1>
157 <title>Read Raw</title>
159 <para>
160 The <smbconfoption><name>read raw</name></smbconfoption> operation is designed to be an optimized, low-latency
161 file read operation. A server may choose to not support it,
162 however, and Samba makes support for <smbconfoption><name>read raw</name></smbconfoption> optional, with it
163 being enabled by default.
164 </para>
166 <para>
167 In some cases clients do not handle <smbconfoption><name>read raw</name></smbconfoption> very well and actually
168 get lower performance using it than they get using the conventional
169 read operations. 
170 </para>
172 <para>
173 So you might like to try <smbconfoption><name>read raw</name><value>no</value></smbconfoption> and see what happens on your
174 network. It might lower, raise or not effect your performance. Only
175 testing can really tell.
176 </para>
178 </sect1>
180 <sect1>
181 <title>Write Raw</title>
183 <para>
184 The <smbconfoption><name>write raw</name></smbconfoption> operation is designed to be an optimized, low-latency
185 file write operation. A server may choose to not support it, however, and Samba makes support for
186 <smbconfoption><name>write raw</name></smbconfoption> optional, with it being enabled by default.
187 </para>
189 <para>
190 Some machines may find <smbconfoption><name>write raw</name></smbconfoption> slower than normal write, in which
191 case you may wish to change this option.
192 </para>
194 </sect1>
196 <sect1>
197 <title>Slow Logins</title>
199 <para>
200 Slow logins are almost always due to the password checking time. Using
201 the lowest practical <smbconfoption><name>password level</name></smbconfoption> will improve things. 
202 </para>
204 </sect1>
206 <sect1>
207 <title>Client Tuning</title>
209 <para>
210 Often a speed problem can be traced to the client. The client (for
211 example Windows for Workgroups) can often be tuned for better TCP
212 performance. Check the sections on the various clients in 
213 <link linkend="Other-Clients">Samba and Other CIFS Clients</link>.
214 </para>
216 </sect1>
218 <sect1>
219 <title>Samba Performance Problem Due to Changing Linux Kernel</title>
221 <para>
222 A user wrote the following to the mailing list:
223 </para>
225 <para>
226 I am running Gentoo on my server and Samba 2.2.8a. Recently
227 I changed kernel version from <filename>linux-2.4.19-gentoo-r10</filename> to
228 <filename>linux-2.4.20-wolk4.0s</filename>. And now I have a performance issue with Samba. 
229 Many of you will probably say,  <quote>Move to vanilla sources!</quote>
230 Well, I tried that and it didn't work. I have a 100mb LAN and two computers (Linux and
231 Windows 2000). The Linux server shares directories with DivX files, the client
232 (Windows 2000) plays them via LAN. Before when I was running the 2.4.19 kernel
233 everything was fine, but now movies freeze and stop. I tried moving
234 files between the server and Windows and it is terribly slow.
235 </para>
237 <para>
238 The answer he was given is:
239 </para>
241 <para>
242 Grab the mii-tool and check the duplex settings on the NIC.
243 My guess is that it is a link layer issue, not an application
244 layer problem. Also run ifconfig and verify that the framing
245 error, collisions, and so on, look normal for ethernet.
246 </para>
248 </sect1>
250 <sect1>
251 <title>Corrupt tdb Files</title>
253 <para>
254 Our Samba PDC server has been hosting three TB of data to our 500+ users
255 [Windows NT/XP]  for the last three years using Samba without a problem.
256 Today all shares went very slow. Also the main smbd kept
257 spawning new processes so we had 1600+ running smbd's (normally we avg. 250).
258 It crashed the SUN E3500 cluster twice. After a lot of searching, I
259 decided to <command>rm /var/locks/*.tdb</command>. Happy again.
260 </para>
262 <para>
263 <emphasis>Question:</emphasis> Is there any method of keeping the *.tdb files in top condition or
264 how can I detect early corruption?
265 </para>
267 <para>
268 <emphasis>Answer:</emphasis> Yes, run <command>tdbbackup</command> each time after stopping nmbd and before starting nmbd.
269 </para>
271 <para>
272 <emphasis>Question:</emphasis> What I also would like to mention is that the service latency seems
273 a lot lower than before the locks cleanup. Any ideas on keeping it top notch?
274 </para>
276 <para>
277 <emphasis>Answer:</emphasis> Yes. Same answer as for previous question!
278 </para>
280 </sect1>
282 <sect1>
283 <title>Samba Performance is Very Slow</title>
285 <para>
286 A site reported experiencing very baffling symptoms with MYOB Premier opening and
287 accessing it's data-files. Some  operations on the file would take between 40 and
288 45 seconds.
289 </para>
291 <para>
292 It turned out that the printer monitor program running on the windows
293 clients was causing the problems. From the logs, we saw activity coming
294 through with pauses of about 1 second.
295 </para>
297 <para>
298 Stopping the monitor software resulted in the networks access at normal
299 (quick) speed. Restarting the program caused the speed to slow down
300 again. The printer was a cannon lbp810 and the relevant task was
301 something like CAPON (not sure on spelling). The monitor software
302 displayed a printing now dialog on the client during printing.
303 </para>
305 <para>
306 We discovered this by starting with a clean install of windows and
307 trying the app at every step of the installation of other software
308 process (had to do this many times).
309 </para>
311 <para>
312 Moral of the story, check everything (other software included)!
313 </para>
315 </sect1>
317 </chapter>