default php.ini mysql.allow_persistent

sofatime

Well-Known Member
#1
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
Daniel
 

mistwang

LiteSpeed Staff
#2
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.
 

xing

LiteSpeed Staff
#3
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.
 

xing

LiteSpeed Staff
#4
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.
 

sofatime

Well-Known Member
#5
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.
 

xing

LiteSpeed Staff
#6
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.
 

xing

LiteSpeed Staff
#7
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.
 
Top