941,512 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 933
  • PHP RSS
Oct 28th, 2009
0

Simple, One-Time PHP Load Balancing Using Random Redirects--Do You See Any Problems?

Expand Post »
Hello all!

I came here through Google searching for PHP load balancing... and got to this thread: http://www.daniweb.com/forums/thread171839.html

I am trying to do something similar, but what I'm trying to do is a one time, one day, quick and cheap load balancing solution using PHP.

The idea is to use a simple php script to randomly redirect users to several other servers with one static page. I am just wondering if this would be sufficient if I were to expect an influx of users for only one day (may reach up to 50,000 users within a one hour period). Below is what I have come up with using only limited php knowledge. The server running this script will be a basic dedicated virtual server by MediaTemple which should suffice as a temporary load balancer, and will be redirected to multiple GridServer accounts from MediaTemple. Do you see any problems with this?

PHP Syntax (Toggle Plain Text)
  1. <?php
  2. $servers = array("www.foo1.com",
  3. "www.foo2.com",
  4. "www.foo3.com");
  5. $server = $servers[array_rand($servers)];
  6. header("Location: http://$server");
  7. ?>

Thank you for taking your time to look at this! I really appreciate it!
Last edited by icon512; Oct 28th, 2009 at 12:42 am.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
icon512 is offline Offline
2 posts
since Oct 2009
Oct 28th, 2009
0
Re: Simple, One-Time PHP Load Balancing Using Random Redirects
That looks fine although if this is just one static page then it's not shortening the load infact you are doubling it as they are going through two servers.
Reputation Points: 11
Solved Threads: 6
Junior Poster in Training
Froger93 is offline Offline
74 posts
since Sep 2009
Oct 28th, 2009
0
Re: Simple, One-Time PHP Load Balancing Using Random Redirects
Well, the point is to make sure that one server is not overloaded and fails...

So even though the load time is taking a little bit longer, it's better than overloading the server and having it take minutes to load or even worse, nothing...
Reputation Points: 10
Solved Threads: 0
Newbie Poster
icon512 is offline Offline
2 posts
since Oct 2009
Oct 29th, 2009
0
Re: Simple, One-Time PHP Load Balancing Using Random Redirects
Is this just one static page or multiple versions of an extensive website?
Reputation Points: 11
Solved Threads: 6
Junior Poster in Training
Froger93 is offline Offline
74 posts
since Sep 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Continual "undefined index:day" errors in PHP script
Next Thread in PHP Forum Timeline: PHP file not rendered





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC