Users may sometimes encounter performance problems in different situations. In many cases, this results from misconfiguration based on wrong or outdated information.
This page gives an overview about possible tuning options. But in every case, the administrator has to weigh, if the changes are necessary!
If you're having performance issues using Samba, you can't solve, please subscribe to the Samba Mailing List. Post a description of your problem together with environment information and your smb.conf. The community and experienced users typically having good ideas to identify the reasons.
Handling Large Directories
Samba implements a solution for sites that have experienced performance degradation, due to the problem of using Samba with applications, that need large numbers of files (100,000 or more) per directory.
To set up an application that needs large numbers of files per directory in a way that does not damage performance unduly, follow these steps:
First, you need to canonicalize all the files in the directory to have one case, upper or lower (lower is recommended). Then set up a new custom share for the application as follows:
[bigshare] path = /srv/samba/manyfilesdir read only = no case sensitive = true default case = lower preserve case = no short preserve case = no
Of course, use your own path and settings, but set the case options to match the case of all the files in your directory. The path should point at the large directory needed for the application. Any new files created in there and in any paths under it will be forced by smbd into lowercase. But smbd will no longer have to scan the directory for names: It knows that if a file does not exist in lowercase, then it doesn't exist at all.
The secret to this is really in the „case sensitive = true“ line. This tells smbd never to scan for case-insensitive versions of names. So if an application asks for a file called „foo“, and it cannot be found by a simple stat call, then smbd will return „file not found“ immediately without scanning the containing directory for a version of a different case. The other „case“ lines make this work by forcing a consistent case on all files created by smbd.
Remember: All files and directories under the path directory must be in lowercase with this share configuration, because smbd will not be able to find any uppercase file-/directorynames with these settings. Also note that this is done on a per-share basis, allowing this parameter to be set only for a share servicing an application with this problematic behavior (using large numbers of entries in a directory) the rest of your smbd shares don't need to be affected.
This makes smbd much faster when dealing with large directories.
Settings that should be avoided!
Below you find some examples of configuration options that are spread over the internet, which, in most cases, do the opposite of the expected! They are useless or even more worse: They may decrease performance!
The Samba Team doesn't recommend to use this options unless you know what you're doing!
Modern server operating systems are tuned for high network performance in the majority of situations. When you set socket options, you are overriding those settings. Linux in particular has an auto-tuning mechanism for buffer sizes that will be disabled if you specify a socket buffer size. This can potentially cripple your TCP/IP stack!
For the majority of installations, this parameter should never be set!