S
S
Seedor2020-03-20 19:20:45
go
Seedor, 2020-03-20 19:20:45

How to limit the speed of uploading content in fasthttp?

Actually, the question is how to set a limit on the data transfer rate to the client without resorting to a third-party server such as nginx, etc. By means of fasthttp. There is a relatively complicated way with stream interception, but there may be some simple way. The task seems to be trivial. )

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladislav, 2020-03-23
@Seedor

I had a similar task, only it was necessary to limit both the incoming and outgoing speed.
Unfortunately, the only working option is to limit the speed of writing / reading data.
I would recommend https://github.com/juju/ratelimit as I myself use this library in production. I tried a lot of different ones, but many had a problem with the write speed limit, except for juju / ratelimit.
With it, you can configure both the total speed limit for up / down, and separate.

D
Dimonchik, 2020-03-20
@dimonchik2013

time.Sleep

R
Roman Mirilaczvili, 2020-03-20
@2ord

You can somewhere in the middleware:
https://github.com/golang/go/wiki/RateLimiting
https://github.com/throttled/throttled

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question