Limiting bandwith per user?
We need to modify our bandwidth usage (per user on our site). I would want to limit bandwidth per ip,,. Basically we want the users who connects to our webstie to only be able to (download @ 2.5Mbps or 250KB/per sec). While were able to cache and upload @ unlimited speed.. Right now we have no cap.
If you're concerned about fairness, I would not recommend limiting per user. It works as long as you have a low connection count, but eventually the sum of all limited connections exceeds your available bandwidth and the situation is as bad as without the limit.
There is a thing called Stochastic Fairness Queuing. It will prevent that a single connection starves and improve fairness. It identifies connections using a hash algorithm and serves them one packet at a time in round robin order.
In order for SFQ to work you have first to limit bandwidth, to move the queue to your machine where you can control it. Here is a very simple setup I often use:
$TC qdisc del dev eth0 root handle 1
$TC qdisc add dev eth0 root handle 1: htb default 20 r2q 50
$TC class add dev eth0 parent 1: classid 1:1 htb rate 10mbit ceil 10mbit
$TC qdisc add dev eth0 parent 1:1 handle 110: sfq perturb 10
$TC filter add dev eth0 parent 1: prio 3 protocol all u32 match u32 0 0 flowid 1:1
If you find this useful please explain your motivation and I can provide more complex setups that'll suit your purpose.
If you are talking about HTTP traffic, you can direct the users to a proxy such as squid. Squid can be configured to limit the bandwidth usage per IP. You can use delay pools
in configuration parameters. You can have a look at this page. You can find many other pages on the internet.
I think it can be also configured to limit the bandwidth per user when enabling authentication.
bandwidth is for download and page view
I think is better you create extra layer on your project and then add some size after any request ( like page view ) and then calculate size of response and sum with traffic of user
if user use more than bandwidth then make bandwidth finish response