This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.(This used to...
[sfrench/samba-autobuild/.git] / docs / docbook / projdoc / Speed.xml
1 <chapter id="speed">
2
3 <chapterinfo>
4         <author>
5                 <firstname>Paul</firstname><surname>Cochrane</surname>
6                 <affiliation>
7                         <orgname>Dundee Limb Fitting Centre</orgname>
8                         <address><email>paulc@dth.scot.nhs.uk</email></address>
9                 </affiliation>
10         </author>
11         &author.jelmer;
12         &author.jht;
13 </chapterinfo>
14
15 <title>Samba Performance Tuning</title>
16
17 <sect1>
18 <title>Comparisons</title>
19
20 <para>
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
25 SMB server.
26 </para>
27
28 <para>
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.
33 </para>
34
35 <para>
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.
39 </para>
40
41 <para>
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
47 systems.
48 </para>
49
50 </sect1>
51
52 <sect1>
53 <title>Socket options</title>
54
55 <para>
56 There are a number of socket options that can greatly affect the
57 performance of a TCP based server like Samba.
58 </para>
59
60 <para>
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.
63 </para>
64
65 <para>
66 The <parameter>socket options</parameter> section of the &smb.conf; manual page describes how
67 to set these and gives recommendations.
68 </para>
69
70 <para>
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.
74 </para>
75
76 <para>
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.
82 </para>
83
84 </sect1>
85
86 <sect1>
87 <title>Read size</title>
88
89 <para>
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.
97 </para>
98
99 <para>
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.
103 </para>
104
105 <para>
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.
110 </para>
111
112 </sect1>
113
114 <sect1>
115 <title>Max xmit</title>
116
117 <para>
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
124 honours this limit.
125 </para>
126
127 <para>
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.
131 </para>
132
133 <para>
134 In most cases the default is the best option.
135 </para>
136
137 </sect1>
138
139 <sect1>
140 <title>Log level</title>
141
142 <para>
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
146 expensive. 
147 </para>
148 </sect1>
149
150 <sect1>
151 <title>Read raw</title>
152
153 <para>
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.
158 </para>
159
160 <para>
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
163 read operations. 
164 </para>
165
166 <para>
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.
170 </para>
171
172 </sect1>
173
174 <sect1>
175 <title>Write raw</title>
176
177 <para>
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.
182 </para>
183
184 <para>
185 Some machines may find <parameter>write raw</parameter> slower than normal write, in which
186 case you may wish to change this option.
187 </para>
188
189 </sect1>
190
191 <sect1>
192 <title>Slow Logins</title>
193
194 <para>
195 Slow logins are almost always due to the password checking time. Using
196 the lowest practical <parameter>password level</parameter> will improve things. 
197 </para>
198
199 </sect1>
200
201 <sect1>
202 <title>LDAP</title>
203
204 <para>
205 LDAP can be vastly improved by using the
206 <ulink url="smb.conf.5.html#LDAPTRUSTIDS"><parameter>ldap trust ids</parameter></ulink> parameter.
207 </para>
208
209 </sect1>
210
211
212 <sect1>
213 <title>Client tuning</title>
214
215 <para>
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>.
220 </para>
221
222 </sect1>
223
224 <sect1>
225 <title>Samba performance problem due changing kernel (2.4.20 Linux kernel)</title>
226
227 <para>
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.
237 </para>
238
239 <para>
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.
244 </para>
245
246 </sect1>
247
248 <sect1>
249 <title>Corrupt tdb Files</title>
250
251 <para>
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.
259 </para>
260
261 <para>
262 Q1) Is there any method of keeping the *.tbl files in top condition or
263 how to early detect corruption?
264 </para>
265
266 <para>
267 A1) Yes, run <command>tdbbackup</command> each time after stoping nmbd and before starting nmbd.
268 </para>
269
270 <para>
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?
273 </para>
274
275 <para>
276 A2) Yes! Samba answer as for Q1!
277 </para>
278
279 </sect1>
280
281 </chapter>