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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.