Projects/Cloudstone/Debugging Olio

From RAD Lab

Jump to: navigation, search

For the most part, you won't need an entire Cloudstone cluster to debug Olio. Therefore, you can run Olio locally and debug it like any other Rails application.

Contents

Requirements

  • MySQL 5.1
  • Rails 2.1.2
    • MySQL Gem
  • Subversion

Instructions

Deploying Olio Locally

  1. Checkout Olio from the repository: svn co http://svn.apache.org/repos/asf/incubator/olio/tags/0.1-final/webapp/rails/trunk/ olio
  2. Change to the Olio directory: cd olio
  3. Instantiate a database configuration file: cp config/database.yml.template config/database.yml
  4. Change the database configuration (e.g. change username to root and remove password: mate config/database.yml
  5. Create the database: rake db:create
  6. Load the database schema: rake db:migrate
  7. Enforce the version of Rails used:
    1. mate config/environment.rb
    2. Uncomment line 25: RAILS_GEM_VERSION = '2.1.2' unless defined? RAILS_GEM_VERSION
  8. Start the development server: script/server (On Windows: ruby script/server)
  9. Point your browser to: http://localhost:3000/
  10. Check Known Issues below for additional steps you may need to run Olio smoothly.

Populating the Local Database

In order to debug anything performance-related, you will probably need a populated Rails application database. To do so, we will dump the data generated by the Faban workload and load it into our local database. There are two ways to obtain the dump file:

  • Obtain an existing MySQL dump from Amazon S3:
    1. Install (and configure) s3cmd or log in to an existing Cloudstone instance.
    2. Get the dump file: s3cmd get s3://radlab-cloudstone/mysql-dump-5k.tar.bz2
      • Download to your local machine, if necessary (i.e. if you used an existing Cloudstone instance to obtain the dump).
      • Naming schema of S3 dumps: database-dump-size.tar.bz2
    3. Decompress the file: tar xjf mysql-dump-5k.tar.bz2
  • Create a new MySQL dump using Faban.
    1. Deploy a cluster for Cloudstone.
    2. Schedule a run with the desired number of concurrent users (e.g. 50).
    3. Log into the database server.
    4. Dump the database data: mysqldump --quick --compact --add-drop-table olio > database-dump-size.sql
    5. Compress the dump: tar cjf database-dump-size.tar.bz2 database-dump-size.sql
    6. Download to your local machine (and optionally store it on S3: s3cmd put database-dump-size.tar.bz2 s3://radlab-cloudstone/database-dump-size.tar.bz2).
    7. Decompress the file: tar xjf database-dump-size.tar.bz2

Once you have the dump file, load it into your local database: mysql -u root olio < mysql-dump-5k.sql

Revision History

Changes to the Olio codebase are not necessarily committed to the main branch of Olio. This list will maintain the list of revisions to optimize Olio.

  1. Optimized Tagcount#tags_count in lib/tagcount.rb.
    • Changed the query generation to avoid excess table scans.
    • Improved response time of home page. Query time reduced from 1.53s to 0.018s.
  2. Added an indexed counter_cache to Tag.
    • Modified vendor/plugins/acts_as_taggable/lib/tagging.rb to add counter_cache => true.
    • Added migration 20090713225055_add_counter_cache_to_tags.rb to add taggings_count column.
    • Improved query time from 0.018s to 0.00037s.
    • Changed Tag.java in Workload to support loading the count column.

Known Issues

  • Mac OS X has issues installing the MySQL gem with the default settings.
    • sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include [1]
  • Rails logs: ActionController::RoutingError (No route matches "/uploaded_files/e1.jpg" with {:method=>:get}):
    • If you populate your database using a dump, you will not have the necessary uploaded files that Rails expects.
    • To fix this so that the error does not show up in the logs:
      1. Create the uploaded_files directory: mkdir public/uploaded_files
      2. Create a dummy image and its dummy thumbnail: touch null.jpg && touch nullt.jpg
      3. Change all images to point to the dummy file: mysql -u root -e "UPDATE images SET filename='null.jpg';" olio
  • Rails logs: Errno::ECONNREFUSED (Connection refused - connect(2)):
    • If you try to create a new user, Geolocation#initialize tries to contact the Geolocation server.
    • To prevent the error, modify app/models/geolocation.rb and add return after line 30.