I'm trying to optimize an application running a MySQL with the InnoDB storage engine.
When running innotop
in the live environment I get the following output:
When Load QPS Slow QCacheHit KCacheHit BpsIn BpsOut
Now 0.00 87.80 0 41.21% 100.00% 11.51k 836.42k
Total 0.00 105.50 190 15.04% 99.34% 13.23k 692.85k
When
, Load
, QPS
and Slow
are self-explanatory.
But what about QCac开发者_开发知识库heHit
, KCacheHit
, BpsIn
and BpsOut
? In general, what are considered "okay" values for those, and when should I start worrying?
Ratios are useless. Seriously. Just ignore them. http://www.mysqlperformanceblog.com/2010/02/28/why-you-should-ignore-mysqls-key-cache-hit-ratio/
Yeah, I'm the author of innotop. I put those features in so people would stop asking me to.
From the article:
Summary
Major points in this article:
- Counter ratios are meaningless as a performance analysis metric because they are a) ratios of b) counters.
- You need to look at absolute magnitude, not ratios.
- For performance analysis, you need to measure elapsed time, not just the number of times something happens.
- In the absence of timing information, and if you trust the cache’s creator and assume that misses are more expensive than hits, then you care about cache misses, not cache hits.
- A Key_read is not guaranteed to be a random physical I/O, but it might be. Gather Key_reads/Uptime over 10-second or 60-second intervals and compare the results to your IO system’s capabilities.
- MySQL doesn’t have good instrumentation for scientifically choosing a key_buffer_size setting, but there are many unscientific approaches that are better than ratio-based tuning.
- Counter ratios suck for everything, not just for MyISAM tuning.
I’ve had some heated arguments over these points, so I don’t expect the above to pass without controversy. But really, it’s time to stop with the bad advice about counter ratios. The sooner we do that, the sooner we can move on to better things.
QCacheHit
is the percentage of the time that the query cache is hit. KCacheHit
is the percentage of the time that the innodb buffer pool is hit (similar to the key buffer). BpsIn
is the number of bytes coming in to your server, BpsOut
is the bytes out.
QCacheHit
should be relatively high, if you're using the query cache. Your rates seem low. KCacheHit
should also be relatively high, and you're in good shape.
BpsIn/Out
don't really matter, unless you're trying to optimize the amount of data being sent/received by your server.
精彩评论