Tuesday, August 28, 2007

Rails Performance Notes

Static Caching

- Cache on demand through Rails
- Cron sweeper (minute.rb?)
- JS + cookie for username
- Caching functional test
- ngnix config (run it locally for testing?)
- deploying cron job


1. Query optimization - query analysis (doing n queries instead of joins)
2. Rails static page caching
3. Asset packager - Firebug Net tab (Page lead times, "apparent" performance)
4. Number of optimal Mongrels ( Topfunky screencast )
5. Rails log - Page load times, Query times
6. Unix diagnostics
- Top
- Vmstat
- MySQL tools
- tail / grep etc
7. Periodic reporting
8. Benchmarks

Friday, August 17, 2007

PostgreSQL on Mac OS

MySQL suddenly stopped working and I was not able to run it. I got frustrated with MySQL error messages like no /tmp/mysql.sock found and -bash: /usr/local/mysql/bin/mysql: Bad CPU type in executable

22:04:59:/usr/local/src > mkdir postgres
22:05:24:/usr/local/src > cd postgres/
22:05:27:/usr/local/src/postgres > ls -l
22:05:29:/usr/local/src/postgres > curl -O ftp://ftp5.us.postgresql.org/pub/PostgreSQL/source/v8.2.4/postgresql-8.2.4.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 14.8M 100 14.8M 0 0 48521 0 0:05:21 0:05:21 --:--:-- 77126
22:12:19:/usr/local/src/postgres > tar -xzvf postgresql-8.2.4.tar.gz

22:31:26:/usr/local/src/postgres > cd postgresql-8.2.4
22:31:30:/usr/local/src/postgres/postgresql-8.2.4 > ./configure --with-includes=/sw/include/ --with-libraries=/sw/lib
checking build system type... powerpc-apple-darwin8.10.0

22:33:12:/usr/local/src/postgres/postgresql-8.2.4 > make
22:41:07:/usr/local/src/postgres/postgresql-8.2.4 > sudo make install
23:25:46:/usr/local/src/postgres/postgresql-8.2.4 > /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the -A option the
next time you run initdb.

Success. You can now start the database server using:

/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data
/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start

23:29:07:/usr/local/src/postgres/postgresql-8.2.4 > /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data
LOG: database system was shut down at 2007-08-16 23:26:25 PDT
LOG: checkpoint record is at 0/42BEB8
LOG: redo record is at 0/42BEB8; undo record is at 0/0; shutdown TRUE
LOG: next transaction ID: 0/593; next OID: 10820
LOG: next MultiXactId: 1; next MultiXactOffset: 0
LOG: database system is ready

23:35:06:~ > /usr/local/pgsql/bin/createdb
23:35:33:~ > /usr/local/pgsql/bin/createdb mytestdb
23:35:45:~ > /usr/local/pgsql/bin/psql mytestdb
Welcome to psql 8.2.4, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit

mytestdb=# create table foo(name varchar primary key, foo_id serial);
NOTICE: CREATE TABLE will create implicit sequence "foo_foo_id_seq" for serial column "foo.foo_id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "foo_pkey" for table "foo"
mytestdb=# insert into foo(name) values ('Liz');
mytestdb=# insert into foo(name) values ('Bunny');
mytestdb=# select * from foo;
name | foo_id
Liz | 1
Bunny | 2
(2 rows)

Sunday, August 12, 2007

Acts as Billable Installation

1. script/plugin install http://source.collectiveidea.com/public/acts_as

2. script/plugin install http://activemerchant.googlecode.com/svn/trunk/

3. sudo gem install --source http://dist.leetsoft.com money

4. script/plugin install http://source.collectiveidea.com/public/rails/p