Limiting egress also limits ingress?

Hello.

I’m running 10 storagenodes on my network, which saturate my upload bandwidth, when not limited. Since this causes lag spikes, I resorted to limit the upload bandwidth of my ethernet interface of my Storj server to a little bit less than my maximum upload bandwidth. However, I noticed that the ingress (which I haven’t limited) is less than half of what it is, when no upload/egress limit is in place. I tested this multiple times and see this phenomenon every time. Is there something I can do to ensure, that I get the usual egress when limiting my ingress?

The Storj server is running on Ubuntu Server 24.04.3
I use “tc” to limit the upload bandwidth. The script I am using:

#!/bin/bash
# limit-egress.sh  
# Example: ./limit-egress.sh enp4s0 25600
# Only limiting traffic which is not routed to 192.168.0.0/24 and 192.168.178.0/24

IFACE="$1"
RATE="$2"

if [ -z "$IFACE" ] || [ -z "$RATE" ]; then
  echo "Usage: $0 <interface> <rate-in-kbit>"
  exit 1
fi

if [ "$EUID" -ne 0 ]; then
  echo "Dieses Script muss mit Root-Rechten ausgeführt werden (sudo)."
  exit 1
fi

# Remove old qdiscs
tc qdisc del dev "$IFACE" root 2>/dev/null

# Add root qdisc
tc qdisc add dev "$IFACE" root handle 1: htb default 30

# Class for limited traffic
tc class add dev "$IFACE" parent 1: classid 1:1 htb rate "${RATE}kbit" ceil "${RATE}kbit"

# Everything that does not go into the internal network, in class 1:1
# First exclude the internal networks (RETURN)
tc filter add dev "$IFACE" protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.0/24 action pass
tc filter add dev "$IFACE" protocol ip parent 1:0 prio 2 u32 match ip dst 192.168.178.0/24 action pass

# Everything else 
tc filter add dev "$IFACE" protocol ip parent 1:0 prio 10 u32 match ip dst 0.0.0.0/0 flowid 1:1

This would be a wrong solution to your buffebload issue. The correct solution is to enable SQM on your upstream channel.

Saturating upstream or downstram shall have no inpact on latency in properly configured network.

4 Likes

I use a pfSense router as upstream channel. Could you point me to a tutorial on how to enable SQM? I’m not exactly sure what to look for.

4 Likes

Thanks, will try that and report back.

I followed your posted tutorial and set the limits to 95% of my maximum upload/download bandwidth. Unfortunately, I see no difference whatsoever. The lagspikes are still present.

Maximum measured actual or claimed by ISP? Codel is compute intensive, how powerful is your pfsense server? Make sure it is not cpu bound.

What does the waveform bufferbloat test show? If you get an A there then the issue is indeed elsewhere, maybe inside your network behind the gateway.

I measured my bandwidth with no nodes running (and no other relevant traffic) and used that to determine the values for the limiters.

CPU usage is sitting at 10% according to the pfSense dashboard. It’s an Intel N100. Should be enough for my small network.

Waveform bufferbloat test shows grade C at the moment. Note: All following values are from the test while all my nodes were running.
Unloaded: 28ms
Download Active: +96ms
Upload Active: +114ms

10% during max load with codel active?

Grade C is not good, but at least we confirmed that bufferbload is the problem.

Maybe your ISP throttles you further under load? Set parameters to 50% of your bandwidth as a test — do you get an A?

+100ms is not horrible but not great either.

It does not depend on network size — just on a throughput.

And there is no wireless link anywhere involved, correct?

Yes, 10% with codel active.

I have set the limits to 50% now. I get a B now (again with nodes running):
Unloaded: 25ms
Download Active: 2ms
Upload Active: 52 ms

I talked to my ISP last week about this problem. They pointed me to my saturated uplink and told me nothing they can do, if I satured it. They also told me, that there is no limiter or throttle on their side (I specifically asked).

No wireless link. All involved clients are on LAN.

What confuses me is the fact, that the Storj Server still uses 100% of my upload bandwith, even thought the limiter is set to 50%.

Did you increase the ‘Queue Length’ in the up and download limiters? The defaults are for upto 100M/bit. Increase to 3000 - 5000 if you have faster.

I have spent many hours with pfsense bufferbloat tutorials. It was a waste of time. :roll_eyes:

1 Like

Something does not work then – but I don’t have experience with pfsense to point out what could be wrong. I played with a plugin on OpenWRT, it worked there, and now I use ubiquiti gateways that have it built-in (technically they have fq_codel + HTB)

(IIRC there was something with firewall rules “match” vs “pass”, their placement (shall be very top rule) and direction, and make sure you turn off all other QoS.)

The nonsense docs provide a better explanation of how it works..

To limit speed you want to use a limiter, fq tries not to drop packets.

I though this is a real issue - dropping packets doesn’t allow to use the internet for yourself?

Well, you need both – fq (to create several “fair” queues") and CoDel – which is an “active queue management” that absolutely does drop packets. This is how TCP is supposed to work, moderate traffic by dropping packets.

Not dropping packets is what poorly behaving equipment does. and this is precisely what causes bufferbloat in the first place.

This ia by design: When CoDel used along with fair queuing, packets will be getting dropped from the most obnoxous larget flows – exactly what you want.

Just using codel is not enough, because indeed, it may drop packets you don’t want dropped.

Often people say “codel” when they mean “fq_codel” and this causes confusion.

1 Like