PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Logiciels d'hébergement > mailing.database.mysql > Mysql Backup Connection in PHP
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Mysql Backup Connection in PHP

Réponse
 
LinkBack Outils de la discussion
Vieux 12/04/2006, 17h26   #1
Locu
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Mysql Backup Connection in PHP

I notice with PHP if a connection cannot be established to a mysql
server with mysql_connect() PHP will timeout and never try the backup
server. In this example:

$db = mysql_connect('db1.local.net', 'username', 'password');
if (!$db) {
$db = mysql_connect('db2.local.net', 'username', 'password');
}

This works great and connects to the 2nd database if the 1st one
rejects the connection completely; however, if the 1st db is under high
load and doesn't respond for 10+ seconds it never jumps to the 2nd one.
Curious if there's a better way to accomplish this. If the 1st db
doesn't respond in 1 second max I'd like to hop to the 2nd one.

Does the newer mysqli_connect handle this better, anyone know?

  Réponse avec citation
Vieux 12/04/2006, 20h00   #2
fletch
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Mysql Backup Connection in PHP

Don't know about mysqli_connect() but you could use fsockopen() and set
a short timeout, close the connection and then reconnect with
mysql_connect();

I would hope there was a tidier solution that this though. Perhaps load
balancing on the backup server, in relation to how much it can handle?

  Réponse avec citation
Vieux 15/04/2006, 17h33   #3
Locu
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Mysql Backup Connection in PHP

Another issue I'm trying to overcome is locking issues. We do
dual-master replication, and in the event a table is locked on db1, it
should still be readable on db2. It would be great to have a way to
timeout a connection if no response rcv'd in say.. 2 seconds for it to
kick to the 2nd server.

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 21h12.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09611 seconds with 11 queries