The Linux kernel and the distributions that package it typically provide very conservative defaults to certain network settings that affect networking parameters. You can tune then to optimise your network performance.

These settings can be tuned via the /proc filesystem or using the sysctl program. The latter is often better, as it reads the contents of /etc/sysctl.conf, which allows you to keep settings across reboots.

The following is a snippet from /etc/sysctl.conf that may improve network performance:

net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_syncookies = 1
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216

The above isn't to replace what may already exist in /etc/sysctl.conf, but rather to supplement it. The first command enables TCP window scaling, which allows clients to download data at a higher rate by enabling extra bits in TCP packets that are used to increase the window size.

The second command enables TCP SYN cookies, which is often enabled by default and is extremely effective in preventing conditions such as SYN floods that can drain the server of resources used to process incoming connections.

The last four options increase the TCP send and receive buffers, which allow an application to move its data out faster so as to serve other requests. This also improves the client's ability to send data to the server when it gets busy.

By adding these commands to the /etc/sysctl.conf file, you ensure they take effect on every reboot. To enable them immediately without a reboot, use:

# sysctl -p /etc/sysctl.conf

To see all of the currently configured sysctl options, use:

# sysctl -a

This will list all of the configuration keys and their current values. The sysctl.conf file allows you to configure and save new defaults; what you see from this output are the defaults defined in the kernel that are currently effective. To see the value of one particular item, use:

# sysctl -q net.ipv4.tcp_window_scaling

Likewise, to set the value of one item without configuring it in sysctl.conf -- and understanding that it won't be retained across reboots, use:

# sysctl -w net.ipv4.tcp_window_scaling=1

This can be useful for testing the effectiveness of certain settings without committing them to being defaults.

Open Sourcery This was published in Open Sourcery, check every Monday for more stories

Related links

Leave a comment

You must read and type the 6 chars within 0..9 and A..F

* indicates mandatory fields.

Log in


Sign up | Forgot your password?

  • Staff Shadow chasing in browsers

    The punching and counterpunching continued in the ongoing web browser development bout. Each time one browser closes a feature gap, a new feature appears in one of the others -- how we ever put up with the years of browser stagnation, I'll never know. Read more »

    -- posted by Staff

  • Chris Duckett Safari gets Gears

    Since its release in May last year, Gears has supported only Internet Explorer and Firefox browsers. With the addition of Safari into the Gears fold, it closes the loop of major browsers to support Gears Read more »

    -- posted by Chris Duckett

  • Renai LeMay MyPerfect.com.au has potential

    Victorian Web start-up My Perfect has a strong story and rationale for why it will succeed. But it has to overcome some challenges and design flaws first. Read more »

    -- posted by Renai LeMay

What's on?