So you’re running the benchmark/stress test – how do you tell if MySQL server is really loaded ? This looks like the trivial question but in fact, especially when workload consists of simple queries I see the load generation and network really putting a lot less load on MySQL than expected. For example you may have 32 threads (or processes) running queries as fast as they can… does it really mean there is an 32 concurrent queries ran all the time ? It may be the case or it may be not…

Take a look at this server for example:

This corresponds to what is expected to be stress load but we can see MySQL is getting only spikes of concurrent query executions and most commonly there are no queries executing. Value 1 for Threads_running corresponds to the connection which runs “SHOW STATUS” so you need to subscribe 1 from the reported amount to see the true number. No wonder in the case above there were a lot of free CPU and IO capacity.

Take a look at another sample:

In this case the load is higher and a lot more uniform – there are cases when actually 32 queries are active (this is test with 32 connections) – but you can see most of the time it is less than that.

Looking at Threads_running is a very simple and powerful tool to see whenever you’re really putting sustained load on the database you may be expecting.

It may be worth to explain what value of Threads_running represents. This is amount of queries which are being currently processing – the ball is on Server side. The server has gotten the query but has not completed sending response back yet. This is a very broad measure of activity – if query is waiting on IO, blocked on Mutex, table lock, row level lock, waiting on innodb_thread_concurrency it will be still considered running. This will be even the case when result of large query is being sent back and send operation is blocked because of slow network or the client. Because the measure is so broad it is very helpful to see if client is loading the server well – if it does the number of threads_running will be appropriately high.

7 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Any idea what “-1” as a Threads_running value could mean?

Deep

Hi,

I’m not sure about this, but my problem is that I only see Threads_running=1 in my Show Status. Is it okay or sth wrong with my settings.

I did some search and found this is okay as per these links

http://www.experts-exchange.com/Database/MySQL/Q_21497745.html

But how come you can see threads running more than 1

Thanx for your time

Regards,
Deep

arun

Deep,

you possibly do not have any non-sleeping threads (except the show slave status thread).

thanks.

Simon J Mudd

Also look at this bug report I made recently: http://bugs.mysql.com/bug.php?id=68963, as I have had issue with not seeing the wood for the trees so to speak because of a high number of running slaves on the server.

Vitaly

I see more threads_running on my MySQL 5.5 server recently (100 instead of 10-20).
All other metrics [slow queries, locks, innodb row operations, end2end system performance …] seem in line with previous period.

Should we check something else? just raise monitoring threshold?

thank you
Vitaly