Persistent connections

resource mysqli_connect ( [string server [, string username [, string password [, string database_name [, int port_number [, string socket]]]]]])

Switching to persistent connections in MySQL is simply a matter of changing your call mysqli_connect() so that the host name starts with "p:". For example, "p:localhost". The difference between the two is that standard connections will always open a new connection, whereas persistent connections will only open a new connection if there is not one already available.

Author's Note: In the per-process Apache module ("prefork"), persistent resources such as persistent MySQL connections are stored per process, which means if you have 150 Apache children running you'll need 150 MySQL permanent connections - even if some of those processes aren't using MySQL right now.

 

Next chapter: Choosing a table type >>

Previous chapter: When MySQL knows best

Jump to:

 

Home: Table of Contents

Copyright ©2015 Paul Hudson. Follow me: @twostraws.