Course contentsShow
← Linux
Lesson 1522 of 1,81913. Containerization Primitives and NamespacesFree lesson

QoS Classifiers and Queuing Disciplines

Prioritize critical application traffic using advanced queuing algorithms like fq_codel.

In this lesson, you will learn how to prioritize critical container application traffic by effectively combining traffic classifiers with advanced queuing disciplines (qdiscs).

When multiple microservices share the same network interface, high-throughput background tasks can induce "bufferbloat"—where packets sit in large buffers waiting to be processed, causing latency spikes for sensitive, real-time traffic. To prevent this, we move beyond simple FIFO (First-In, First-Out) queuing to intelligent scheduling.

Classifiers and Qdiscs

Traffic Control (tc) manages packets through two main components:

  1. Classifiers (Filters): These inspect packet headers (like IP addresses, ports, or DSCP markings) to categorize traffic.
  2. Queuing Disciplines (qdiscs): These determine how packets are held, ordered, and dropped.

For high-performance container environments, fq_codel (Fair Queuing Controlled Delay) is the gold standard. It addresses bufferbloat by automatically managing multiple sub-queues based on flow hashing, ensuring that high-volume streams do not starve latency-sensitive flows.

Implementation Pattern

To apply this to a specific container's veth interface, you can attach fq_codel directly to the egress:

# Attach fq_codel to the veth interface of a container
tc qdisc add dev veth1234 root fq_codel target 5ms interval 100ms

In this setup, fq_codel monitors the "sojourn time" (how long packets wait in the queue). If the delay exceeds the target (5ms), the algorithm proactively drops packets from the longest queues to signal congestion, forcing TCP senders to throttle back before the queue grows uncontrollably.

If you need to differentiate traffic types—such as prioritizing a database query stream over a log synchronization stream—you would first attach a classful qdisc like HTB (Hierarchical Token Bucket), define specific classes with bandwidth limits, and then use a filter to map specific traffic to those classes.

By combining granular classifiers with the self-correcting nature of fq_codel, you ensure that your critical microservices maintain low-latency paths even when the container host is under heavy network saturation.

Key Takeaway: Use classifiers to identify and mark critical traffic, then deploy fq_codel as your egress qdisc to minimize bufferbloat and guarantee low-latency delivery for high-priority microservices.