ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

mysql_pconnect - too many connections

September 23, 2010 1:30pm

Subscribe [4]
  • #1 / Sep 23, 2010 1:30pm

    NNWebmaster

    43 posts

    I’ve been getting an increase in traffic recently and this has led to a serious performance hit to my database server. Rackspace has come back with a reason in that using mysql_pconnect is causing Apache to max out its connections. The limit for Apache has been increased but I’m wondering if there’s a more permanent solution. The identified this code segment as the source of the problem:

    function db_connect($select_db = TRUE)
        {    
            $this->conn_id = ($this->conntype == 0) ?
              @mysql_connect ($this->hostname, $this->username, $this->password):
              @mysql_pconnect($this->hostname, $this->username, $this->password);
            
            if ( ! $this->conn_id)
            {            
                return FALSE;        
            }
            
            if ($select_db == TRUE)
            {
                if ( ! $this->select_db())
                {
                    return FALSE;    
                }
            }
            
            $this->server_info = @mysql_get_server_info();
            
            return TRUE;
        }

    They’re also suggesting that I change mysql_pconnect to mysql_connect but I see it there already. What’s the best approach to this?

  • #2 / Sep 23, 2010 1:42pm

    NNWebmaster

    43 posts

    Looking through that file I see this line in the variable declaration:

    var $conntype           = 1;            // 1 = persistent.  0 = non

    Would it be ok to change this to 0?

  • #3 / Sep 23, 2010 4:44pm

    Ingmar

    29245 posts

    Yes, definitely. The default is to use non-persistent connections; this should work well.

  • #4 / Mar 18, 2011 12:16pm

    Sorry the above still does not fix the issue.

    Even with non-persistent connections the site can not handle more than 1 connection per second.

    From using MySQL Workbench, It seems there are too many queries being run from a single page!

  • #5 / Mar 18, 2011 12:22pm

    NNWebmaster

    43 posts

    Thanks for the advice.

    We’re actually in the process of moving to a load balanced environment with a database cluster which should help us out a great deal. Ideally I would have preferred a cloud environment but I don’t make those decisions. 😊

  • #6 / Mar 19, 2011 5:05pm

    Greg Salt

    3988 posts

    Hi Andy,

    Thanks for the update. Are you ok with us closing this thread now?

    Cheers

    Greg

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases