Slow down/upload ftp sftp http on Ubutu Server 18.04 LTS on LAN

0

I'm facing a embarrassing problem, I have a home Ubuntu server and when I want to download from other PC in the same LAN, doesn't matter if I download or upload from/to http (my http server is apache2 on the ubuntu server), ftp or sftp and doesn't matter if I use WinSCP or FileZilla nothing is different :

My download/upload speed is around 1.5 Mo/s.

But sometimes I see the speed reaching 100 Mo/s.

The question is:

How can I fix that slow network speed for my ubuntu server ?

What I can say is :

It's not because of CPU performances (either the server CPU and client PC's CPU) htop shows really low usage of CPU on the server as task manager do for my PC.

It's not because of the LAN performances.

I've searched on google, and found a lot of people that have the same problem, but I've found no solutions that are pertinent for my situation.

[UPDATE 1] Nothing changed for the download speed with sftp and ftp after re-installation of the server. Thanks for your attention !

[UPDATE 2] Ok I tried with wired connection and it's up to 50Mo/s, indeed I'm on Wi-Fi connection and it's far worse 8Mo/s. What I don't understand is why when I download something from internet even if is with Wi-Fi connection it goes up to 24Mo/s...

[SOLUTION] Buy a PLC (Power-Line Carrier)

Xalares

Posted 2019-10-25T08:34:37.163

Reputation: 1

Well, I'm going to reinstall my ubuntu server from scratch, and see if something change... It's a bit radical but that's the only way I see to find what's the matter. – Xalares – 2019-10-25T10:28:50.310

"so nothing changed with sftp" - What about FTP? + Do not post important information in comment. Edit it into your question + "It's not because of CPU performances" - How did you check? – Martin Prikryl – 2019-10-25T11:35:51.043

Answers

0

First, i don't see any question in your post... But i'll assume that your question is "Why my transfert rate isn't always 1 GiB/s ?".

 Theorical VS real network speed.

When a link is announced to support 100MiB/s or 10GiB/s, it's a //raw// transfert rate.

Protocols are using bandwidth

If you use TCP (which is the case with HTTP/SFTP/SCP/FTP...), the real bandwidth will be: 1500 (commonly used MTU) - sizeof TCP header - sizeof Ethernet header - sizeoef protocols metadata:

  • Ethernet header: ~30 bytes.
  • TCP header: ~20 bytes.

So, for 1500 bytes, you already loose 50 bytes, which is 3%.

And this is only for RAW transfert over TCP. Using HTTP/SFTP/FTP imply using even more metadata (the one related to protocol: headers on HTTP, command channel on FTP, ) that are using bandwidth.

This was for the "theorical VS practical" bandwidth.

 Network card: "Hey, i need data", Hard drive disk; "Wait a minute bro".

Now, there's another point that may drastically slow down your transfert: the fact you are transferring files.

As long as you transfer files, then you're depending of your filesystem + mass storage performances. For example, Transferring 15GiB of small files will be longer than transferring a 15GiB file because your OS have to:

  • List files
  • Open file
  • Read file content
  • Push it throught socket.
  • Close file.
  • Open next file ...

Your files are stored using filesystem on hard drive disk, SSD, USB flash, etc.. so you have to take into account:

  • The overhead introduced by your filesystem.
  • The overhead introduced by your real, hardware device.

Benchmarking network

If you want to make sure that your network is really working at full speed, i would suggest doing the following benchmark, using 2 machines on the same lan:

 On machine #1

  • time nc -l -p 10000

On machine #2

  • dd if=/dev/zero bs=1M count=1024 | nc <machine #1> 10000

It will:

  1. On machine #1, listen for incoming packets on port 10000 and return you the time passed to receive data.
  2. On machine #2, read 1GiB zeros from /dev/zero (almost instant) and push it to machine #2 throught network.

If, using this benchmark, you reach your link maximal bandwidth minus ~ 3%, then your link is working full speed. Else, there's a problem on the link you should investigate.

 Getting more more more moarrrr bytes/seconds

To increase transfert speed, you may:

  • If you have the total control on your network, you may increase the MTU so that each packet have more space dedicated to payload.
  • Study the better filesystem.
  • Think about using ramdisk instead of real hard drive.
  • Use an application protocol that uses few metadata ( nc > *. HTTP is not that bad in most case, avoid FTP because of the overhead induced by opening/closing new TCP port for file transfert, avoid SFTP because of the overhead induced by crypto, etc... )

Edited after exchanges with OP in comment

Wifi VS RJ45

Wifi isn't good in big transfert. I can't explain, but i often noticed that performance are poor, even poorer than using a hop host internet to achieve the transfert. It probably depends on Wifi used (a, b, c, n), on wifi setup (access point, channel used) and in neighborhood (everybody on the same channel?). To get the best, use RJ45 !

binarym

Posted 2019-10-25T08:34:37.163

Reputation: 320

Tanks for your answer, indeed there is no question in my post and I'll correct that. I know as you are saying that there are raw and effective network speed. Because of that I'm not expecting 1Gbps of data download speed. I can assure you that I'm able to download from internet with faster speed than I'm able to download from my local ubuntu server no matter what protocol and size/number of file. I tried to download only one big file of 10Go from my server so I don't think it's a matter of hard drive reading speed. – Xalares – 2019-10-25T15:30:54.610

What kind of LAN are you using ? Wifi or RJ45 ? The only time i saw this happening was while using wifi: radio collisions made the transfert rate desastrous (i guess because of TCP and the concept of 1 acknowledge per packet) but using an intermediate hop in Internet enhanced the transfert rate.... (See this recent question regarding this topic ... share medium ... etc...)

– binarym – 2019-10-25T15:34:17.327

I'm using Wi-Fi connection, but what I don't understand is that if there are radio collisions why they doesn't affect the regular connection which is really great in fact ! – Xalares – 2019-10-25T18:10:15.460

Can't explain it too ... maybe the latency involved by using an internet host is enought to avoid collisions. Did you tried using RJ45 ? – binarym – 2019-10-25T18:29:42.533

I tried wired connection, and indeed it's far more better ! It's up to 50Mo/s with wired connection ! – Xalares – 2019-10-25T18:56:22.970

So the bottleneck is probably on the "physical" layer. If you want to totally understand that issue, i suggest you have a look to this post which points to other stackexchange about radio frequencies. I edited my answer.

– binarym – 2019-10-25T18:59:43.200