List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:September 28 2003 1:54am
Subject:Re: # processes vs. #threads, and memory usage (Revisited for thread cache)
View as plain text  
In the last episode (Sep 27), Kevin said:
> Bringing this back up again, because the number of extra 'threads'
> mysql is using seems to vary widely, from I've noticed sometimes,
> from 5 more than the threads I'm using to more than 50!
> 
> My memory usage also seems to differ accordingly.
> 
> It seems to be because my thread cache is set to 40, so 'mytop' shows
> 38 threads cached, with only 20 connected right now.  Shouldn't it
> kill off those threads after awhile?
> 
> Is that what the wait_timeout field is for?  I thought it was for
> keeping the connection open, rather than the connection cached.  Mine
> is currently at '600', and it doesn't seem to be clearing up the
> cache...

Idle threads should take up almost no RAM (thread_stack plus a little
bit of overhead), so there should be no need to kill them.  If you're
swapping, add more RAM, or reduce mysql's memory usage by reducing its
buffer sizes (check the manual for which ones are used when).

wait_timeout is how long before an idle client connection is
terminated.  If the total thread count is greater than thread_cache,
the thread exits too.
 
> The reason this is important is because I suspect my 'slow queries'
> comes up when I run out of ram and it starts using disk swap - which
> happens because mysql is taking up so much extra memory.

Well, that's easy enough to test; just watch vmstat output during a
query.  If you are swapping, either reduce the global cache settings
(key_buffer, query_cache_size, or one of the many innodb_*_size
variables), or the per-query settings (sort_buffer, tmp_table_size,
join_buffer_size, etc).  RAM is cheap too.

-- 
	Dan Nelson
	dnelson@stripped
Thread
Noob Question: Error 1046Charlie Brewer25 Sep
  • Re: Noob Question: Error 1046Hassan Schroeder25 Sep
  • # processes vs. #threads, and memory usageKevin25 Sep
    • Re: # processes vs. #threads, and memory usageLenz Grimmer25 Sep
      • RE: # processes vs. #threads, and memory usage (Revisited for thread cache)Kevin28 Sep
        • Re: # processes vs. #threads, and memory usage (Revisited for thread cache)Dan Nelson28 Sep
          • slow 'sending data' phaseKevin29 Sep
        • install script errorsJon Hancock29 Sep
        • Authenticationketvin29 Sep
          • Re: AuthenticationVictoria Reznichenko29 Sep
        • Re: AuthenticationDirector General: NEFACOMP29 Sep
        • How to backup MySQL databasee?florence florence31 Dec
    • Re: # processes vs. #threads, and memory usageJeremy Zawodny25 Sep
  • Re: Noob Question: Error 1046Director General: NEFACOMP26 Sep
Re: Noob Question: Error 1046Charlie Brewer25 Sep
RE: How to backup MySQL databasee?Ugo Bellavance31 Dec