This is a really dumb question, but here goes.

  1. I've got one web server, running a simple PHP app.
  2. I've got two MySQL servers, with one replicated database, which powers the PHP app. I'm using two MySQL databases to deal with demand.
  3. How can I (and indeed, can I) get the PHP app to alternate which MySQL server it uses?

The line where I connect to the database is currently this:

$con = mysql_connect('10.0.0.2:3306','name','password')
or die('Could not connect to the server!');

Is there a way I can load-balance with 10.0.0.2 and my other server?

link|improve this question

25% accept rate
Unfortunately, this question is slighty off topic as per the site FaQ and will likely be closed or moved to the sister ServerFault site, where a load-balancer question may have already been asked. – tombull89 May 12 '11 at 14:35
argh sorry, will move it to serverfault (can't we just merge all three sites?!) – simon May 12 '11 at 16:05
ok moved to serverfault.com/questions/269093/… – simon May 12 '11 at 16:07
well, you've got your answer less than 10 minutes on SF. If you asked on SuperStackFault(TM) it'd get drowned out by the sheer volume of content. Still, it's a good original question and I may well use it in the future. – tombull89 May 12 '11 at 17:09
feedback

closed as off topic by studiohack May 12 '11 at 14:58

Questions on Super User are expected to generally relate to computer software or computer hardware, within the scope defined in the faq.

Browse other questions tagged or ask your own question.