FQ(8)
๐ FQ(8) ๐
๐ NAME ๐
okay so FQ is the Fair Queue traffic policing thing. It's a scheduler for packets, bestie ๐ง
โจ SYNOPSIS โจ
tc qdisc ... fq [ limit PACKETS ] [ flow_limit PACKETS ] [ quantum BYTES
] [ initial_quantum BYTES ] [ maxrate RATE ] [ buckets NUMBER ] [
orphan_mask NUMBER ] [ pacing | nopacing ] [ ce_threshold TIME ]
๐ฆ DESCRIPTION ๐ฆ
ngl FQ (Fair Queue) is a classless packet scheduler, and it's mostly used for traffic your machine generates itself ๐
It's built to give each flow its own pacing, so nobody hogs the line. FQ does flow separation and can respect the pacing requirements the TCP stack sets. Every packet that belongs to a socket counts as a 'flow'. For packets that aren't local (the router workload era ๐), the packet hash is used as a fallback.
An app can ask for a maximum pacing rate with the SO_MAX_PACING_RATE setsockopt call. This scheduler adds delay between packets so each socket stays under its rate limit. Note that after linux-4.20, linux adopted EDT (Earliest Departure Time), and TCP directly sets the right Departure Time for each skb. It's giving efficiency ๐ฅ
Dequeueing happens in a round-robin fashion. There's a special FIFO queue just for high priority packets (TC_PRIO_CONTROL priority), and those always get dequeued first. Main character energy for the VIPs ๐
FQ is non-work-conserving. Read that one twice, it matters ๐ซถ
TCP pacing is so good for flows that have idle times, because the congestion window lets the TCP stack queue a possibly large number of packets. This removes the 'slow start after idle' choice, which was badly hitting large BDP flows and apps delivering chunks of data, like video streams ๐
๐ธ PARAMETERS ๐ธ
limit
Hard limit on the real queue size. When this limit is reached, new packets get dropped ๐ญ If the value is lowered, packets are dropped so the new limit is met. Default is 10000 packets.
flow_limit
Hard limit on the maximum number of packets queued per flow. Default value is 100.
quantum
The credit per dequeue RR round, aka the amount of bytes a flow is allowed to dequeue at once. A larger value means a longer time period before the next flow gets served. Default is 2 * interface MTU bytes.
initial_quantum
The initial sending rate credit, aka the amount of bytes a new flow is allowed to dequeue at first. This is specifically meant to allow using IW10 without added delay โจ Default is 10 * interface MTU, i.e. 15140 for 'standard' ethernet.
maxrate
Maximum sending rate of a flow. Default is unlimited. The application specific setting via SO_MAX_PACING_RATE is ignored only if it's larger than this value.
buckets
The size of the hash table used for flow lookups. Each bucket gets assigned a red-black tree for efficient collision sorting. Default: 1024.
orphan_mask
For packets not owned by a socket, fq can mask a part of skb->hash and reduce the number of buckets associated with the traffic. This is a DDOS prevention mechanism ๐ก๏ธ The default is 1023 (meaning no more than 1024 flows are allocated for these packets).
[no]pacing
Enable or disable flow pacing. Default is enabled.
ce_threshold
Sets a threshold above which all packets get marked with ECN Congestion Experienced. This is useful for DCTCP-style congestion control algorithms that need marking at very shallow queueing thresholds ๐ฆ
๐ง EXAMPLES ๐ง
Here's the vibe check, bestie ๐
#tc qdisc add dev eth0 root fq ce_threshold 4ms
#tc -s -d qdisc show dev eth0
qdisc fq 8001: dev eth0 root refcnt 2 limit 10000p flow_limit 100p
buckets 1024 orphan_mask 1023 quantum 3028b initial_quantum 15140b
low_rate_threshold 550Kbit refill_delay 40.0ms ce_threshold 4.0ms
Sent 72149092 bytes 48062 pkt (dropped 2176, overlimits 0 requeues 0)
backlog 1937920b 1280p requeues 0
flows 34 (inactive 17 throttled 0)
gc 0 highprio 0 throttled 0 ce_mark 47622 flows_plimit 2176
๐ SEE ALSO ๐
tc(8), socket(7) โ go check these out, they're literally the next chapter ๐
๐ AUTHORS ๐
FQ was written by Eric Dumazet. Iconic behavior, iconic author ๐
That's the tea, bestie โจ This page came from iproute2, dated 10 Sept 2015, and it's all about FQ(8) ๐ Stay pacing, stay fair ๐ซถ
๐ฆ where this page comes from
- alpine 3.22: iproute2-doc 6.15.0-r0 ยท GPL-2.0-or-later
- alpine 3.23: iproute2-doc 6.17.0-r0 ยท GPL-2.0-or-later
- alpine 3.24: iproute2-doc 7.0.0-r0 ยท GPL-2.0-or-later
- arch rolling: iproute2 7.2.0-1
- arch rolling: iproute2 7.3.0-1 ยท GPL-2.0-or-later
- centos-stream 10: iproute-tc 7.0.0-2.el10 ยท GPL-2.0-or-later
- centos-stream 9: iproute-tc 6.17.0-3.el9 ยท GPL-2.0-or-later
- debian bookworm: iproute2 6.1.0-3 ยท GPL-2.0-only
- debian trixie: iproute2 6.15.0-1 ยท GPL-2.0-only
- fedora 43: iproute-tc 6.14.0-2.fc43 ยท GPL-2.0-or-later
- fedora 44: iproute-tc 6.17.0-2.fc44 ยท GPL-2.0-or-later
- nixos 26.05: iproute2 7.0.0
- nixpkgs unstable: iproute2 7.2.0
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- ubuntu jammy: iproute2 5.15.0-1ubuntu2 ยท GPL-2.0-only
- ubuntu jammy: iproute2 5.15.0-1ubuntu2.2 ยท GPL-2.0-only
- ubuntu noble: iproute2 6.1.0-1ubuntu6 ยท GPL-2.0-only
- ubuntu noble: iproute2 6.1.0-1ubuntu6.4 ยท GPL-2.0-only
- ubuntu questing: iproute2 6.16.0-1ubuntu2
- ubuntu questing: iproute2 6.16.0-1ubuntu2.1 ยท GPL-2.0-only
- ubuntu questing: iproute2 6.16.0-1ubuntu2.2
- ubuntu resolute: iproute2 6.19.0-1ubuntu1 ยท GPL-2.0-only
- ubuntu resolute: iproute2 6.19.0-1ubuntu1.1 ยท GPL-2.0-only
- ubuntu stonking: iproute2 7.2.0-1ubuntu1 ยท GPL-2.0-only
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms