L
L
Lelouch2020-05-27 17:04:21
linux
Lelouch, 2020-05-27 17:04:21

How to limit bandwidth for a single service in Linux?

I have a TG proxy that I use for myself and share a bit with the world.

Here is the implementation:
https://github.com/alexbers/mtprotoproxy

But lately there have been too many guest connections and they eat up traffic a lot.

It spins without a docker, as a regular service. I want to run two services in parallel - for myself and the guest. On the guest, respectively, limit the bandwidth.

Google suggests that tc can help me with this. But, I could not figure out the documentation on how to make a restriction at the level of a specific service.

Or maybe there is a simpler solution?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
V
Vladimir, 2020-05-27
@MechanID

I don’t know simple ways, try reading the documentation on using tc, everything is described in great detail https://www.opennet.ru/docs/RUS/LARTC/c834.html

V
Vitaly Karasik, 2020-05-27
@vitaly_il1

I didn't use it, but it seems like this:
https://www.tutorialspoint.com/how-to-limit-networ...

V
Valentine, 2020-05-27
@vvpoloskin

here Study

K
Karpion, 2020-05-27
@Karpion

You can look inside the service for a way to arrange shaping (limit the speed). Many serious products have it - for example, Squid definitely has it, but I did not use it.
It can be limited by means of a firewall. ipfw in FreeBSD has it. In iptables, I don't know.
You can filter and wrap in shaping by source and destination IP addresses, by source and destination ports, by the user of the local program. It is probably easiest for you to use the port - after all, it is easiest to spread two instances of the service across ports.

R
Roman Mirilaczvili, 2020-05-27
@2ord

nginx and rate limit:
https://www.nginx.com/blog/rate-limiting-nginx/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question