Archive for March, 2011
How to gather statistics at regular intervals
I gather a lot of statistics such as performance data. Sometimes I have multiple things going on a system and I want to be able to align and compare the resulting data from multiple processes later. That means they need to be aligned on time intervals. Here is a naive way to gather stats at intervals:
while sleep 1; do gather-some-stats; done
There are two problems: each iteration will take longer than a second, so there will be drift; and the iterations will not be aligned exactly on the clock ticks, so the data isn’t as easy to correlate with other samples. This becomes a bigger problem when there are many such jobs gathering data at longer intervals such as 15 seconds or 5 minutes, where the lack of correlation between samples can be frustrating.
Here is what I’ve been doing recently. Is there a better way?
INTERVAL=1
while true; do
sleep=$(date +%s.%N | awk "{print $INTERVAL - (\$1 % $INTERVAL)}")
sleep $sleep
gather-some-stats
done
See you at Collaborate 2011
I’ll be speaking at IOUG’s Collaborate conference in Florida the week of April 10-14. My session is called MySQL Performance Basics. For those who know MySQL, this won’t be exciting, but if you’re new to it, I hope it will be a good orientation to what you should focus on and ignore.
Sheeri Cabral posted a good round-up of the MySQL talks at Collaborate on the PalominoDB blog.
No Hotsos? Go to the MySQL Conference instead.
I wish I could be at the Hotsos Symposium. I would keep my mouth very tightly closed and my ears wide open, and try to learn from people who are completely out of my league about performance analysis topics I won’t grok for another decade (if I’m lucky). But I just can’t cram in that much travel.
If you’re like me, why don’t you go to the O’Reilly MySQL Conference instead? I’ll be trying my feeble best to bring some of the Oracle performance scientist’s mentality to this event, with presentations such as my Forecasting MySQL Performance and Scalability session. And a lot of smart people will be there from many database communities. Percona has a 20% discount, too — not a bad enticement.





