Permanent CodeIgniter connection to multiple databases?

I use several databases in the CodeIgniter application and read a lot that persistent connections should be disconnected .

Why is this measure recommended, and is it still necessary in the newest version, 2.0.2?

I do things like

$db2 = $this->load->database("dbname", TRUE); 
+7
source share
1 answer

Code ignition documentation does not explain

Unfortunately, the Code Igniter documentation for 2.0.2 does not explain why they should be disabled. He simply explains that there is a setting for this. The rationale for this is most likely due to the fact that this is actually not the Code Igniter functionality, but the more functional PHP / MySQL functionality. PHP contains a very nice and detailed page in its documentation on persistent connections.

Explanation from the server administrator (me)

Basically, it comes down to performance. If you have a small number of users who are in California and your MySQL database server is in Switzerland, there will be significant overhead for connecting to a MySQL server (compared to connecting to MySQL on the same server in California). Having a persistent connection will prevent the overhead of reconnecting every time you want to look at something in MySQL. There are also many other problems that can cause connection failures, for example, how the server or database is configured. In addition to performance, it can also cause problems if the connection does not close properly, resulting in locked tables.

Why is it recommended to disable

The reason this setting is not suitable for most servers is that if you have more than 60 users using your database at the same time or that your MySQL configuration is set to the maximum number of connections, you will quickly reach the maximum number of connections . and this can lead to database errors or server crashes, etc.

+1
source

All Articles