Re: Distributing load over multiple links

From: Konstantin P. Belous <const@dont-contact.us>
Date: Tue, 7 Oct 1997 11:36:24 +0300 (EET DST)

Hello,

you may use following patch for neighbors.c file. It allow specify parent
loading as a requests persentage, which will be send to this parent.
As a result, we can balance loading between parents.

For example:

cache_host proxy.gu.net parent 80 3130 weight=70 no-query
cache_host infocom.cris.net parent 8080 3130 weight=30 no-query

weight parameter specify parent loading, weights summary should be equal
100. It's important to use 'no-query' options.
 
Patch tested and used with squid 1.1.14.
You may try it :)

Sorry for my English.

Constantin Belous
const@cris.net

> I will have a situation in a few days where a network is conencted to the
> Internet via 2 links, a 128K ISDN and a 2MB link. The 2MB link goes to a
> provider very distant (network wise) from the provider the ISDN goes to.
>
> I dont want to run BGP if I can help it due to lack of memory in routers
> and as most traffic is web I thought I would just play with the routing of
> squid traffic.
>
> Bad Picture of Network Setup:
>
> Network A <-- 128K --> Squid <-- 2Mb --> Network B <--large--> Internet
> | |
> \_________Some unknown link___________________________________/
>
> Now the 2Mb link is charged by the MB, the ISDN is charged flat rate
> (while utilisation is under 40%). We have a parent cache on Net B.
>
> What I thought should happen would be...
>
> Squid box will have a static route telling it to get to the parent on Net
> B via 2Mb link.
...

> The question is...How to I load balance between source and a parent? I
> know how to do it btween multiple parents...do I just create a non
> cacheing proxy server on the same box as squid and configure it as a
> parent?

--- neighbors.c.orig Fri Jul 11 02:42:14 1997
+++ neighbors.c Thu Aug 7 18:41:28 1997
@@ -357,6 +357,69 @@
     return f;
 }
 
+#define MAX_PEERS 10
+struct {
+ float from, to;
+} usage_factor[MAX_PEERS]; /* up to ... peers */
+
+peer *
+getDefaultParent(request_t * request)
+{
+ float rfactor=0;
+ int i;
+ peer *e = NULL, *tpeer=NULL;
+ peer *peers[MAX_PEERS];
+
+ static short init=0;
+ if (!init) {
+ float weight=0;
+ init++;
+ /* initialize range for each parent from parent weight */
+ for (e = Peers.peers_head, i=0; e; e = e->next, i++) {
+ usage_factor[i].from = weight;
+ weight += e->weight==1 ? 0 : (float)e->weight/100;
+ usage_factor[i].to = weight;
+ }
+ }
+
+ /* init peers array */
+ for (e = Peers.peers_head, i=0; e; e = e->next, i++)
+ peers[i] = e;
+
+ /* random factor */
+ rfactor = (double)rand()/(RAND_MAX);
+
+ /* select parent */
+ for (i=0; i<Peers.n; i++)
+ if (usage_factor[i].from <= rfactor &&
+ rfactor <= usage_factor[i].to)
+ break;
+
+ /* range checking */
+ i= i>Peers.n-1 ? 0 : i;
+
+ /* swap top parent with selected parent */
+ tpeer = peers[0];
+ peers[0] = peers[i];
+ peers[i] = tpeer;
+
+ for (i=0; i<Peers.n; i++) {
+ e = peers[i];
+ if (neighborType(e, request) != PEER_PARENT)
+ continue;
+ /*
+ if (!BIT_TEST(e->options, NEIGHBOR_DEFAULT_PARENT))
+ continue;
+ */
+ if (!peerHTTPOkay(e, request))
+ continue;
+ debug(15, 3, "getDefaultParent: returning %s\n", e->host);
+ return e;
+ }
+ return NULL;
+}
+
+/*
 peer *
 getDefaultParent(request_t * request)
 {
@@ -373,7 +436,7 @@
     }
     return NULL;
 }
-
+*/
 #ifdef HIER_EXPERIMENT
 peer *
 getRandomParent(request_t * request)
Received on Tue Oct 07 1997 - 01:58:11 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:37:15 MST