Linux Increasing The Transmit Queue Length (txqueuelen)

by on October 22, 2009 · 11 comments· LAST UPDATED October 22, 2009

in , ,

How do I set txqueuelen (the length of the transmit queue) length of the network card device under Linux? How do I set it for a high latency and/or a high speed network for bulk transfer from disturbing interactive traffic like ssh too much?

You can set the length of the transmit queue of the device using /sbin/ifconfig command as follows:

  1. Small value for slower devices with a high latency like modem links and ISDN.
  2. High value is recommend for server connected over the high-speed Internet connections that perform large data transfers.

Increasing The txqueuelen

Increase the txqueuelength parameter to a value between 1000 and 20000 per interface:

ifconfig ${interface} txqueuelen ${size}
ifconfig eth1 txqueuelen 10000
ifconfig eth0 txqueuelen 5000

Setting the txqueuelen permanently

Edit /etc/rc.locale, enter:
vi /etc/rc.local
Append the following setting per interface:

/sbin/ifconfig eth1 txqueuelen 10000
/sbin/ifconfig eth0 txqueuelen 10000
TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 11 comments… read them below or add one }

1 Yevgen October 22, 2009 at 9:56 am

You can use also this command:
ip link set eth1 txqueuelen 10000

Reply

2 iwbcman January 10, 2011 at 5:09 pm

Thx for posting this howto for setting txqueuelen.

It should be noted however that increasing the txqueuelen value is a sure fire way to oversaturate your network interface buffers which may cause excessive jitter and DNS resolve timeouts. The default Linux txqueuelen value of 1000 is already way to high, and reducing this value to some much smaller number will reduce the likelihood of your network interface buffers being oversaturated. Personally I have had good results setting the value to 200.

Basically TCP must be able to have packets dropped quickly in order for the server to know that there is network congestion occurring. The size of the value determines how much buffering takes place(where # of packets translates to number of seconds of data being buffered). When this value is too high the feedback mechanism, which forms the basis for the network congestion avoidance algorithms in TCP, fails, meaning instead of packets being dropped thereby signalling that there is congestion. When the server is unaware of congestion due to excessive buffering the inevitable retransmission of packets only occurs once the problem has gotten too severe- and thus gigantic latencies are introduced, latencies equivalent to the number of seconds buffered according to the value set in txqueuelen. So the smaller the txqueuelen value, the better are the chances that TCP’s congestion avoidance algorithms can do their job-hence resulting in higher transfer speeds, and the less likely that the buffers will be overfilled leading to gigantic timeouts when retransmission inevitably occurs. Google Jim Gettys and bufferbloat for a better explanation.

Reply

3 Maroon January 13, 2011 at 2:01 pm

Sir,

As for the proxy servers (squid), what is recommended? to increase the tx queue length? or the oposite?

Knowing that we are using server hardware…

Please advise

Reply

4 NANO November 28, 2012 at 2:02 am

blow fish the length of word is hashed all the way to the name state itself … outside the algorithm the words are recognizable but the word like PHISH and FISH would be towards human decision.

Reply

5 Dave Täht February 13, 2011 at 2:39 am

Smaller will make your TCP stack more responsive. TCP does plenty of buffering for you already.

Unmanaged FIFO buffers greater than, say, 32, are bad. You can use bigger buffers, but you should then use a qdisc of some sort to balance your flows. I can’t imagine a valid reason for any level of FIFO buffering at present.

Try also enabling ECN and SACK.

The previous poster – while otherwise very correct – also missed using ethtool to reduce your dma tx queues.

See also:

http://www.bufferbloat.net/projects/bloat/wiki/Linux_Tips

Reply

6 MK2 April 21, 2011 at 11:15 pm

I find a slightly cleaner way to make this permanent is to vi /etc/network/interfaces and add the following line below the interface you want to change:

up ifconfig $IFACE txqueuelen 10000

The up allows any following command to be executed when the interface is brought up. This way the line is in the same place as the rest of the interface configuration.

Reply

7 ddale July 21, 2011 at 2:41 pm

If I want to snmp poll TxQueueLen, what is the number that will be returned – number of packets in the queue? The number of bytes being used by the queue?

Reply

8 nima0102 September 17, 2011 at 12:11 pm

Hi
Thanks for your good instruction
May you give me more information about reasons of “PACKET DROP” ?
If NIC gets one corrupted packet, is number increased? or system does not count corrupted packet at all?

Thanks in advance

Reply

9 Maciej September 19, 2011 at 8:38 am

I second iwbcman’s comment. Read on the consequences of blindly setting txqueuelen to high values.

Reply

10 Agostino September 20, 2011 at 4:38 pm

Not sure, remember that the device is always handled by a CPU. It is useful to set the txqueuelen to small values for slower devices with a high latency (modem links, ISDN) to prevent fast bulk transfers from disturbing interactive traffic. Therefore careful tuning is required to ensure that the sizes of the queues are optimal for your network connection. The default of 100 is inadequate for long distance, high throughput pipes. Also you have to consider the receiver side, we have a similar queue for incoming packets. This queue will build up in size when an interface receives packets faster than the kernel can process them. If this queue is too small (default is 1000), we will begin to loose packets at the receiver, rather than on the network. I have doing more and more testing and personally i have more better performance and lowest cpu load on stress server quad core and giga ethernet at about 4650mi distance from me with this 2 setting:
ifconfig eth0 txqueuelen 2000
echo 2000 > /proc/sys/net/core/netdev_max_backlog
Bye.

Reply

11 vv April 2, 2012 at 10:40 pm

when i try
ifconfig ${interface} txqueuelen ${size}
ifconfig eth1 txqueuelen 10000
ifconfig eth0 txqueuelen 5000

i get this:
SIOCSIFTXQLEN: No such device
My question if i add lines

/sbin/ifconfig eth1 txqueuelen 10000
/sbin/ifconfig eth0 txqueuelen 10000
in rc.local its enoguht for increase it?

Reply

Leave a Comment

Tagged as: , , , , , , , , , , , , , , , , , , , ,

Previous Faq:

Next Faq: