External/Remote Database Possible With Dolphin?

Hi All,

I'm having a heck of a time with database errors on my site. The errors are all cannot connect/ database busy errors. I'm on a reputable Dolphin specialist host (shared) and other than the database issues, the hosting has been great. The host has told me that the errors are because of the limit on the number of database connections allowed to the database server. This makes sense, except, that my site doesn't have any more activity then it ever did for the year  on the same host before I started experiencing this problem. In fact, sometimes the database will give errors when I have only four people online, but later, when 25 members are online, there are no database problems.

My members are starting to get very frustrated so I'm looking for something. Since the database is the only issue, I'm wondering if I can get a database only host (I see them out there) for my database. Has anyone set up Dolphin with everything set up on one hosting account, but had it use a database on a different server? Is it even possible?

Thanks for any help/advice.

Quote · 19 Mar 2012

this shouldn't be a problem. you can have your site on one server and have the DB somewhere else.
do you use pconnect? ( persistent connection to the DB) If yes disable it, it should help,

Using persistent connections can require a bit of tuning of your Apache and MySQL configurations to ensure that you do not exceed the number of connections allowed by MySQL.

Quote · 19 Mar 2012

Thank you prolaznik. I'm pretty sure the host has the option to use persistent connections locked off, but I will take a look into that.

Quote · 19 Mar 2012

mysql.allow_persistent = Off   (php.ini)

/inc/classes/BxDolDb.php

find function

 /**
  * connect to database with appointed parameters
  */
 function connect()
 {
  $full_host = $this->host;
  $full_host .= $this->port ? ':'.$this->port : '';
  $full_host .= $this->socket ? ':'.$this->socket : '';

  $this->link = @mysql_pconnect($full_host, $this->user, $this->password);
  if (!$this->link)
            $this->error('Database connect failed', true);

  if (!$this->select_db())
            $this->error('Database select failed', true);
  
        mysql_query("SET NAMES 'utf8'", $this->link);
        mysql_query("SET sql_mode = ''", $this->link);

        $GLOBALS['bx_db_link'] = $this->link;
 }

and change to

 /**
  * connect to database with appointed parameters
  */
 function connect()
 {
  $full_host = $this->host;
  $full_host .= $this->port ? ':'.$this->port : '';
  $full_host .= $this->socket ? ':'.$this->socket : '';

  $this->link = @mysql_connect($full_host, $this->user, $this->password);
  if (!$this->link)
            $this->error('Database connect failed', true);

  if (!$this->select_db())
            $this->error('Database select failed', true);
  
        mysql_query("SET NAMES 'utf8'", $this->link);
        mysql_query("SET sql_mode = ''", $this->link);

        $GLOBALS['bx_db_link'] = $this->link;
 }


 Apache does not work well with persistent connections. When it receives a request from a new client, instead of using one of the available children which already has a persistent connection open, it tends to spawn a new child, which must then open a new database connection. This causes excess processes which are just sleeping, wasting resources, and causing errors when you reach your maximum connections, plus it defeats any benefit of persistent connections

Quote · 19 Mar 2012

Thank you!  I will try this out right now.

Quote · 19 Mar 2012
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.