default php.ini mysql.allow_persistent

Discussion in 'PHP' started by sofatime, Jul 20, 2006.

  1. sofatime

    sofatime Well-Known Member

    I noticed that in the default php.ini for lsws mysql.allow_persistent is Off. I understand that this should be off if you are using CGI for PHP, because those processes die anyway, but wouldn't it be better to turn this On for lsphp? As the php process stays up anyway and could reuse the connections to mysql?

    Thanks for info
  2. mistwang

    mistwang LiteSpeed Staff

    Sometimes, a persistent mysql connection may hang PHP process and causes various trouble. So we recommend turning it off. You can turn it on if you want to.
  3. xing

    xing LiteSpeed Staff

    Generally LiteSpeed packages will include very "conservative" configurations.

    Persistent mysql connection from php has always been a problem with large scale operations in the past so we will play it safe. Users are more than welcome to performance-tune their php.ini to the max. Let us know how well it works with your setup and traffic level.
  4. xing

    xing LiteSpeed Staff

    We have performed reliability testing with PDO and mysql persistent connection enabled in the last few days and the results are not good and re-affirms the fact that users should not enable mysql persistent connection under high volume situations.

    Please note persistent test is with PDO mysql module. Not with mysqli or mysql extension directly.
  5. sofatime

    sofatime Well-Known Member

    Thank you for the information. I will leave it off for now and try it later. I am quite new to PHP, but in our ColdFusion installation we only use persistent connections.
  6. xing

    xing LiteSpeed Staff

    I believe it was fine to use persistent connections in ColdFusion because of the very different way both engines connect to mysql.

    ColdFusion is basically a java engine using mysql's JDBC type4 driver. JDBC provides builtin connection pooling. When you use persistent connection, JDBC is able to manage dead connections.

    PHP mysql modules connectis to mysql server directly with no inbetween connection pooling ability.

    JDBC pooling method allows a more reliability operation when using persistent connections.
  7. xing

    xing LiteSpeed Staff

    One more note and regarding performance.

    Non-persistent php mysql connections can be just as fast as persistent conections provided your mysql server is tuned correctly:

    my.cnf: thread_cache = 16

    The thread_cache value in my.cnf must be configured to a value just high enough so when viewing statics, mysqladmin extended-status, "Threads_created" value does not increase during peak hours. Do not set it too high and suffer wasted cpu cycles.
  8. sofatime

    sofatime Well-Known Member

    Ok, thanks, I have configured that setting and will see how it performs.

Share This Page