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