Nginx – Limiting per-request download AND upload speed on Apache or Nginx

apache-2.4nginxrate-limitingupload

I'm currently running a couple of Web servers (one is Apache 2.4 based, another is running nginx 1.8).

I need to set a rate limit, on each individual GET/POST request, that can throttle both download and upload speed.

I've googled around but every solution I've found seems to focus on download rate only, and I can't find a way to set a limit also on data sent from the client to the server in a request body.

I need this because most requests are related to file uploads.

Any suggestion would be greatly appreciated.
Thanks!

Best Answer

You can't probably find this information because it's not generally needed; your case is just too rare.

Downloads can be of any size, even extremely huge, and rate limiting will allow equitable distribution of network capacity between the users: one huge download can't cause slowing down on typical browsing etc.

HTTP uploads, however, are normally limited in size and they may reserve memory during the upload, that can only be released when the upload is over and the file can be saved. Therefore, I'd suggest limiting the amount of concurrent uploads instead, as I would want a single upload to be over as soon as possible.

Besides, the upload speed in most cases is already limited by an asynchronous Internet connection, so your users would suffer from a bad user experience if you'd limit it even further.

Related Topic