Hi guys!
I have a debian box acting as a router and need a tool to perform
traffic shaping based on source/destination IPs, interfaces, etc. I
have tried the default tc, however, it uses plenty of resources, e.g.
600 mbps without shaping flows through with 3% cpu load and the same
600mbps with shaping (tc using htb on egress interface) consumes
something like 40% cpu.
Hi guys!cpu load and the same 600mbps with shaping (tc
I have a debian box acting as a router and need a tool to perform traffic shaping based on source/destination IPs, interfaces, etc. I have tried the default tc, however, it uses plenty of resources, e.g. 600 mbps without shaping flows through with 3%
using htb on egress interface) consumes something like 40% cpu.as well as no manuals and so on - I guess it's
Probably someone could advise some kind of a tool to do such shaping with minimum resources consumed - I've searched through the web and found a module named nf-hishape, however, I didn't manage to find some reasonably high number of articles about it
not very popular (if it's actually alive).
Any help would be appreciated.
Thanks in advance.
tc class add dev eth1 parent 1:1 classid 1:30 htb rate 1mbps ceil 1000mbps
On 05/27/2016 02:40 PM, Aleksey wrote:
Hi guys!Hi.
I have a debian box acting as a router and need a tool to perform
traffic shaping based on source/destination IPs, interfaces, etc. I
have tried the default tc, however, it uses plenty of resources, e.g.
600 mbps without shaping flows through with 3% cpu load and the same
600mbps with shaping (tc
using htb on egress interface) consumes something like 40% cpu.
Probably someone could advise some kind of a tool to do such shaping
with minimum resources consumed - I've searched through the web and
found a module named nf-hishape, however, I didn't manage to find some
reasonably high number of articles about it as well as no manuals and
so on - I guess it's
not very popular (if it's actually alive).
Any help would be appreciated.
Thanks in advance.
Seems you use flat list of filters. How many filters you have?
Did you try hash tables for traffic classification?
fq_codel should be used in any case, if you have more than one service use a fq_codel per service and shape them accordingly with a hard limit. Above all services queues add a root fq_codel and shape them to 92% of the total available
bandwidth in total.
Reducing a service under the physical bandwidth needed is mostly unintended or
is a result of misunderstanding of the difference between average to peak bandwidth of network-applications and cost me in job a huge amount of time.
A good start point:
https://wiki.gentoo.org/wiki/Traffic_shaping
Best regards Ruben
Practically, I haven't done any configuration on my production router - I have performed tests in lab environment. Configuration was pretty simple:
tc qdisc add dev eth1 root handle 1: htb default 30
tc class add dev eth1 parent 1: classid 1:1 htb rate 1000mbps ceil 1000mbps tc class add dev eth1 parent 1:1 classid 1:10 htb rate 3mbps ceil 5mbps
tc class add dev eth1 parent 1:1 classid 1:20 htb rate 5mbps ceil 7mbps
tc class add dev eth1 parent 1:1 classid 1:30 htb rate 1mbps ceil 1000mbps
tc qdisc add dev eth1 parent 1:10 handle 10:0 sfq perturb 10
tc qdisc add dev eth1 parent 1:20 handle 20:0 sfq perturb 10
tc qdisc add dev eth1 parent 1:30 handle 30:0 sfq perturb 10
tc filter add dev eth1 protocol ip parent 1:0 prio 1 u32 match ip dport 443 0xffff flowid 1:20
tc filter add dev eth1 protocol ip parent 1:0 prio 1 u32 match ip dport 80 0xffff flowid 1:10
On Fri, May 27, 2016 at 04:50:55PM +0300, Aleksey wrote:
Practically, I haven't done any configuration on my production router
- I
have performed tests in lab environment. Configuration was pretty
simple:
tc qdisc add dev eth1 root handle 1: htb default 30
tc class add dev eth1 parent 1: classid 1:1 htb rate 1000mbps ceil
1000mbps
tc class add dev eth1 parent 1:1 classid 1:10 htb rate 3mbps ceil
5mbps
tc class add dev eth1 parent 1:1 classid 1:20 htb rate 5mbps ceil
7mbps
tc class add dev eth1 parent 1:1 classid 1:30 htb rate 1mbps ceil
1000mbps
tc qdisc add dev eth1 parent 1:10 handle 10:0 sfq perturb 10
tc qdisc add dev eth1 parent 1:20 handle 20:0 sfq perturb 10
tc qdisc add dev eth1 parent 1:30 handle 30:0 sfq perturb 10
tc filter add dev eth1 protocol ip parent 1:0 prio 1 u32 match ip
dport 443
0xffff flowid 1:20
tc filter add dev eth1 protocol ip parent 1:0 prio 1 u32 match ip
dport 80
0xffff flowid 1:10
I'd assume the problem is that when you bind htb directly to the root
of a
device you basically loose the multiqueue capability of an ethernet
card
because all packets must end in a single queue from which they are
dispatched
to the multiple queues of an ethernet card.
mk
I have also noticed that all the load is on one CPU core it is not distributed to all available cores. And how can this be avoided?
So, yes, I have 10G uplinks. The main goal is to be able to shape
traffic from certain hosts to the destinations that are reachable
through local internet exchange and to all other destinations (world).
Local IX is connected to one interface of my debian box and worldwide
traffic flows through the another. The simpliest way to achieve this,
for my opinion, was to apply egress qdiscs on there interfaces and apply filters and classes there also, so it would effectively shape as I need.
The problem with shaping closer to the source is that I wouldn't be able
to classify the traffic on switches - it's not only one or a couple of destinations, it's something like 30k destinations available through
local IX.
Probably you could point me to a better option.
P.S. to lxP - increasing rate on the default htb class didn't help - probably, CPU usage could drop a couple percents lower (not sure,
really) but is is definitely not significant.
--
With kind regards,
Aleksey
On Mon, May 30, 2016 at 01:55:51PM +0300, Aleksey wrote:
I have also noticed that all the load is on one CPU core it is not
distributed to all available cores. And how can this be avoided?
There is a qdisc called mq which creates a class for each hardware
queue on
the attached ethernet card. You can bind other qdiscs (such as htb) to
each of
these classes but this will not allow you to shape traffic for a single
type going out over all the hardware queues.
It might be possible to have multiple htb qdiscs and use filters to
send
each type of traffic to a selected hardware queue. This has other
adverse
effects (such as not being able to borrow unused bandwidth among the hw queues) and there still might be lock contention among the cores for
each such
queue so it might not even work better.
If you are at 1 Gbit speed the cpu can probably handle it so there is
no need
to do any of this. If you have a 10Gbit+ connection then this probably
isn't
the correct place to do shaping anyway and should be done closer to the source.
It depends on what you're trying to accomplish.
regards
Martin
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 64:03:10 |
Calls: | 6,654 |
Files: | 12,200 |
Messages: | 5,331,763 |