How to manage Squid based on per user user bandwidth

user2430445 picture user2430445 · Mar 19, 2014 · Viewed 16.9k times · Source

I want to manage the bandwidth and traffic based on user activities on Squid Server Proxy.

I made some research but couldn't find the solution that I want.

For example, users who have more than 256K traffic should be restricted from server.

Can you help me?

Thanks

Answer

I'm assumed squid 3.x:

To provide a way to limit the bandwidth of certain requests based on any list of criteria.

class: the class of a delay pool determines how the delay is applied, ie, whether the different client IPs are treated separately or as a group (or both)

class 1: a class 1 delay pool contains a single unified bucket which is used for all requests from hosts subject to the pool

class 2: a class 2 delay pool contains one unified bucket and 255 buckets, one for each host on an 8-bit network (IPv4 class C)

class 3: contains 255 buckets for the subnets in a 16-bit network, and individual buckets for every host on these networks (IPv4 class B )

class 4: as class 3 but in addition have per authenticated user buckets, one per user.

class 5: custom class based on tag values returned by external_acl_type helpers in http_access. One bucket per used tag value.

Delay pools allows you to limit traffic for clients or client groups, with various features:

  • Can specify peer hosts which aren't affected by delay pools, ie, local peering or other 'free' traffic (with the no-delay peer option).

  • delay behavior is selected by ACLs (low and high priority traffic, staff vs students or student vs authenticated student or so on).

  • each group of users has a number of buckets, a bucket has an amount coming into it in a second and a maximum amount it can grow to; when it reaches zero, objects reads are deferred until one of the object's clients has some traffic allowance.
  • any number of pools can be configured with a given class and any set of limits within the pools can be disabled, for example you might only want to use the aggregate and per-host bucket groups of class 3, not the per-network one.

In your case can you use:

For a class 4 delay pool:
        delay_pools pool 4
        delay_parameters pool aggregate network individual user

The last delay_pool, can be configure in your squid server proxy:

for example; each user will be limited to 128Kbits/sec no matter how many workstations they are logged into:

delay_pools 1
delay_class 1 2
delay_access 1 allow  all
delay_parameters 4 32000/32000 8000/8000 600/64000 16000/16000

Please read more:

http://wiki.squid-cache.org/Features/DelayPools

http://www.squid-cache.org/Doc/config/delay_parameters/