Skip to content

Shape Bandwidth

Limit upload or download throughput for matched public requests without rejecting them.

Use This When

Use traffic shaping for large uploads, public file downloads, or protecting small upstreams from bandwidth-heavy clients.

Prerequisites

  • A host/path/method match that isolates the traffic to slow.
  • A byte-per-second budget for upload, download, or both.

Steps

  1. Open Traffic Policy -> Traffic Shapers and create a rule.

    p2pstream Traffic Policy page showing cache rules and traffic shapers
    The Cache and Traffic Shapers sections sit together because both act after early deny policies and before or during route target forwarding.
  2. Match the traffic. Example for a downloads path:

    FieldValue
    Namedownloads-shaper
    Priority20
    EnabledOn
    ProtocolsHTTPS
    Host patternsfiles.example.com
    Path prefixes/download
  3. Choose budget scope:

    ScopeUse when
    Per keyAll requests for the same key should share one budget.
    Per requestEvery request should get an independent budget.

    For public downloads, use per key and key by remote IP. For one-off large imports, per request may be simpler.

  4. Set byte rates:

    FieldValue
    Download bytes per second1048576
    Upload bytes per second0
    Burst bytes2097152
    Request exempt bytes0
    Response exempt bytes65536

    0 means unlimited for upload or download rates.

    Burst bytes

    Burst allows a connection to temporarily exceed the configured byte-per-second rate by up to this many bytes before the token bucket enforces the limit. Use it to absorb the initial burst of a download without throttling the entire transfer from byte one. Set to 0 to disable burst.

p2pstream traffic shaper editor showing request match, budget scope, key parts, upload and download byte rates, burst, and exempt bytes
The traffic shaper editor defines which requests are slowed, whether budgets are shared per key or per request, and how much upload or download throughput is available.

Verification

Download a large matching file and watch transfer speed. Use Traffic tracing to confirm the shaper rule is selected.

Troubleshooting

SymptomCheck
Small responses appear unshapedThey may finish inside exempt bytes or before the rate is visible.
Clients share bandwidth unexpectedlyReview key parts and budget scope.
Rule does not matchConfirm host, path, protocol, method, and priority.

Next Steps

Operations documentation for self-hosted p2pstream deployments.