Rail bandwidth management?

I was wondering if anyone knew that you could manage the bandwidth in the rails application in some way that is not dependent on the web server. For example, each account has a bandwidth limit. Is incoming and outgoing traffic deducted from the monthly allowance?

+5
source share
1 answer

One option is to add after_filter to application.rb (so that it applies to all actions) and do the following:

def store_bandwidth_usage
   response_size = response.body.size
   # Assuming the User model has a bandwidth_usage attribute
   @current_user.increment!(:bandwidth_usage, response_size) 
end

Of course, you will need a before_filter file, which would check that the user has not passed through the allocated bandwidth, otherwise they will be denied access.

, , rails, , (, ), .

+4

All Articles