Regenerate
[samba.git] / docs / htmldocs / speed.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <HTML
3 ><HEAD
4 ><TITLE
5 >Samba performance issues</TITLE
6 ><META
7 NAME="GENERATOR"
8 CONTENT="Modular DocBook HTML Stylesheet Version 1.77+"><LINK
9 REL="HOME"
10 TITLE="SAMBA Project Documentation"
11 HREF="samba-howto-collection.html"><LINK
12 REL="UP"
13 TITLE="Optional configuration"
14 HREF="optional.html"><LINK
15 REL="PREVIOUS"
16 TITLE="Group mapping HOWTO"
17 HREF="groupmapping.html"><LINK
18 REL="NEXT"
19 TITLE="Creating Group Profiles"
20 HREF="groupprofiles.html"></HEAD
21 ><BODY
22 CLASS="CHAPTER"
23 BGCOLOR="#FFFFFF"
24 TEXT="#000000"
25 LINK="#0000FF"
26 VLINK="#840084"
27 ALINK="#0000FF"
28 ><DIV
29 CLASS="NAVHEADER"
30 ><TABLE
31 SUMMARY="Header navigation table"
32 WIDTH="100%"
33 BORDER="0"
34 CELLPADDING="0"
35 CELLSPACING="0"
36 ><TR
37 ><TH
38 COLSPAN="3"
39 ALIGN="center"
40 >SAMBA Project Documentation</TH
41 ></TR
42 ><TR
43 ><TD
44 WIDTH="10%"
45 ALIGN="left"
46 VALIGN="bottom"
47 ><A
48 HREF="groupmapping.html"
49 ACCESSKEY="P"
50 >Prev</A
51 ></TD
52 ><TD
53 WIDTH="80%"
54 ALIGN="center"
55 VALIGN="bottom"
56 ></TD
57 ><TD
58 WIDTH="10%"
59 ALIGN="right"
60 VALIGN="bottom"
61 ><A
62 HREF="groupprofiles.html"
63 ACCESSKEY="N"
64 >Next</A
65 ></TD
66 ></TR
67 ></TABLE
68 ><HR
69 ALIGN="LEFT"
70 WIDTH="100%"></DIV
71 ><DIV
72 CLASS="CHAPTER"
73 ><H1
74 ><A
75 NAME="SPEED"
76 ></A
77 >Chapter 19. Samba performance issues</H1
78 ><DIV
79 CLASS="SECT1"
80 ><H1
81 CLASS="SECT1"
82 ><A
83 NAME="AEN3033"
84 ></A
85 >19.1. Comparisons</H1
86 ><P
87 >The Samba server uses TCP to talk to the client. Thus if you are
88 trying to see if it performs well you should really compare it to
89 programs that use the same protocol. The most readily available
90 programs for file transfer that use TCP are ftp or another TCP based
91 SMB server.</P
92 ><P
93 >If you want to test against something like a NT or WfWg server then
94 you will have to disable all but TCP on either the client or
95 server. Otherwise you may well be using a totally different protocol
96 (such as Netbeui) and comparisons may not be valid.</P
97 ><P
98 >Generally you should find that Samba performs similarly to ftp at raw
99 transfer speed. It should perform quite a bit faster than NFS,
100 although this very much depends on your system.</P
101 ><P
102 >Several people have done comparisons between Samba and Novell, NFS or
103 WinNT. In some cases Samba performed the best, in others the worst. I
104 suspect the biggest factor is not Samba vs some other system but the
105 hardware and drivers used on the various systems. Given similar
106 hardware Samba should certainly be competitive in speed with other
107 systems.</P
108 ></DIV
109 ><DIV
110 CLASS="SECT1"
111 ><H1
112 CLASS="SECT1"
113 ><A
114 NAME="AEN3039"
115 ></A
116 >19.2. Socket options</H1
117 ><P
118 >There are a number of socket options that can greatly affect the
119 performance of a TCP based server like Samba.</P
120 ><P
121 >The socket options that Samba uses are settable both on the command
122 line with the -O option, or in the smb.conf file.</P
123 ><P
124 >The "socket options" section of the smb.conf manual page describes how
125 to set these and gives recommendations.</P
126 ><P
127 >Getting the socket options right can make a big difference to your
128 performance, but getting them wrong can degrade it by just as
129 much. The correct settings are very dependent on your local network.</P
130 ><P
131 >The socket option TCP_NODELAY is the one that seems to make the
132 biggest single difference for most networks. Many people report that
133 adding "socket options = TCP_NODELAY" doubles the read performance of
134 a Samba drive. The best explanation I have seen for this is that the
135 Microsoft TCP/IP stack is slow in sending tcp ACKs.</P
136 ></DIV
137 ><DIV
138 CLASS="SECT1"
139 ><H1
140 CLASS="SECT1"
141 ><A
142 NAME="AEN3046"
143 ></A
144 >19.3. Read size</H1
145 ><P
146 >The option "read size" affects the overlap of disk reads/writes with
147 network reads/writes. If the amount of data being transferred in
148 several of the SMB commands (currently SMBwrite, SMBwriteX and
149 SMBreadbraw) is larger than this value then the server begins writing
150 the data before it has received the whole packet from the network, or
151 in the case of SMBreadbraw, it begins writing to the network before
152 all the data has been read from disk.</P
153 ><P
154 >This overlapping works best when the speeds of disk and network access
155 are similar, having very little effect when the speed of one is much
156 greater than the other.</P
157 ><P
158 >The default value is 16384, but very little experimentation has been
159 done yet to determine the optimal value, and it is likely that the best
160 value will vary greatly between systems anyway. A value over 65536 is
161 pointless and will cause you to allocate memory unnecessarily.</P
162 ></DIV
163 ><DIV
164 CLASS="SECT1"
165 ><H1
166 CLASS="SECT1"
167 ><A
168 NAME="AEN3051"
169 ></A
170 >19.4. Max xmit</H1
171 ><P
172 >At startup the client and server negotiate a "maximum transmit" size,
173 which limits the size of nearly all SMB commands. You can set the
174 maximum size that Samba will negotiate using the "max xmit = " option
175 in smb.conf. Note that this is the maximum size of SMB request that 
176 Samba will accept, but not the maximum size that the *client* will accept.
177 The client maximum receive size is sent to Samba by the client and Samba
178 honours this limit.</P
179 ><P
180 >It defaults to 65536 bytes (the maximum), but it is possible that some
181 clients may perform better with a smaller transmit unit. Trying values
182 of less than 2048 is likely to cause severe problems.</P
183 ><P
184 >In most cases the default is the best option.</P
185 ></DIV
186 ><DIV
187 CLASS="SECT1"
188 ><H1
189 CLASS="SECT1"
190 ><A
191 NAME="AEN3056"
192 ></A
193 >19.5. Log level</H1
194 ><P
195 >If you set the log level (also known as "debug level") higher than 2
196 then you may suffer a large drop in performance. This is because the
197 server flushes the log file after each operation, which can be very
198 expensive. </P
199 ></DIV
200 ><DIV
201 CLASS="SECT1"
202 ><H1
203 CLASS="SECT1"
204 ><A
205 NAME="AEN3059"
206 ></A
207 >19.6. Read raw</H1
208 ><P
209 >The "read raw" operation is designed to be an optimised, low-latency
210 file read operation. A server may choose to not support it,
211 however. and Samba makes support for "read raw" optional, with it
212 being enabled by default.</P
213 ><P
214 >In some cases clients don't handle "read raw" very well and actually
215 get lower performance using it than they get using the conventional
216 read operations. </P
217 ><P
218 >So you might like to try "read raw = no" and see what happens on your
219 network. It might lower, raise or not affect your performance. Only
220 testing can really tell.</P
221 ></DIV
222 ><DIV
223 CLASS="SECT1"
224 ><H1
225 CLASS="SECT1"
226 ><A
227 NAME="AEN3064"
228 ></A
229 >19.7. Write raw</H1
230 ><P
231 >The "write raw" operation is designed to be an optimised, low-latency
232 file write operation. A server may choose to not support it,
233 however. and Samba makes support for "write raw" optional, with it
234 being enabled by default.</P
235 ><P
236 >Some machines may find "write raw" slower than normal write, in which
237 case you may wish to change this option.</P
238 ></DIV
239 ><DIV
240 CLASS="SECT1"
241 ><H1
242 CLASS="SECT1"
243 ><A
244 NAME="AEN3068"
245 ></A
246 >19.8. Slow Clients</H1
247 ><P
248 >One person has reported that setting the protocol to COREPLUS rather
249 than LANMAN2 gave a dramatic speed improvement (from 10k/s to 150k/s).</P
250 ><P
251 >I suspect that his PC's (386sx16 based) were asking for more data than
252 they could chew. I suspect a similar speed could be had by setting
253 "read raw = no" and "max xmit = 2048", instead of changing the
254 protocol. Lowering the "read size" might also help.</P
255 ></DIV
256 ><DIV
257 CLASS="SECT1"
258 ><H1
259 CLASS="SECT1"
260 ><A
261 NAME="AEN3072"
262 ></A
263 >19.9. Slow Logins</H1
264 ><P
265 >Slow logins are almost always due to the password checking time. Using
266 the lowest practical "password level" will improve things a lot. You
267 could also enable the "UFC crypt" option in the Makefile.</P
268 ></DIV
269 ><DIV
270 CLASS="SECT1"
271 ><H1
272 CLASS="SECT1"
273 ><A
274 NAME="AEN3075"
275 ></A
276 >19.10. Client tuning</H1
277 ><P
278 >Often a speed problem can be traced to the client. The client (for
279 example Windows for Workgroups) can often be tuned for better TCP
280 performance.</P
281 ><P
282 >See your client docs for details. In particular, I have heard rumours
283 that the WfWg options TCPWINDOWSIZE and TCPSEGMENTSIZE can have a
284 large impact on performance.</P
285 ><P
286 >Also note that some people have found that setting DefaultRcvWindow in
287 the [MSTCP] section of the SYSTEM.INI file under WfWg to 3072 gives a
288 big improvement. I don't know why.</P
289 ><P
290 >My own experience wth DefaultRcvWindow is that I get much better
291 performance with a large value (16384 or larger). Other people have
292 reported that anything over 3072 slows things down enourmously. One
293 person even reported a speed drop of a factor of 30 when he went from
294 3072 to 8192. I don't know why.</P
295 ><P
296 >It probably depends a lot on your hardware, and the type of unix box
297 you have at the other end of the link.</P
298 ><P
299 >Paul Cochrane has done some testing on client side tuning and come 
300 to the following conclusions:</P
301 ><P
302 >Install the W2setup.exe file from www.microsoft.com. This is an 
303 update for the winsock stack and utilities which improve performance.</P
304 ><P
305 >Configure the win95 TCPIP registry settings to give better 
306 perfomance. I use a program called MTUSPEED.exe which I got off the 
307 net. There are various other utilities of this type freely available. 
308 The setting which give the best performance for me are:</P
309 ><P
310 ></P
311 ><OL
312 TYPE="1"
313 ><LI
314 ><P
315 >MaxMTU                  Remove</P
316 ></LI
317 ><LI
318 ><P
319 >RWIN                    Remove</P
320 ></LI
321 ><LI
322 ><P
323 >MTUAutoDiscover         Disable</P
324 ></LI
325 ><LI
326 ><P
327 >MTUBlackHoleDetect      Disable</P
328 ></LI
329 ><LI
330 ><P
331 >Time To Live            Enabled</P
332 ></LI
333 ><LI
334 ><P
335 >Time To Live - HOPS     32</P
336 ></LI
337 ><LI
338 ><P
339 >NDI Cache Size          0</P
340 ></LI
341 ></OL
342 ><P
343 >I tried virtually all of the items mentioned in the document and 
344 the only one which made a difference to me was the socket options. It 
345 turned out I was better off without any!!!!!</P
346 ><P
347 >In terms of overall speed of transfer, between various win95 clients 
348 and a DX2-66 20MB server with a crappy NE2000 compatible and old IDE 
349 drive (Kernel 2.0.30). The transfer rate was reasonable for 10 baseT.</P
350 ><P
351 ><PRE
352 CLASS="PROGRAMLISTING"
353 >The figures are:          Put              Get 
354 P166 client 3Com card:    420-440kB/s      500-520kB/s
355 P100 client 3Com card:    390-410kB/s      490-510kB/s
356 DX4-75 client NE2000:     370-380kB/s      330-350kB/s</PRE
357 ></P
358 ><P
359 >I based these test on transfer two files a 4.5MB text file and a 15MB 
360 textfile. The results arn't bad considering the hardware Samba is 
361 running on. It's a crap machine!!!!</P
362 ><P
363 >The updates mentioned in 1 and 2 brought up the transfer rates from 
364 just over 100kB/s in some clients.</P
365 ><P
366 >A new client is a P333 connected via a 100MB/s card and hub. The 
367 transfer rates from this were good: 450-500kB/s on put and 600+kB/s 
368 on get.</P
369 ><P
370 >Looking at standard FTP throughput, Samba is a bit slower (100kB/s 
371 upwards). I suppose there is more going on in the samba protocol, but 
372 if it could get up to the rate of FTP the perfomance would be quite 
373 staggering.</P
374 ></DIV
375 ></DIV
376 ><DIV
377 CLASS="NAVFOOTER"
378 ><HR
379 ALIGN="LEFT"
380 WIDTH="100%"><TABLE
381 SUMMARY="Footer navigation table"
382 WIDTH="100%"
383 BORDER="0"
384 CELLPADDING="0"
385 CELLSPACING="0"
386 ><TR
387 ><TD
388 WIDTH="33%"
389 ALIGN="left"
390 VALIGN="top"
391 ><A
392 HREF="groupmapping.html"
393 ACCESSKEY="P"
394 >Prev</A
395 ></TD
396 ><TD
397 WIDTH="34%"
398 ALIGN="center"
399 VALIGN="top"
400 ><A
401 HREF="samba-howto-collection.html"
402 ACCESSKEY="H"
403 >Home</A
404 ></TD
405 ><TD
406 WIDTH="33%"
407 ALIGN="right"
408 VALIGN="top"
409 ><A
410 HREF="groupprofiles.html"
411 ACCESSKEY="N"
412 >Next</A
413 ></TD
414 ></TR
415 ><TR
416 ><TD
417 WIDTH="33%"
418 ALIGN="left"
419 VALIGN="top"
420 >Group mapping HOWTO</TD
421 ><TD
422 WIDTH="34%"
423 ALIGN="center"
424 VALIGN="top"
425 ><A
426 HREF="optional.html"
427 ACCESSKEY="U"
428 >Up</A
429 ></TD
430 ><TD
431 WIDTH="33%"
432 ALIGN="right"
433 VALIGN="top"
434 >Creating Group Profiles</TD
435 ></TR
436 ></TABLE
437 ></DIV
438 ></BODY
439 ></HTML
440 >