1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN">
5 >Samba performance issues
</TITLE
8 CONTENT=
"Modular DocBook HTML Stylesheet Version 1.76b+
11 TITLE=
"SAMBA Project Documentation"
12 HREF=
"samba-howto-collection.html"><LINK
14 TITLE=
"Optional configuration"
15 HREF=
"optional.html"><LINK
17 TITLE=
"Group mapping HOWTO"
18 HREF=
"groupmapping.html"><LINK
21 HREF=
"appendixes.html"></HEAD
32 SUMMARY=
"Header navigation table"
41 >SAMBA Project Documentation
</TH
49 HREF=
"groupmapping.html"
63 HREF=
"appendixes.html"
76 NAME=
"SPEED">Chapter
22. Samba performance issues
</H1
82 NAME=
"AEN3055">22.1. Comparisons
</H1
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
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
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
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
111 NAME=
"AEN3061">22.2. Socket options
</H1
113 >There are a number of socket options that can greatly affect the
114 performance of a TCP based server like Samba.
</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
119 >The
"socket options" section of the smb.conf manual page describes how
120 to set these and gives recommendations.
</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
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
137 NAME=
"AEN3068">22.3. Read size
</H1
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
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
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
161 NAME=
"AEN3073">22.4. Max xmit
</H1
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
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
175 >In most cases the default is the best option.
</P
182 NAME=
"AEN3078">22.5. Log level
</H1
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
194 NAME=
"AEN3081">22.6. Read raw
</H1
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
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
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
214 NAME=
"AEN3086">22.7. Write raw
</H1
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
221 >Some machines may find
"write raw" slower than normal write, in which
222 case you may wish to change this option.
</P
229 NAME=
"AEN3090">22.8. Slow Clients
</H1
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
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
244 NAME=
"AEN3094">22.9. Slow Logins
</H1
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
255 NAME=
"AEN3097">22.10. Client tuning
</H1
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
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
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
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
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
278 >Paul Cochrane has done some testing on client side tuning and come
279 to the following conclusions:
</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
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
302 >MTUAutoDiscover Disable
</P
306 >MTUBlackHoleDetect Disable
</P
310 >Time To Live Enabled
</P
314 >Time To Live - HOPS
32</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
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
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
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
342 >The updates mentioned in
1 and
2 brought up the transfer rates from
343 just over
100kB/s in some clients.
</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
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
360 SUMMARY=
"Footer navigation table"
371 HREF=
"groupmapping.html"
380 HREF=
"samba-howto-collection.html"
389 HREF=
"appendixes.html"
399 >Group mapping HOWTO
</TD