Daniel Higginbotham's adventures in making stuff

Announcing Palmist

14 May 2008

A Handy Tool for Finding and Fixing MySQL Bottlenecks

Purpose: Help find and fix mysql bottlenecks in Ruby on Rails

Example (click to enlarge)

example

Features

  • Make it easy to work on one request at a time
  • Highlight duplicate queries
  • Show the time each query takes and total db time
  • Link to EXPLAIN
  • List general MySQL optimization tips

Example Workflow

  • Every night I get an email from pl_analyze showing which requests are taking the most time in the database on designerpages.com ’s production server
  • Locally, I start Designer Pages in development mode
  • I also start Palmist, making sure it’s configured to analzye Designer Page’s development log (note that you might want to run your web app in production mode because the MySQL behavior will be slightly different)
  • Locally, I navigate to the Designer Pages page which is spending a lot of time in the database
  • In Palmist, I “refresh” so that I can see that latest analysis of the page I just visited in Designer Pages
  • As I make changes to Designer Pages, I refresh Palmist to see what effect the changes have

Installation

  • Follow the instructions at "http://nubyonrails.com/articles/a-hodel-3000-compliant-logger-for-the-rest-of-us ":http://nubyonrails.com/articles/a-hodel-3000-compliant-logger-for-the-rest-of-us to install a Hodel-3000 compliant logger on the site you want to examine
  • sudo gem install ruby-debug
  • git clone git://github.com/flyingma/palmist.git
  • cd palmist
  • Copy config/config.example.yml to config/config.yml (cp config/config.example.yml config/config.yml)
  • Modify config/config.yml and config/database.yml and create your database
  • Clear the log files you want to analyze if they’re huge and you don’t want palmist to take forever analyzing them
  • rake db:migrate
    • This will analyze the log of the site you specified in config.yml
    • The migration assumes that palmist’s database uses mysql
    • ./script/start_3001 to start Palmist on port 3001 in dev mode
    • To use palmist after clearing your log files, you should run rake remigrate

Mad props to Eric Hodel.

Comments