Why is my threads_connected ALWAYS = 1? I run a website with fairly high traffic. I've been having a lot of issues lately with "too many connections" or "could not connect" to MySQL and I think it's because of bots but I'm not 100% positive. I connect to the database using one username. So anyone who visits the site connects with the same script (and MySQL user).

If I have 1,000 people on the site at one time and I show processlist, the threads_connected is always 1. Is that normal? Could this be the cause of the too many connections issue? 

The strange thing is, I can have 20,000 people on the site and it runs fine. But MySQL has been crashing a lot lately with an average of 200 people on the site - which my Amazon instance can EASILY handle. And there are always bots in the access_log when it goes down. I have tried so many things to stop MySQL from crashing and nothing is working.
There are two different issues -- threads connected and threads running.

In a typical, well oiled, production server, you will see this in SHOW PROCESSLIST:


Lots of "Sleep" connections,
Fewer than max_connections lines in the processlist,
One, or a small number, of non-Sleep connections.
Most queries are so fast that they go back to Sleep before you notice it.  I often see "thousands of Queries per second", yet "nothing running".  This is good.


"Sleep" means that the connection is not running a query at the moment.  Instead it might be doing application processing, or it might be part of a "connection pool".

The reason you always see "1" is that you have to run a query (SHOW PROCESSLIST or something else) to get the number.  So the "1" is itself.

You said Threads_connected is always 1.  Did you mean Threads_running?  Note also the capitalization.

What is the value of thread_cache_size?  8 is typical, but the exact value does not matter a lot.

What about Max_used_connections and max_connections?

Is there any sort of "connection pooling"?  Are there multiple clients?

Consider providing me with the info mentioned in tuning here .