Skip to content

Bandwidth Rules

Bandwidth Rules let you change every subscriber’s speed on a schedule, without touching their service plan. A typical use is a NIGHT rule that doubles speeds from 23:00 to 07:00, or a MAINTENANCE rule that halves speeds during a specific window for testing.

Rules are stored in the bandwidth_rules table and applied by the BandwidthRuleService background goroutine. Every 30 seconds the service checks active windows and pushes Mikrotik-Rate-Limit updates via CoA (with MikroTik API fallback).

Sidebar → Bandwidth Rules. Direct URL: /bandwidth.

Requires bandwidth.view. Most resellers see this read-only; admin or a reseller with bandwidth.create/edit/delete can modify.

SectionWhat it shows
Rules tableName, Trigger Type, Time window, Days, Multipliers, Services, Priority, Enabled, Auto-Apply, Actions
Add Rule buttonCreate a new rule
Per-service overrides modalInside each rule edit — override the global multipliers for specific services
FieldNotes
Name*E.g. NIGHT, WEEKEND, MAINTENANCE. Surfaced in subscriber logs when applied.
Trigger Typetime (default), quota, or fup. Only time is fully implemented today; quota and fup are reserved for future use.
Start TimeHH:MM in system timezone.
End TimeHH:MM. Windows that cross midnight are supported (e.g. 23:00 → 07:00).
Days of WeekJSON array, e.g. [1,2,3,4,5] for weekdays (1 = Monday, 7 = Sunday). Empty array = every day.
Upload MultiplierInteger percent. 100 = unchanged, 200 = double speed, 50 = half.
Download MultiplierSame.
Service IDsJSON array of service IDs the rule applies to. Empty = applies to all services.
PriorityLower number = higher priority (1 wins over 10). When multiple rules overlap, the lowest-priority-number rule is applied.
EnabledMaster on/off without deleting.
Auto-ApplyIf on, applies automatically every 30 s while the window is active. If off, the rule is a template that has to be applied manually via Apply Now.

A rule’s global multipliers can be overridden per service via the bandwidth_rule_service_multipliers table. Click Edit on a rule → Per-service overrides to set specific multipliers for individual services.

Example: a NIGHT rule with global 200% multiplier, but you don’t want the 100 Mbps tier to double (your backbone can’t sustain it). Add a per-service override for the 100 Mbps service with multiplier 100%, leaving everything else at 200%.

When applying, the service handler looks up the per-service multiplier first, falling back to the rule’s global multiplier if no override exists.

How it stacks — the speed priority order

Section titled “How it stacks — the speed priority order”

Final speed for any subscriber is computed in this order (each step is multiplied):

  1. Subscriber bandwidth rule (per-user custom speed override from subscriber_bandwidth_rules) — if active, replaces the service’s base speed.
  2. FUP speed (if the user’s fup_level > 0) — replaces base speed with the FUP-tier speed.
  3. Service base speed — if neither 1 nor 2.

That base speed is then multiplied by the active global Bandwidth Rule if any. Formula:

final_speed = base_speed × (bandwidth_rule_multiplier ÷ 100)

Important: if both a global Bandwidth Rule AND the service’s own Free Hours / Time-Based Speed are configured for the same window, only the global Bandwidth Rule is applied — to prevent double-boosting.

On each 30 s cycle, BandwidthRuleService:

  1. Loads all enabled = true AND auto_apply = true rules.
  2. For each, checks now() in window. If not, looks for queues previously tagged with this rule and restores the original speed.
  3. If active, iterates online subscribers grouped by NAS. For each subscriber:
    • Looks up the subscriber’s effective base speed (per the priority order above).
    • Multiplies by the rule’s multiplier (or per-service override if defined).
    • Calls UpdateUserRateLimitWithIP on the MikroTik (kb format, no conversion).
    • Falls back to CoA UpdateRateLimit if API fails.
  4. Logs Applied X to user@domain per success.

A read-only audit map (appliedToQueues) tracks what’s been changed so the restore phase only restores queues this rule actually modified. This prevents one rule from undoing another rule’s changes.

Speeds throughout ProxPanel are in kb (kilobits). The bandwidth rule service was previously buggy here — pre-v1.0.149 it multiplied speeds by 1000, treating download_speed as Mbps. A 1200k service with a 200% NIGHT rule was getting 1.2 Gbps on MikroTik instead of 2.4 Mbps. Fixed across bandwidth_rule_service.go and cdn_bandwidth_rule_service.go.

For rules with auto_apply = false, the Apply Now button on the row immediately runs one pass of the rule against all matching subscribers. Use this for ad-hoc maintenance windows where you don’t want the rule firing on a schedule.

ModeWhen the rule firesUse case
Auto-apply = onEvery 30 s while window is activeRegular schedules like NIGHT, WEEKEND
Auto-apply = offOnly when Apply Now is clickedOne-shot maintenance, A/B tests

CDN-specific bandwidth rules live in a separate page (CDN → Bandwidth Rules) and operate on PCQ queues instead of the main per-user simple queue. The logic mirrors what’s described here but only touches CDN-traffic queues. See CDN Management.

Create a “Friday Night Free” rule (Fri 18:00 → Sat 06:00)

Section titled “Create a “Friday Night Free” rule (Fri 18:00 → Sat 06:00)”
  1. Add Rule → name FRIDAY-NIGHT.
  2. Start Time 18:00, End Time 06:00.
  3. Days of Week — select Friday only. (The window naturally rolls into Saturday morning.)
  4. Upload + Download Multiplier — 300 (triple speed).
  5. Priority 10, Enabled, Auto-Apply ON.
  6. Save. The next 30-second cycle picks it up if you’re inside the window.

Halve bandwidth on a misbehaving NAS for one hour

Section titled “Halve bandwidth on a misbehaving NAS for one hour”
  1. Add Rule → name MAINTENANCE-NAS-3.
  2. Service IDs — leave blank to hit everyone.
  3. Multipliers 50 / 50.
  4. Auto-Apply OFF, Enabled ON.
  5. Save.
  6. Click Apply Now. All subscribers on the NAS get halved speeds via CoA.
  7. After your maintenance, edit the rule to clear/disable and click Apply Now again to restore.

Boost only the 10 Mbps tier subscribers at night

Section titled “Boost only the 10 Mbps tier subscribers at night”
  1. Add Rule NIGHT-10M, Window 00:00 → 06:00, Multiplier 200%.
  2. Set Service IDs to just the 10 Mbps service.
  3. Save. Only those subscribers see doubled speed at night; 100 Mbps subscribers stay at their normal rate.
PermissionEffect
bandwidth.viewPage loads.
bandwidth.createAdd Rule button.
bandwidth.editEdit + Apply Now buttons.
bandwidth.deleteDelete button.
subscribers.bandwidth_rulesPer-subscriber rules tab on the Subscriber Detail page.