Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to find out the memory cost of each mysql process. Right now, I have 800+ mysql connections but I have no idea when will the system start swapping. I use FreeBSD.

share|improve this question

The amount of memory consumed by each connection is variable, depending on what queries you're running, the size of result sets, and probably the phase of the moon. You'll want to measure current memory usage, and (assuming a bunch here) extrapolate from the current average memory usage of a connection to work out how many connections you can get.

The problem with this method is that memory may not be your limiting factor -- query contention, disk IO, or whatever could kill you before you start swapping.

share|improve this answer

You can determine the maximum memory cost per-connection to the server fairly easily from your configuration variables.

Obtaining your actual memory usage per-connection is unfortunately a lot more difficult because of the way in which mysqld threads.

share|improve this answer

Another good tool that I use for understanding/configuring how mysql uses memory is mysqlreport.

share|improve this answer

use to show you report

-------- Performance Metrics -----------------------------------------------
[--] Total buffers: 168.0M global + 2.8M per thread (10 max threads)
[OK] Maximum reached memory usage: 179.0M (18.04% of installed RAM)
[OK] Maximum possible memory usage: 195.5M (19.70% of installed RAM)

2.8M is my every thread memory costs including connection and 195.5M is total costs

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.