I have a ruby on rails app running on passenger / nginx. The app allows users to have download access to very large files (VM backups, sometimes 200Gigs) and I’m on a burstable connection with my ISP up to 100 Mbit/sec.
The problem is that if you begin downloading one of these large files the transfer will climb as high as possible which I don’t want. I’d like to limit the downloading of these large files to a fixed rate such as 150 Kbps while still allowing faster speeds on other parts of the application. Is this possible?
You should include a directive like this in your nginx configuration file (inside the block of your server configuration):
This limits the speed of transmission of the answer to client. It works as a limit for each connection, not for the total server transfer rate. (Maybe you can adjust max_clients =
worker_processes*worker_connectionsas a work-around to limit total transfer.)Take a look at nginx documentation for limit_rate. There is also a
limit_rate_afterdirective that is useful to set this limit only after download exceeds certain size.