--MimeMultipartBoundary
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Hello Squiders,
we have found balancing load problem between our parents on the
round-robin fashion, but with defined load for each parent.
As the result, I can propose following patch for neighbors.c file.
It allows defining load for each parent as a request percentage,
or, in practice, defines parent's traffic loading.
If you will find that it is useful characteristic, you may include it
in squid package.
For use this feature it is enough to define weight of parent and disable icp
requests
--- cache_host proxy.gu.net parent 80 3130 weight=75 no-query cache_host infocom.cris.net parent 8080 3130 weight=25 no-query --- Thanks, Constantin Belous const@cris.net Diff: --- 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) --MimeMultipartBoundary--Received on Tue Jul 29 2003 - 13:15:42 MDT
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:11:22 MST