MySQL: No. of Connections

connectionsMySQL

I have a medium sized database (7 GB) with around 200 concurrent users. I am getting some database lag issues, suddenly my node-mysql client freezes during selects and inserts.

As a process of troubleshooting I checked SHOW STATUS on the DB. Everything seemed to be okay, but the connections attribute has a value of 262050.

I want to understand if this number is okay or if the figure is exorbitant?

Best Answer

Server Status Variables

Connections

The number of connection attempts (successful or not) to the MySQL server.

I.e. it is a counter which can increase only. Each attempt to connect to server, both successful and falling, increase it. Each connection, both existing and already broken, is taken into account. So this variable value can be used only for to calculate the average number of connections per some time period.

Threads_connected

The number of currently open connections.

It is the amount of real external connections in any state. Do not include inner server services connections (sheduler connection, for example).

Threads_running

The number of threads that are not sleeping.

It is the amount of real connections not in sleeping state, including inner server services connections (sheduler connection, for example).

You can see a correlation between last 2 variables while compare the output of the commands

SHOW GLOBAL STATUS 
    WHERE Variable_name IN ( /* 'Connections', */
                            'Threads_connected',
                            'Threads_running');

and

SHOW PROCESSLIST;