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