Back to articles
Technology Insight

Configure Traffic Shaping & QoS (Quality of Service)

May 6, 2026
Configuring Traffic Shaping & QoS on VPS

Configuring Traffic Shaping & QoS: Bandwidth Prioritization and Traffic Control on VPS

When a VPS runs multiple services simultaneously (web, API, database, backup, torrent, etc.), bandwidth contention can easily occur, leading to network congestion, high latency, and poor user experience. Traffic Shaping and Quality of Service (QoS) allow you to proactively prioritize traffic for critical services and limit bandwidth for less important tasks. This article provides a detailed guide on implementing QoS on a Linux VPS using the `tc` (traffic control) tool and wondershaper in 2026.

1. What is Traffic Shaping & QoS?

Traffic Shaping is a technique to control the speed and order of data transmission. QoS allows packet classification and applying different policies to each type (prioritization, limiting, or dropping).

  • Prioritization: HTTP/HTTPS, VoIP, and video calls are processed first.
  • Limiting: Backup, torrent, and large downloads have their bandwidth throttled.
  • Benefits: Ensures business-critical applications remain stable and prevents any single service from consuming all available bandwidth.

// Interface simulating QoS Policy
interface QoSPolicy {
  serviceName: string;
  protocol: "tcp" | "udp" | "any";
  portRange: string;
  priority: number;        // 1 = highest, 10 = lowest
  maxBandwidthMbps: number;
  burstLimitKbps: number;
}

const policies: QoSPolicy[] = [
  { serviceName: "Web HTTPS", protocol: "tcp", portRange: "443", priority: 1, maxBandwidthMbps: 0, burstLimitKbps: 2048 },
  { serviceName: "API Backend", protocol: "tcp", portRange: "3000-4000", priority: 2, maxBandwidthMbps: 500, burstLimitKbps: 1024 },
  { serviceName: "Backup & Torrent", protocol: "tcp", portRange: "any", priority: 8, maxBandwidthMbps: 100, burstLimitKbps: 512 }
];

console.log(`Applied ${policies.length} QoS policies`);
 

2. Main Tools: tc (iproute2) and wondershaper

`tc` is the most powerful Linux tool for traffic control. Wondershaper is a simple wrapper that makes configuration quick and easy.

3. VPS Requirements and Preparation

Factor Recommendation
Network Port 1Gbps or higher
Kernel QoS support (default on Ubuntu/Debian)
Tools iproute2, wondershaper, iptables

4. Installation and Basic Configuration


// Installation and basic QoS configuration script (simulated)
const setupQoSScript = `
sudo apt install -y iproute2 wondershaper
# Limit eth0 interface to 800Mbps down / 200Mbps up
sudo wondershaper eth0 800000 200000

# Clear old rules
sudo wondershaper clear eth0
`;

console.log("Traffic Shaping activated on interface eth0");
 

5. Prioritizing HTTP/HTTPS and Throttling Downloads

Prioritize web traffic and limit heavy download connections.


// Advanced QoS Configuration using tc (illustrative logic)
interface TrafficClass {
  classId: string;
  rateMbps: number;
  priority: number;
  description: string;
}

function applyQoSRules(interfaceName: string = "eth0") {
  const classes: TrafficClass[] = [
    { classId: "1:10", rateMbps: 600, priority: 1, description: "Web & API - High Priority" },
    { classId: "1:20", rateMbps: 150, priority: 5, description: "Database & Internal" },
    { classId: "1:30", rateMbps: 50, priority: 8, description: "Download & Backup - Limited" }
  ];

  console.log(`[QoS] Applied ${classes.length} traffic classes on ${interfaceName}`);
  
  classes.forEach(cls => {
    console.log(`[${cls.classId}] ${cls.description} - Max ${cls.rateMbps} Mbps`);
  });
}

applyQoSRules();
 

6. Combining iptables Marking with tc

Use iptables to mark packets, then tc classifies them based on the mark.


// Example iptables + tc integration logic
function setupTrafficMarking() {
  console.log("[iptables] Marking HTTP/HTTPS traffic...");
  console.log("iptables -t mangle -A PREROUTING -p tcp --dport 80 -j MARK --set-mark 10");
  console.log("iptables -t mangle -A PREROUTING -p tcp --dport 443 -j MARK --set-mark 10");
  
  console.log("[tc] Classifying marked packets to high priority queue");
}

setupTrafficMarking();
 

7. Best Practices for QoS Implementation

  • Prioritize based on business impact: API > Web > Database > Backup.
  • Always allow burst for critical traffic.
  • Monitor effectiveness using iftop, nload, or Prometheus.
  • Avoid overly strict limits that cause packet loss.
  • Use HTB (Hierarchical Token Bucket) for flexible control.
  • Backup QoS configuration before making changes.

8. Conclusion: Traffic Shaping & QoS Configuration Checklist

Before applying to production, verify the following:

  1. Have you clearly identified which services need priority?
  2. Have you fully implemented wondershaper or tc/htb?
  3. Is HTTP/HTTPS given the highest priority?
  4. Are backup and torrent traffic properly bandwidth-limited?
  5. Do you have monitoring in place to measure QoS effectiveness?
  6. Is the configuration automated via scripts or systemd?

Implementing Traffic Shaping & QoS helps your VPS use bandwidth intelligently, ensuring critical applications remain stable even during high traffic. This is an important skill that makes your system run smoother and more professionally in 2026.

Hope this detailed guide helps you successfully configure QoS and optimize network performance on your VPS!