Table of Contents

Ubuntu - Samba - Optimize Samba

Samba, like any other program can use a little speed boost.

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.

socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536

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.


Options to watch closely

The following Samba options will affect performance if they are not set correctly.