Next revision | Previous revision |
samba:optimize_samba [2016/07/10 23:53] – created peter | samba:optimize_samba [2019/12/04 19:00] (current) – removed peter |
---|
====== Samba - Optimize Samba ====== | |
| |
Samba, like any other program can use a little speed boost. You want to get the most out of your machines and optimizing your applications can extend their life by doing the job longer. | |
| |
Samba needs to be tuned to your network because every enviorment offers its own unique set of challenges. Here is a collection of hints and tricks tp Optimize Samba. | |
| |
| |
===== Network Socket Options ===== | |
| |
The socket options configuration options are really host system tuning options, but they're set on a per-connection basis, and can be reset by Samba on the sockets it employs by adding **socket options = option** to the [global] section of your smb.conf file. This single line can gain you a 200% throughput increase over default settings. | |
| |
<code bash> | |
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536 | |
</code> | |
| |
| |
**TCP_NODELAY** tells the server to send as many packets as necessary to keep delay low. This will account for a 30 percent speedup by itself. In Samba 2.0 socket options = TCP_NODELAY became the default value. | |
| |
**IPTOS_LOWDELAY** is another option trading off throughput for lower delay, but which affects routers and other systems, not the server. All the IPTOS options are new; they're not supported by all operating systems and routers though. If they are supported, set IPTOS_LOWDELAY whenever you set TCP_NODELAY. This option gives us a minor speed up around 20%. | |
| |
**SO_SNDBUF** and **SO_RCVBUF** The send and receive buffers can often be the reset to a value higher than that of the operating system. This yields a marginal increase of speed until it reaches a point of diminishing returns. For a modern OpenBSD box serving shares to Windows xp/Vista or Linux machines a SO_SNDBUF and SO_RCVBUF of 65536 increased throughput by as much as 20% by itself. | |
| |
**SO_KEEPALIVE** initiates a periodic check every four(4) hours to see if the client is still there. This option eventually arranges to close dead connections, returning unused memory and process-table entries to the operating system. Using this option is conjunction with "deadtime = 15" to close idle connection as fast as your working environment will allow. | |
| |
| |
===== Raw read and write ===== | |
| |
These are important performance configuration options; they enable Samba to use large reads and writes to the network, of up to 64KB in a single SMB request. They also require the largest SMB packet structures, SMBreadraw and SMBwriteraw, from which the options take their names. In the past, some clients failed if you tried to use read raw. No clients suffer from this problem now. Read and write raw default to yes, and should be left on unless you find you have one of the ancient buggy clients. | |
| |
| |
===== Opportunistic locking ===== | |
| |
Opportunistic locks, or oplocks, allow clients to cache files locally, improving performance on the order of 30 percent. This option is now enabled by default. For read-only files, the fake oplocks provides the same functionality without actually doing any caching. If you have files that cannot be cached, oplocks can be turned off. Database files should never be cached, nor should any files that are updated both on the server and the client and whose changes must be immediately visible. For these files, the veto oplock files option allows you to specify a list of individual files or a pattern containing wild cards to avoid caching. oplocks can be turned off on a share-by-share basis if you have large groups of files you don't want cached on clients. | |
| |
| |
===== Log level ===== | |
| |
Samba produces a lot of debugging messages at level 3 and above, and writing them to disk or syslog is a slow operation. Much of the disk I/O would be wasted on debugging messages. Reduce the logging level to 2 or under. | |
| |
| |