According to blog of Damien Cooke and Tom Daly, I setup the Regperf test for Ruby on Rails to comparing ruby 1.8.6 with darryl's ruby for database accessing. The genre of applications that Regperf belongs to is usually used for very simple, one or more table, applications to Create/Read/Update/Delete simple data for a particular purpose.
1) sun studio is ready on solaris
2) ruby 1.8.6 is ready on solaris
3) postgres 8.2 is ready on solaris
Step 1, Install the database
1. We will add a new user "regperf" to run the whole test.
# useradd -m -d /export/regperf -s /usr/bin/bash regperf
# su - regperf
2. creates a new PostgreSQL database cluster on /export/regperf/data.
-bash-3.2$ initdb -D ./data
3. The database server can be started by following two commands (just choose one).
-bash-3.2$ postmaster -D ./data
-bash-3.2$ pg_ctl -D ./data -l logfile start
4. Setup the postgres database, the Sample Database is got from Damien's blog.
4.1) create regperf user.
-bash-3.2$ createuser damien
-bash-3.2$ createuser postgres
4.2) create a database called regperf.
-bash-3.2$ createdb regperf
4.3) import the database, most of the errors can be ignored.
-bash-3.2$ pg_restore -d regperf regperfdb.tar
5. using psql to check the detail info of database.
-bash-3.2$ psql regperf
listing tables ---- regperf=# \\dt
listing items ---- regperf=# select \* from subscriptions;
6. If you want to use remote client to access postgres server, set the following files and then restart the server.
For example: listen_addresses= '\*'
- add listen address to data/postgresql.conf
For example: host all all 126.96.36.199/32 trust
- add host to data/pg_hba.conf
- restart server by "postmaster -D ./data"
Step 2, Setup Rails Application
1. gems install
1.1 install rails 1.2.3 and related gems.
1.2 install ruby-postgres-0.7.1.2006.04.06 if you get any errors in installation, pay attention to the rbconfig.rb
on ruby/1.8/lib/ruby/1.8/sparc-solaris2.11, which initialize the environment for ruby.
The ruby-postgres-0.7.1.2006.04.06 is made by gcc, there're incompatible options for sun studio, so I install the gem manually.
- gem install ruby-postgres-0.7.1.2006.04.06
- cd /var/ruby/1.8/gem_home/gems/ruby-postgres-0.7.1.2006.04.06
- ruby extconf.rb --with-pgsql-dir=/usr/postgres/8.2
- Modify the Makefile created by ruby, remove the incompatible options such as -Wall
- make install
- checked by irb
irb(main):001:0> require 'postgres'
1.3 you can get more detail info by install mongrel related gems.
2. Download and start the Application(regperf-j1.tar).
-bash-3.2$ tar xvf regperf-j1.tar
-bash-3.2$ cd regperf
Notes: the page info are located in regperf/public.
If the postgres server is set remote, we should change config/database.yaml to set remote server, for example:
3. Pointing the web browser to localhost:3000/subscription the check the application.
Step 3, Setup Faban and the Faban Regperf driver
1. Download the Faban bundle by http://faban.sunsource.net/.
2. Set FABAN_HOME and JAVA_HOME.
3. Download the FABAN driver for Rails from Damien's blog and unjar it into $FABAN_HOME/samples.
Here I made a lot of modifications and rebuild the regperf-rails by myself.
3.1 modify the source code in reperf-rails/src/regperf/driver.
- For Loader1.java, change subscriptions to subscription
- For RailsDriver.java, change subscriptions to subscription
- For RailsDriver.java, change the function getSubscriberFromPage
Change the line from :
String idstr = sb.substring(match.start()+20, match.end()-2);
String idstr = sb.substring(match.start()+19, match.end()-2);
otherwise idstr will get null if the index is less than 10.
3.2 rebuild by ant.
Step 4, Running the performance using the Rails runtime
1. Edit the regperf-rails/config/run.xml
- Change the value of basepath from subscriptions to subscription
- change the value of outputDir to match your $FABAN_HOME/output directory
- change the value of host for serverConfig for remote rails application server
- modify the number of simulated users by changing the value of <scale>1<scale>
You will get 10 users for each scale factor e.g. scale 1 will give 10 simulated users 2. -bash-3.2$ cd reperf-rails/sbin
Note the number of loadedsubscribers should match the number of rows you load into the database (this is set initially to 100)
Refer to the Faban documentation for other values to change in the run.xml
3. you can change the number of loader then run ./loader.sh
If the rails application server is set remote, we should change the address in loader.sh
4. start the rmiregistry (this runs in the background)
-bash-3.2$ ./registry.sh &
5. start and execute the benchmark
Starts up all of the simulated users and writes results of the run into $FABAN_HOME/output/xx directory.
The results can be conveniently viewed with a web browser.