What are the techniques to test the connection speed of a server (in my case, virtual Ubuntu server @ Slicehost)? Bonus points for one liner bash command.

  • What exactly are we testing? Are we testing website requests per second or what. Are we testing a single connection or multiple connections simultanious? Just saw it was asked 7 years ago, ok nvm. – Cristian Matthias Ambæk May 11 '18 at 18:20

One of the better command line tools for checking bandwidth available is iperf. However you need another box on an known fast connection to run the test against. I'm not aware of any public iperf servers.

| improve this answer | |

Run netserver on one computer and netperf -h other.server.com -l 30 on another; see the official Netperf site for more details, source, and a Windows binary (most *nix port/package systems have netperf in them). Note: the results will be limited by the slowest connection between the two and port 12865 must be open on the server side.

| improve this answer | |

Take a look at this question for a technique to use dd over netcat and make note of the discovery that disk I/O was the limiting factor over a local network with the particular hardware involved. Over the internet and with faster hardware, your mileage may vary. By using /dev/zero as the source and /dev/null as the destination, the disk I/O factor will be eliminated as noted in the comments.

target system:
nc -l -p 9000 | pv | dd of=/dev/null

source system:
dd if=/dev/zero | pv | nc 9000 -q 10

| improve this answer | |
  • +1 for the use of pv. You can also replace /dev/hda by /dev/null and /dev/random for network testing without beeing limited by disk i/o. – petrus Jan 9 '11 at 22:27
  • Uh, excuse me, dd of=/dev/hda? Won't that overwrite the contents of first disk? The thread you linked to is about cloning a machine over the network... OP beware :) – linkedlinked Jan 9 '11 at 22:29
  • /dev/zero would be a good source for this - /dev/hda will be limited by disk I/O - and you'd want to set the "of" to /dev/null - OTHERWISE YOU'LL GET DATA LOSS. – JamesHannah Jan 9 '11 at 22:38
  • Yes, I meant to change that. I'll do it now. – Paused until further notice. Jan 10 '11 at 0:32

This is my own one-linner to get the time of th emost basic HTTP 1/1 request on my servers. Change www.foo.com by the ServerName and the HTTP server IP (use the IP, as with the real name you would have the DNS search time added).

time printf 'GET / HTTP/1.1\nHost:www.foo.com\n\n' |nc -w 10 -q 10 80 1>/dev/null

I usually do it on a very simple default Virtualhost with a static HTML page, to get the base response time (no cgi or php things, not even session, mod_rewrite or auth managment.

For the real time tracking I use Nagios plugins, apache status results (very usefull on bash one linners as well wityh q=auto), and sometime autobench (based on httperf).

| improve this answer | |

I think the simplest is to use iftop.

On the server @ slicehost run

sudo iftop

Then start downloading a large file with wget in another SSH window.

From the iftop man page:

The main part of the display lists, for each pair of hosts, the rate at which data has been sent and received over the preceding 2, 10 and 40 second intervals. The direction of data flow is indicated by arrows, <= and =>. For instance,

   foo.example.com  =>  bar.example.com      1Kb  500b   100b
                    <=                       2Mb    2Mb    2Mb


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.