# poor Samba performance

## BillyIdle

Hi there,

I have some serious samba performance issues and have no idea why.

My network is a gigabit network. It isn't the best hardware, so I don't expect any performance wonders here, but I think 2 MB/s is definitely too slow. I've tested other transfer methods, like ftp and scp and I always get more throughput. With FTP I have around 35-40 MB/s. 

The samba-config is nothing special. I've post it at the bottom of this post.

The linux machine is an AMD Duron with 1.8 Ghz and 1,25 GB RAM. I've tried to transfer it with different client machines and with the linux tool "dbench" (set with 10 Clients).

Versions:

 - net-fs/samba-3.0.22-r3  USE="automount readline syslog -acl -async -cups -doc -examples -kerberos -ldap -ldapsam -libclamav -mysql -oav -pam -postgres -python -quotas -swat -winbind -xml

 - gentoo-sources-2.6.17-r4

I've tested it with two HDDs, one is an normal 20GB PATA HDD and one is an Samsung 250 GB SATA HDD. I've tested them with hdparm and bonnie++ and their values seems to be okay. There is no iptables or something like that which hangs between this traffic.

So, finally, my samba config (I have stripped down some comments):

```

[global]

   workgroup = Workgroup

   netbios name = fileserver

   server string = fileserver Samba %v

   printcap name = cups

   load printers = no

   printing = cups

   printer admin = @adm

   log file = /var/log/samba/log.%m

   max log size = 50

   hosts allow = 192.168.12. 127.

   map to guest = bad user

   security = user

   encrypt passwords = yes

   smb passwd file = /etc/samba/private/smbpasswd

   socket options = TCP_NODELAY SO_KEEPALIVE SO_RCVBUF=2048 SO_SNDBUF=2048 IPTOS_LOWDELAY

   read size = 1024

   getwd cache = yes

   dns proxy = no 

#============================ Share Definitions ==============================

[homes]

   comment = Own Files

   browseable = no

   writable = yes

[printers]

   comment = All Printers

   path = /var/spool/samba

   browseable = no

   guest ok = yes

   writable = no

   printable = yes

   create mode = 0700

   print command = lpr-cups -P %p -o raw %s -r   # using client side printer drivers.

[print$]

   path = /var/lib/samba/printers

   browseable = yes

   read only = yes

   write list = @adm root

   guest ok = yes

[netshare]

        map system = yes

        writeable = yes

        delete readonly = yes

        map hidden = yes

        write list = billy,@users

        path = /netshare

        force group = users

        comment = shared folder

        valid users = billy,@users

        create mode = 777

        allow hosts = 192.168.12. 127.

        directory mode = 777

```

