there's only one client application running queries against a MySQL instance.
After enabling MySQL's general query log (configured to log every query) I noticed that every query starts with a "Connect".
Does this imply connection pooling isn't working?
Thx, Christian.
Edit1:
DB is accessed by PHP application (SugarCRM). It's configured to use persistent connections.
> egrep connections /var/www/html/sugarcrm/config.php
'disable_persistent_connections' => 'false',
> egrep -A7 dbconfigoption /var/www/html/sugarcrm/config.php
'dbconfigoption' =>
array (
'persistent' => true,
'autofree' => false,
'debug' => 0,
'ssl' => false,
'collation' => 'utf8_general_ci',
),
Main Question (not trying to solve it at the moment, just want to understand): If in the log every query starts with a "Connect" - does this then imply that no persistent connections are used?
1 Answer 1
Three aspects must be considered
ASPECT #1 : PHP
PHP has a setting for Persistent Connections
[MySQL]
; Allow or prevent persistent links.
mysql.allow_persistent=On
Make sure this is on in php.ini
if you want to use Persistent Connections
ASPECT #2 : Your Code
Since mysql_pconnect is deprecated, make sure you are using one of the following
- mysqli-connect with
p:
before the host name - PDO::__construct() with
PDO::ATTR_PERSISTENT
as a driver option
ASPECT #3 : MySQL
When mysqld sees a connection attempt, it records it statistically as one of the following
- Connections : Connections Attempts (Successful or Not)
- Aborted_connects : Failed Connection Attempts
If the general log is echoing just the word Connect as an event, chances are that's just a Connection attempt. Any subsequent events on that connection would be operating on a established thread (DB Connection). The general log will not tell you whether the DB Connection is newly created or already established.
To actually know if the connections are coming and going, you should monitor
- Threads_connected : The number of currently open connections
- Threads_created : The number of threads created to handle connections
To actually see them in a single query, please run this
SELECT * FROM information_schema.global_status WHERE variable_name IN
('Connections','Aborted_connects','Threads_connected','Threads_created');
-
What should be done to ensure resources are released when the processing is completed for this active connection?Wilson Hauck– Wilson Hauck2019年07月27日 11:45:45 +00:00Commented Jul 27, 2019 at 11:45
-
@WilsonHauck See my old post "Why decrease the wait_timeout configuration parameter in MySQL?" dba.stackexchange.com/questions/41585/…RolandoMySQLDBA– RolandoMySQLDBA2019年07月27日 18:34:59 +00:00Commented Jul 27, 2019 at 18:34
Explore related questions
See similar questions with these tags.