Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

During website operation, in mysql process list, I see a couple of processes with the "command" column marked as "SLEEP".

Should I worry? How to stop this?

share|improve this question

Even the most powerful ones of us need to sleep sometimes. Without sleep one becames anxious and insomnia can lead to all kinds of serious symptoms.

More seriously: sleep state means that MySQL process has done with its query, but the client-side did not yet exit. Many web applications don't clean up their connections afterwards, which leads to sleeping MySQL processes. Don't worry if there are only handful of them; MySQL will clean up those after a configurable timeout period (wait_timeout).

Or if your web application uses persistent connections and connection pooling, then it's perfectly normal to have even lots of sleeping processes: in that case your application just opens up for example 100 SQL connections and keeps them open. That reduces connection opening/closing overhead. Unless your application is a very busy one, it's normal that not nearly every SQL process has something to do, so they sleep.

share|improve this answer

No, don't worry about them unless you have thousands of them. Usually they indicate a database connection that is currently not doing anything, but otherwise still alive.

Many websites are built such that at the beginning of processing a page, a database connection is opened, then used throughout the generation of the page and finally discarded at the end. If the discarding is done properly, the database connection is closed and the server will then kill the relevant thread, which means this connection disappears from the process list.

If the connection is not closed, it may remain in "SLEEP" state until it times out. In that case you may end up with lots of sleeping processes. but unless you run into memory issues on the db server, this isn't a big problem either.

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.