mercredi 3 décembre 2014

PDO over network, hangs MySql Database after running 1 to 3 hours?


I have the following class



--------------------------------------------- CRUD Code Snippet--------------------
class CRUD{
function __construct(){
$this->db_user = "user_name";
$this->db_pass = "user_password";
$this->db_name = "myDb";
$this->host = "localhost";
}


//connect() function to connect to database
private function connect(){
try{
$pdo_Options = array(PDO::ATTR_PERSISTENT => true, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);
$this->con = new PDO("mysql:host={$this->host};dbname={$this->db_name};charset=utf8", $this->db_user, $this->db_pass, $pdo_Options);
}catch(PDOException $ex){
return $ex->getMessage();
$this->tempVar = $ex->getMessage();
}
}


----------- The following method creates problems when updating record --------------
public function dbQuery($sql,$bindVars=array()){
try{
$this->connect();
$statement = $this->con->prepare($sql);
$statement->execute($bindVars);
if($statement->rowCount() > 0){
return true;
}
else{
return false;
}
$this->con = null;
}catch(PDOException $exc){
$this->tempVar = $exc->getMessage();
$this->sqlToReturn = $sql;
return false;
}
}

}//CRUD
-------------------------------------------------------------------


The function running very good and it performs its work perfectly but after certain time of execution MySql database get hangs and stop responding. The page code where the mentioned function dbQuery() called, it shows an error after consuming 120 seconds of time. in my scenario, the software is running over a huge network and having apx: 300 concurrent users who are inserting, updating, searching and deleting records in database. Database having apx: 300000 records. I have installed WAMP server on windows 8.1 64-bit. MySql Version is : 5.6.20, on T110-II Power Edge Xeon server machine.


I did not find/diagnosed the issue why this problem occurs?


Please guide me, as I'm really worrying about this problem. enter image description here





Aucun commentaire:

Enregistrer un commentaire