Maybe someone has a tip or some kind of advice where to look (searchin the forums wasn't very succesful). Thanks in advance, maybe you can help  :Smile: 

----------

## palatin

For a start, you may want to look into changing the 'read size' option, as it may seem to harm performance when set too low.

I stumbled upon Samba tuning, which might help you further.

----------

## Janne Pikkarainen

Try to make these bigger: SO_RCVBUF=2048 SO_SNDBUF=2048

Two kb buffer seems a bit small.

----------

## BillyIdle

Hi there, 

thanks for the answers.

I've experimented a little bit with that what you said. With little sucess: I'm now at ~3 MB/s, which is better than before but not even as high as expected.

My "speed optimized settings" are now like this:

```

   socket options = TCP_NODELAY SO_KEEPALIVE SO_RCVBUF=8192 SO_SNDBUF=8192 IPTOS_LOWDELAY

   read size = 65535

   getwd cache = yes

   read raw = yes

   write raw = yes

   dead time = 15

   lpq cache = 30

   oplocks = yes

   max xmit = 65535

```

The transfer rate is a little bit strange: The transfer starts "fast" with 25-35 MB/s but gets very fast to only ~3 MB/s and stays there.

I've followed some advises from the link palatin gave me (as you can see in the config), but it hasn't the results I expected.[/code]

----------

## Janne Pikkarainen

Ok. That kind of rapid speed stall is usually symptom of some kind of network problem. TCP/IP tends to drop speed if it encounters some errors or other problems during transmission. 

What kind of transfer rates do you get with other protocols? You already mentioned "faster", but anywhere near 35-40 MB/s?

----------

## BillyIdle

Hi again,

thanks for your attention at all  :Smile: 

First of all, I have to correct an error: The real transferate is NOT 2 MB/s, it's even worse ... 0.17 MB/s it's the value. I was a little bit confused with smbtorture output (had 10 Clients as option).

I have tested two other protocols, one time FTP, one time SCP. They are both faster than smb. FTP comes to 35-40 MB/s as I mentioned before. The SCP transfer rate I don't remember exactly, it was something around 2 MB/s, which is very low as well. 

What I've done now is the following two things:

- tried another distribution: result is the same like gentoo

- tried another NIC: result is also the same.

I have simply no other idea for now. Maybe I will test this whole thing on another machine tomorrow. I'm glad about every tip that I'm receiving, so thanks in advance and thanks for the already existing posts on this topic  :Smile: 

----------

## darkphader

You might try a later release, there's an ebuild in the bug database for 3.0.23b (I created this edited ebuild and use it in production on 3 different servers).

Also I believe "syslog" is still experimental, plus you're not linking against cups (-cups in your use), yet you specify it in your smb.conf ( printcap name = cups, printing = cups). You may want to straighten that out and for a test try with -automount as well.

Also verify you have solid name resolution. Try populating your lmhosts files.

Chris

----------

## Janne Pikkarainen

Have you tried to snoop with Ethereal... err.... Wireshark what happens during SMB transfers?

----------

## BillyIdle

Hi darkphader,

unfortunately the gentoo bug database search is not working ... I've tried it several times, but I get no search result, it hangs by "Please stand by ..." since 30 minutes. Can you provide me another link to your ebuild so I can use it? 

The cups thing is something I want to get rid of anyway, because I don't use any printers on this machine. I will change the use-flags for the two other things as well. Maybe that helps a little bit.

Is the name resolution in my case important? All tests were done with the exact IP adress, no hostnames or something like that. I will test it anyway. Thanks for all your advises.

----------

## BillyIdle

@Janne:

I will test that to, stands on my ToDo list  :Smile: 

----------

## BillyIdle

So, news from the samba front  :Wink: 

I've updated to samba version 3.0.23b with the ebuild that darkphader kindly provided. And I removed all the printing / cups things, I don't use it anyway. -automount and -syslog in the USE-Flags is also set.

What I have now is a speed between 0.25 MB/s and 0.40 MB/s according to smbtorture. The command I use is: 

```
smbtorture //192.168.12.254/netshare -U billy%test NBENCH
```

 within the /usr/share/dbench directory.

The smbtorture tool was compiled by hand this time, because the ebuilds by darkphader doesn't provide me with that tool, no idea why (maybe another error by me  :Wink: ).

The Wireshark-test stands out, I'll do that as soon as I'm at home. What transfer rates are you reaching with smbtorture? Would be interesting, because this server we use here in my company also uses samba and has the same perfomance issue than mine at home.

So, any new ideas?  :Smile: 

Okay, that was the news. I would like to thank all of you for your help so far, really nice   :Exclamation: 

----------

## Janne Pikkarainen

Now that I think of it... I haven't even used smbtorture before   :Laughing: 

Have you tried to transfer single big files with smbclient?

----------

## darkphader

 *BillyIdle wrote:*   

> The smbtorture tool was compiled by hand this time, because the ebuilds by darkphader doesn't provide me with that tool, no idea why (maybe another error by me ;-)).

 

Yes, that's true. If you edit the ebuild to use the previous patchset (samba-3-gentoo-0.3.14.tar.bz2) you will get smbtorture, in fact I will probably change my mind about the patchset change as it appears rpctorture is not included in TORTURE_PROGS, although I'm not quite sure how useful the rest of the EVERYTHING_PROGS is.

So what parameters and tests are you running with smbtorture?

Also note the warning when running it - they recommend that use the new and improved smbtorture from the Samba4 suite.

Chris

----------

## BillyIdle

Hi there,

thanks for the replies  :Smile: 

darkphader: Do you mean the command for smbtorture? Or what? The command was/is: "smbtorture //192.168.12.254/netshare -U billy%test NBENCH" like posted before.

I've tried it with smbclient and get rates from 19 to 20 MB/s on an 100 MBit Card. Is smbtorture completely different in its benchmark ways, or what?

Even if 20 MB/s is way better than before, it's not what I'm expecting (because I get much higher rates with other protocols). 

What I will do now, is to get an better GBit NIC, because my old one sucks as I found out and I'll check smbtorture with the new samba 4 suite.

So, from one point of view, it's now better, but 20 MB/s is even not that what I'm expecting ... is there more I can do about the samba perfomance?

----------

## tgh

While I suspect my experience with Samba won't help you... I run samba on a newer Asus A8V motherboard (I think Marvell 88E8001 gigabit NIC).  Some Windows machines would seem to talk to the box at full speed or talk to other boxes at full speed (I tried various configurations).  Connecting to the box directly with other TCP/IP tools showed good performance, just not for Samba.

I finally upgraded my kernel last week to the latest for gentoo-sources and I'm now seeing much higher data rates to/from the box for Samba.  So I suspect that the Marvell driver got tuned up in the past 6 months and now works better.

(I generally hear good things about Intel NICs.)

----------

