Make Linux faster, lighter and more powerful

You've tweaked your router, optimised your server and replaced all your broadband filters in your house – and you still have a slow connection. Before you make an angry phone call to your ISP, there's a possibility that the client machine may be the bottleneck. With just a few of these tweaks you can improve your connections, or at the very least eliminate your client machine as the single point of failure.

Use hostname 'localhost'

This doesn't cause a drastic improvement on its own, but in conjunction with the other network tricks here can improve your local machine's network performance. Simply open /etc/hosts in a text editor with root permissions and change the top two lines to:

127.0.0.1 localhost
yourhost 127.0.1.1 yourhost

where yourhost is the name of the machine (ie bobdesktop). Ensure you keep a backup of your /etc/hosts file, as not all distros are compatible with this!

Optimise TCP settings

Distros come preconfigured for "average" internet users, but in a world of 3G, dial-up and ADSL there is no such thing as an average user. Now edit /etc/sysctl.conf as root and append the following:

net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_sack = 1

(This may take some trial and error, so keep a backup of the files you edit.)

The top line removes timestamps and so relieves all incoming and outgoing packets of a 12k overhead. The bottom line enables selective acknowledgements, which means fewer checks are initiated on each packet so they are delivered quicker.

We don't recommend the latter tweak for dial-up connections as this increases the number of packets which need to be resent.

Metrics and backlogs

You can further optimise your TCP settings by appending the following lines to the same text file:

net.ipv4.tcp_no_metrics_save = 1
net.core.netdev_max_backlog = 2500

The top line speeds up connections by ensuring that TCP metrics are not saved for each individual packet. The second line dictates the backlog of packets allowed.

To give an idea of the scale of the figure you should use for your backlog, around 2,000 is recommended for wireless or older Ethernet connections, and around 5,000 for a 1GB Ethernet cable to broadband connection.

On the other hand, this figure can rise up to 30,000 for an expensive 10GB Ethernet cable. The slower the connection, the lower your backlog should be, as the aim of this tweak is to clear outstanding packets as soon as possible in order to boost connection speeds.

TCP window scaling

The TCP window settings define the minimum and maximum size of packets we can send and recieve. Dial-up users will see a speed boost with smaller packet sizes while broadband users will see a speed boost with larger packet sizes.

Edit /etc/sysctl.conf as root, and , append this:

net.ipv4.tcp_window_scaling = 1

net.ipv4.tcp_wmem = 10240 87380 16777216
net.ipv4.tcp_rmem = 10240 87380 16777216
net.ipv4.tcp_mem = 16777216 16777216 16777216
net.core.rmem_max = 16777216
net.core wmem_max = 16777216

Those figures are optimised for a 2Mbps connection on Sky broadband over a wireless connection, but the packet size recommendation for any given connection is usually maximum bandwidth divided by latency. You can find these figures by heading to www.speedtest.net, and you can also analyse how your changes are affecting your connection via www.speedguide.net:8080.

TCP window

SPEED GUIDE: This online guide can give you an indication of which values and tweaks will improve your network connection

TOPICS