Various nuggets of useful technical information.

Wednesday, June 25, 2008

Samba Performance Tuning

If you are using Samba to be the file server for windows machines, you may need to tweak certain options within Samba to get it work more ideally for your setup.

This post assumes you have already set Samba up to be a file server or a PDC/file server and have already defined some shared folders.

Share level directives:
For shared folder where files may be accessed concurrently by multiple users, I find that the following permissions within the share definition in Samba are quite good:

security mask = 0775
directory security mask = 0775
force create mode = 0777
force directory mode = 0777

This ensures that new folders and files created are fully controllable by everyone.

For folders where files may be accessed by a few users and never concurrently, I find that the following options within the share definition in Samba are quite good. There are a host of windows programs that 'import' files to be used in data generation and analysis. This setting is especially crucial for that kind of setup:

level2 oplocks = True
oplocks = True

By specifying that the files can be locked by an application, import speeds are exponentially increased, however one may find that concurrent file access is slowed down.

Therein lies the difference:

If your files are meant to be shared concurrently by multiple users - the first section applies to you.
If your files are meant to be used by a few users and rarely, if ever, concurrently, then use the second section.

More information on oplocks and samba file locking can be found here:
http://www.samba.org/samba/docs/man/Samba3-HOWTO/locking.html

More information on files and directories in shares can be found here:
http://www.samba.org/samba/docs/man/Samba3-HOWTO/AccessControls.html


Global level directives:
I always add these options in the global section:

socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=8192 SO_SNDBUF=8192

Fiddle with the last two options - SO_RCVBUF and SO_SNDBUF till you get performance you are happy with. Bear in mind, blindly doubling or tripling those numbers does not improve performance.

More information can be found here:
http://www.samba.org/samba/docs/man/Samba3-HOWTO/speed.html


No comments: