PHP Persistent Connections Causing MySQL Load
PHP persistent connections cause a high load on your MySQL database. For small Web applications, the load is not substantial. For busy websites, the load can cause timeout errors and memory issues on the database server. To alleviate the high memory usage, you add the "mysql_close" function to the end of PHP pages that do not need the open MySQL connection. The function closes a persistent connection, freeing memory on pages that do not need database resources.
Instructions
-
-
1
Right-click on a PHP page that does not need the MySQL resources. Click "Open With" and select your PHP editor.
-
2
Search the site to find any MySQL queries. If you add the close function to a page that uses MySQL, your site will return an error when users open the page. For this reason, you must review the page for any MySQL queries before adding the close function.
-
-
3
Add the following function to your page to close the MySQL connection and free up resources on your server:
mysql_close();
-
4
Repeat these steps for each PHP page on your site. After you finish adding the close function, upload the pages to your site.
-
1