Jump to content

Trying to program a Round Robin Script


Lostnode

Recommended Posts

Ok, so here is what I am trying to do.
Basicaly I am trying to set up a makeshift load balancing script, so that every time I click a file download link it goes to a new server in a list. But I wanted to make the scriipt as easy as possible to update, so that I can scale the ammount of file links form 2 or 3 to like 50 or 80 and not have to do too much work.

So here was the idea behind it.

the links would look like "getfile.php?folder=[i]foldername[/i]&file=[i]filename[/i]" This woul make is fairly easy to keep the round robin small and easily updated.

Now getfile.php has an array of domains ($domain), for instance

sub1.domain.com
sub2.domain.com
sub3.domain.com

Now when I click the link, it processes it and gives me back http://$domain/$folder/$file but in order, not a random selection, so the first click goes to sub1, the second sub2.

Here is the kicker though, if I add more sub domains or remove then, I don't want the scirpt to fail.

Now I am a complete newbie, I can pass variables and hack minor scripts, but this baffles me, I am not entrily sure how to set up arrays, but I can see via example, my problem though is the round robin part, how make it go from one domain to the next in line. I found one, however it required a script on the reciving end, which means I woul have to attach to a php file... the files I am looking at are anythign from a zip to a jpg and not a php document. So it basicaly needs to send the info via the link to incement.

Honestly I think I am a little out of my league beiung a newbie... it sounds so simple, but I don't think it is...
Link to comment
https://forums.phpfreaks.com/topic/7208-trying-to-program-a-round-robin-script/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.