1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Option 'persistent' in config of database

Discussion in 'General XenForo Discussion and Feedback' started by infis, Oct 29, 2011.

  1. infis

    infis Well-Known Member

    Why the option $config [' db] [' persistent '] is not used?
    Any problems are connected with it or have simply forgotten it to add in a code?

    Version 1.0.4 library/Xenforo/Application.php
    PHP:
        public function loadDb(Zend_Config $dbConfig)
        {
            
    $db Zend_Db::factory($dbConfig->adapter,
                array(
                    
    'host' => $dbConfig->host,
                    
    'port' => $dbConfig->port,
                    
    'username' => $dbConfig->username,
                    
    'password' => $dbConfig->password,
                    
    'dbname' => $dbConfig->dbname,
                    
    'charset' => 'utf8'
                
    )
            );
    Version 1.1.0 Beta 4 library/Xenforo/Application.php
    PHP:
        public function loadDb(Zend_Config $dbConfig)
        {
            
    $db Zend_Db::factory($dbConfig->adapter,
                array(
                    
    'host' => $dbConfig->host,
                    
    'port' => $dbConfig->port,
                    
    'username' => $dbConfig->username,
                    
    'password' => $dbConfig->password,
                    
    'dbname' => $dbConfig->dbname,
                    
    'adapterNamespace' => $dbConfig->adapterNamespace,
                    
    'charset' => 'utf8'
                
    )
            );
    Also what for an option adapterNamespace?
     
    Darkimmortal likes this.
  2. Floris

    Floris Guest

    Sites with 5 to up to 100 users online on a shared hosting or better that support 100 persistent connections could perhaps use this. Everything above that or else doesn't want to use it.

    I can not imagine a reason why anybody wants to use persistent connections. MySQL is made to support quick connects/disconnects quickly enough, and most web applications don't use them because of the amount of traffic they're getting. It only creates overhead. The cons outweigh the pros in my opinion.

    Plus, every Apache child proc will get a persistent connection, on a somewhat busy box (especially on shared hosting) you end up with overwhelming MySQL and running into errors.

    I guess the one benefit of pc is that when you open the connection, and as long as it remains in scope, you can run multiple queries, in my opinion not something useful to a web app such as a forum.
     
  3. Luke F

    Luke F Well-Known Member

    Persistent connections work great in PHP-FPM setups
     
  4. Mike

    Mike XenForo Developer Staff Member

    Persistent connections aren't implemented like that in MySQLi: http://php.net/manual/en/mysqli.persistconns.php

    Zend_Db doesn't actually use the persistent flag anyway. So you just need to adjust your host name if it's supported by your PHP (eg, p:localhost).
     
  5. infis

    infis Well-Known Member

    Why you consider only the shared hosting? Own servers are now quite popular VPS and VDS, and also.
    MySQL on one server with a site and on different - not same. And in real life there are many hosters giving a site and the server of a database, located physically on different computers.
    I think, what it is not necessary to explain, what such work through Unix sockets and through TCP?
    I have initially raised the question not about expediency, and about absence of possibility of use of persistent connections.
    I.e. me interested more, whether it is connected with what that errors or it have simply forgotten to add a class code.

    The expediency of use of this option, certainly, depends on concrete conditions. In most cases, by the way, this option allows to reduce time of generation of page. Probably, not in a case with xenForo.
     
  6. infis

    infis Well-Known Member

    I use PHP 5.2 and flag "p:" is not working.
    Code:
    An exception occurred: Unknown MySQL server host 'p:localhost' (1) in /xxxxxxxx/library/Zend/Db/Adapter/Mysqli.php on line 333
    
        Zend_Db_Adapter_Mysqli->_connect() in Zend/Db/Adapter/Abstract.php at line 315
        Zend_Db_Adapter_Abstract->getConnection() in XenForo/Application.php at line 550
        XenForo_Application->loadDb()
        call_user_func_array() in XenForo/Application.php at line 777
        XenForo_Application->lazyLoad() in XenForo/Application.php at line 807
        XenForo_Application::get() in XenForo/Application.php at line 1056
        XenForo_Application::getDb() in XenForo/Error.php at line 47
        XenForo_Error::unexpectedException() in XenForo/Application.php at line 295
        XenForo_Application::handleException()
    
     
  7. Floris

    Floris Guest

    I actually advise everybody to NOT use shared hosting. So I completely agree with you
    But used shared hosting as example where people run into persistent connection max reached, etc.
     
  8. Mike

    Mike XenForo Developer Staff Member

    That's why I linked to that manual page:
    I don't mean this in a condescending way, but if you're not running PHP 5.3 (with an opcode cache) then it's not really worth pursuing other micro-optimizations -- you will see bigger speedups from upgrading to 5.3 (and PHP 5.2 is deprecated now as well).
     
  9. infis

    infis Well-Known Member

    Yes, it is difficult to disagree with it.
    Unfortunately, not always it is possible to use that would be desirable. On the new server at me costs 5.3, and here on old - 5.2.
    Well. It is not critical, and the thread can be closed.

    It would be good, that the information on distinctions in version PHP and in work xenForo would be accessible at a stage of a choice of the forum engine. That is, it is necessary to inform on it in results of work of a script of check of conformity to requirements of the forum engine. There (in a script) it is necessary to add and check PHP extension imagick, by the way :)
     

Share This Page