Performance tuning the Samba server

In this recipe, we will look at Samba configuration parameters in order to get optimum performance out of your Samba installation.

Getting ready

You will need root access or an account with sudo privileges.

It is assumed that you have installed the Samba server and it is properly working.

How to do it…

  1. Open the Samba configuration file located at /etc/samba/smb.conf:
    $ sudo vi /etc/samba/smb.conf
    
  2. Add or edit the following options under the global section of the configuration file:
    [global]
    log level = 1
    socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=131072 SO_SNDBUF=131072 SO_KEEPALIVE
    read raw = Yes
    write raw = Yes
    strict locking = No
    oplocks = yes
    max xmit = 65535
    dead time = 15
    getwd cache = yes
    aio read size = 16384
    aio write size = 16384
    use sendfile = true
  3. Save the configuration file and restart the Samba service:
    $ sudo service smbd restart
    

How it works…

The Samba server provides various configuration parameters. It uses TCP sockets to connect with clients and for data transfer. You should compare Samba's performance with similar TCP services such as FTP.

The preceding example lists some commonly used configuration options for Samba. Some of these options may work for you and some of them may not. The latest Samba version ships with default values for these options that work fairly well for common network conditions. As always, test these options one at a time or in a group, and benchmark each modification to get optimum performance.

The explanation for the preceding is as follows:

  • log level: The default log level is set to 0. Samba produces a lot of debugging information and writing all this to disk is a slow operation. Increasing the log level results in increased logs and poor performance. Unless you are debugging the server, it is good to have the log level set to the lowest value.
  • socket options: These are the TCP/IP stack level options.
  • read raw and write raw: These options enable Samba to use large read and writes to a network up to 64 KB in a single request. Some older clients may have issues with raw reads and writes. Check your setup before using these options.
  • dead time and so_keepalive: These options set periodic checks for dead connections and close such connections and free unused memory.
  • oplocks: This allows clients to cache files locally and results in overall performance improvement. The default setting disables oplocks.
  • aio read size and aio write size: This Asynchronous IO (AIO) allows Samba to read and write asynchronously when a file's size is bigger than the specified size values.

You can find various other options and respective explanations in the Samba manual pages. Use the following command to open the manual pages on your server:

$ man smbd
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset