]> git.ipfire.org Git - thirdparty/squid.git/commit - src/MessageDelayPools.h
Add response delay pools feature for Squid-to-client speed limiting.
authorEduard Bagdasaryan <eduard.bagdasaryan@measurement-factory.com>
Sun, 19 Feb 2017 17:13:27 +0000 (06:13 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 19 Feb 2017 17:13:27 +0000 (06:13 +1300)
commitb27668ec6cfce0b56ca6d8ef4b887207f4ecc6b7
tree77c4c85caf2b23f0c82e1d30aeb9e7887f57a573
parent17b07509e0c7751e28f8dfd1844f50b1a0f72a5d
Add response delay pools feature for Squid-to-client speed limiting.

The feature restricts Squid-to-client bandwidth only.  It applies to
both cache hits and misses.

  * Rationale *

  This may be useful for specific response(s) bandwidth limiting.
  There are situations when doing this is hardly possible
  (or impossible) by means of netfilter/iptables operating with
  TCP/IP packets and IP addresses information for filtering. In other
  words, sometimes it is problematic to 'extract' a single response from
  TCP/IP data flow at system level. For example, a single Squid-to-client
  TCP connection can transmit multiple responses (persistent connections,
  pipelining or HTTP/2 connection multiplexing) or be encrypted
  (HTTPS proxy mode).

  * Description *

  When Squid starts delivering the final HTTP response to a client,
  Squid checks response_delay_pool_access rules (supporting fast ACLs
  only), in the order they were declared. The first rule with a
  matching ACL wins.  If (and only if) an "allow" rule won, Squid
  assigns the response to the corresponding named delay pool.

  If a response is assigned to a delay pool, the response becomes
  subject to the configured bucket and aggregate bandwidth limits of
  that pool, similar to the current "class 2" server-side delay pools,
  but with a brand new, dedicated "individual" filled bucket assigned to
  the matched response.

  The new feature serves the same purpose as the existing client-side
  pools: both features limit Squid-to-client bandwidth. Their common
  interface was placed into a new base BandwidthBucket class.  The
  difference is that client-side pools do not aggregate clients and
  always use one bucket per client IP. It is possible that a response
  becomes a subject of both these pools. In such situations only matched
  response delay pool will be used for Squid-to-client speed limiting.

  * Limitations *

  The accurate SMP support (with the aggregate bucket shared among
  workers) is outside this patch scope. In SMP configurations,
  Squid should automatically divide the aggregate_speed_limit and
  max_aggregate_size values among the configured number of Squid
  workers.

  * Also: *

  Fixed ClientDelayConfig which did not perform cleanup on
  destruction, causing memory problems detected by Valgrind. It was not
  possible to fix this with minimal changes because of linker problems
  with SquidConfig while checking with test-builds.sh. So I had
  to refactor ClientDelayConfig module, separating configuration code
  (old ClientDelayConfig class) from configured data (a new
  ClientDelayPools class) and minimizing dependencies with SquidConfig.
26 files changed:
src/BandwidthBucket.cc [new file with mode: 0644]
src/BandwidthBucket.h [new file with mode: 0644]
src/ClientDelayConfig.cc
src/ClientDelayConfig.h
src/ClientInfo.h
src/Makefile.am
src/MessageBucket.cc [new file with mode: 0644]
src/MessageBucket.h [new file with mode: 0644]
src/MessageDelayPools.cc [new file with mode: 0644]
src/MessageDelayPools.h [new file with mode: 0644]
src/SquidConfig.h
src/cache_cf.cc
src/cf.data.depend
src/cf.data.pre
src/client_db.cc
src/client_side.cc
src/client_side.h
src/comm.cc
src/comm/IoCallback.cc
src/comm/Loops.h
src/comm/Write.cc
src/comm/Write.h
src/comm/forward.h
src/fde.h
src/http/Stream.cc
src/http/Stream.h