yahoo / mysql_perf_analyzer

MySQL performance monitoring and analysis.
Apache License 2.0
1.44k stars 214 forks source link

multiple connections from monitoring user #19

Closed devalias closed 9 years ago

devalias commented 9 years ago

Hi, a engineer noticed 31 connections for about 8 seconds, then the threads go into sleep mode. Why is that and can we limit the amount of connections?

xrao commented 9 years ago

If you have several users using Top screen at the same time to check the same database server, that is possible. To fetch data as fast as possible, Top will send out queries concurrently. But that is still only two connections (one for global status, one for repl lag). Few UI functions might send out queries concurrently, too. Metrics scanner and alert scanner only run as you schedule, with each use one connection. Since it is not designed as consumer faced application, and it does not expect a large user base per installation, there is no connection sharing among sessions.

devalias commented 9 years ago

thanks Xrao, I will continue to investigate, user stated that the monitoring user started 31 threads for about 8 seconds then they went to sleep.

 On Thursday, July 23, 2015 6:31 PM, xrao <notifications@github.com> wrote:

If you have several users using Top screen at the same time to check the same database server, that is possible. To fetch data as fast as possible, Top will send out queries concurrently. But that is still only two connections (one for global status, one for repl lag). Few UI functions might send out queries concurrently, too. Metrics scanner and alert scanner only run as you schedule, with each use one connection. Since it is not designed as consumer faced application, and it does not expect a large user base per installation, there is no connection sharing among sessions.— Reply to this email directly or view it on GitHub.

devalias commented 9 years ago

Hi Xrao, so I had a chance to look with mytop and this is happening:

   Id      User         Host/IP         DB       Time    Cmd    State Query                                                                                                                                                       
   --      ----         -------         --       ----    ---    ----- ----------                                                                                                                                                  

193825 repl 10.25.3.93 9365652 Binlog Master h
394615 repl 10.25.3.94 29058 Binlog Master h
396566 monuser 10.25.3.3 informatio 28 Sleep
396567 monuser 10.25.3.3 informatio 27 Sleep
396568 monuser 10.25.3.3 informatio 27 Sleep
396569 monuser 10.25.3.3 informatio 27 Sleep
396570 monuser 10.25.3.3 informatio 27 Sleep
396571 monuser 10.25.3.3 informatio 27 Sleep
396572 monuser 10.25.3.3 informatio 27 Sleep
396573 monuser 10.25.3.3 informatio 27 Sleep
396574 monuser 10.25.3.3 informatio 26 Sleep
396575 monuser 10.25.3.3 informatio 26 Sleep
396576 monuser 10.25.3.3 informatio 26 Sleep
396577 monuser 10.25.3.3 informatio 26 Sleep
396578 monuser 10.25.3.3 informatio 26 Sleep
396579 monuser 10.25.3.3 informatio 25 Sleep
396580 monuser 10.25.3.3 informatio 25 Sleep
396581 monuser 10.25.3.3 informatio 25 Sleep
396582 monuser 10.25.3.3 informatio 25 Sleep
396583 monuser 10.25.3.3 informatio 25 Sleep
396584 monuser 10.25.3.3 informatio 25 Sleep
396585 monuser 10.25.3.3 informatio 25 Sleep
396586 monuser 10.25.3.3 informatio 25 Sleep
396587 monuser 10.25.3.3 informatio 24 Sleep
396588 monuser 10.25.3.3 informatio 24 Sleep
can you change the monitor user to not keep threads open?

xrao commented 9 years ago

I am curious how many end users are targeting the same database at the same time? From my experience, a single user session rarely has more than two connections to the same DB opening at the same time. By design, I try to reuse the connections inside the same user session, and all the connections will be closed when user sessions timed out. I am not a fan of "open a connection, use it once and close it". But if this is a desired feature, I will consider to add a configuration parameter to allow you to control it.

xrao commented 9 years ago

Updated. Please use Setting page, uncheck "Reuse Monitor User Connections?", then click Submit. No need to restart scanner since no scanner related info changes. However, this is not really a recommended feature.

devalias commented 9 years ago

Thanks Xrao, will test this out.

devalias commented 9 years ago

Updated and ran some tests, only see 1 connection created now, looks good. Thanks for the quick response/update.