[Mod_log_sql] High number of MySQL threads when using mod_log_sql

Thomas Goirand thomas at goirand.fr
Wed Feb 29 23:19:37 EST 2012


Hi,

FYI, I'm the Debian maintainer for the mod_log_sql package, and I've
been using it for many, many years on all of my servers (I'm tempted to
say a decade, but I'm not sure that's right).

On 02/29/2012 05:47 PM, Robert Krig wrote:
> The one webserver I have logging to MySQL gets about 30-50 hits per 
> second. And already this is causing about 150-200 MySQL server threads.

Frankly, I don't see why this should be worrisome.

On 02/29/2012 05:47 PM, Robert Krig wrote:
> Is it normal for mod_log_sql to be using so many MySQL threads?

Yes, for each apache thread, there's a MySQL connection being made.

On 02/29/2012 05:47 PM, Robert Krig wrote:
> Is there a way I could optimise this?

If by optimize, you mean connecting to MySQL when an apache thread needs
to log something, then immediately after, disconnect, then you'd be
slowing down things. The way things are done right now really *is* the
optimized way.

On 02/29/2012 05:47 PM, Robert Krig wrote:
> I don't know if its gonna cause problems if MySQL has so many threads
> open.

It is *not* a problem. Just make sure that the max_connection directive
in your MySQL server is set to a high number. The default (100
connections) really is too low, and should be increased to something
like 500 or 1000. My experience shows that 500 MySQL connections isn't
an issue anyway.

I hope that helps.

Thomas


More information about the Mod_log_sql mailing list