CLASS="section" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" >

31.8. Optimizing Samba

It is a big mistake to set the wide links Samba parameter to no in the Samba configuration file /etc/smb.conf. This option, if set to no, tells Samba not to follow symbolic links outside of an area designated as being exported as a share point. In order to determine if a link points outside the shared area, Samba has to follow the link and then do a directory path lookup to determine where on the file system the link ended up. This ends up adding a total of six extra system calls per filename lookup, and Samba looks up filenames a lot. A test done was published that showed that setting this parameter will cause a 25 to 30 -percent slowdown in Samba performance.

31.8.1. Tuning the buffer cache

The modification of the filesystem cache-tuning parameters can significantly improve Linux's file-serving performance up to a factor of two. Linux will attempt to use memory not being used for any other purpose for filesystem caching. A special daemon, called bdflush, will periodically flush dirty buffers, buffers that contain modified filesystem data or metadata to the disk.

The secret to good performance is to keep as much of the data in memory for as long as is possible. Writing to the disk is the slowest part of any filesystem. If you know that the filesystem will be heavily used, then you can tune this process for Linux Samba. As with many kernel tuneable options, this can be done on the fly by writing to special files in the /proc filesystem. The trick is, you have to tell Linux you want it to do that. You do so by executing the following command for a Linux 2.2 kernel.

The default setup for the bdflush parameters under Red Hat Linux is:

          "40 500 64 256 500 3000 500 1884 2"
        
To change the values of bdflush, type the following command on your terminal:

Under Version 6.1

          [root@deep ] /# echo "80 500 64 64 15 6000 6000 1884 2" >/proc/sys/vm/bdflush
        
You may add the above commands to the /etc/rc.d/rc.local script file and you'll not have to type it again the next time you reboot your system.

Under Version 6.2 Edit the /etc/sysctl.conf file and add the following line:

          # Improve file system performance
          vm.bdflush = 80 500 64 64 15 6000 6000 1884 2
        

You must restart your network for the change to take effect. The command to restart the network is the following:

          [root@deep ] /# /etc/rc.d/init.d/network restart
        

          Setting network parameters		[  OK  ]
          Bringing up interface lo		[  OK  ]
          Bringing up interface eth0	        [  OK  ]
          Bringing up interface eth1	        [  OK  ]
        
This line tells bdflush not to worry about writing out dirty blocks to the disk until the filesystem buffer cache is 80 percent full (80). The other values tune such things as the number of buffers to write out in one disk operation (500), how long to allow dirty buffers to age in the kernel (60*HZ), etc. You can find full details in the 2.2 kernel documentation in the file linux/Documentation/sysctl/vm.txt, and also, you can check General System Optimization, for more information.