Redirection

Weighted Round-Robin Redirection

by lhl ( | | | )

Here's a quick and dirty way to do weighted round-robin redirection. I assign the key rather than the entire array for weighted array creation so it's not the most inefficient way to do it ever (a more efficient way is to call rand(1,100) and then have a big switch, but it's a PITA to shuffle, especially as you add more sites).

Anyway, the following example shows 50% of the traffic going to url-3, 37.5% to url-2, and 12.5% to url-1:

XML feed