Thursday July 02, 2009
Rails on GlassFish - "most performant of all", "simpler and just works", "blazing speed"
Here are some quotes about running Rails applications on GlassFish from user@jruby
mailing list:
I find the glassfish gem
to be the most performant of all -- and I don't need to war-up my app.
I also have some mongrel
cluster stuff, but glassfish is simpler and just works.
Voila...blazing speed,
can handle lots of traffic. Note that I am also cominging into apache
from a dyndns name. So, whatever IP I have, I can go straight to
execution on the glassfish gem and NO warring up! What could be easier
deployment, or a faster execution?
It's running fantasticly
and performing like nothing I've seen before :) Completely stable
memory, no wirings or anything bad for 5 days now.. (with several
ab/htperf stresstests).
It's always exciting to get good endorsements of our efforts in the
GlassFish team :)
Other similar stories for using Rails/GlassFish in production are
described at rubyonrails+stories.
Technorati: glassfish
v3 gem rubyonrails
stories
jruby
Posted by Arun Gupta in web2.0 | Comments[0]
|
|
|
|
|
Friday May 15, 2009
Ruby-on-Rails and Ramaze production deployments on GlassFish
Published three new JRuby/GlassFish production deployment stories
in as many days:
Posted by Arun Gupta in General | Comments[0]
|
|
|
|
|
Tuesday May 05, 2009
Rails Conf 2009 Day 2 Trip Report
This is a follow up post from David's
keynote.
| Attended Women
in Rails
panel discussion. The panel, Sarah
Mei, Lori
Olson, and Desi
McAdam (from L to R), had a very interesting discussion
around
the genuine problems and possible solutions of involving more women in
Rails community. |
![]() |
I presented on Develop with Pleasure, Deploy with Fun: GlassFish and NetBeans for a better Rails experience, slides here. The several concepts in the talk are explained in the following bullets: |
![]() |
The next talk of the day was JRuby: State of the Art |
| Later in the evening, Brian Helmkamp, Aman Gupta, Luis Navena, Pat Allan, Dan Kubb, and John Nunemaker were awarded Ruby Heroes Award! |
![]() |
And the keynote by Tim Ferris,
lets not talk about it ;-) I edited pictures, authored my blog, caught
up
on email/RSS during the keynote. #railconf on IRC and twitter
were way more fun! Check the live ratings. "1" was the lowest rating that could be given anyway! |
Sea Change Affinity - Why JRuby/GlassFish ?
At Rails Conf
2009, Jay
McGaffigan from Sea
Change talked about why they choose JRuby/GlassFish for their
product Affinity.
Here are some of the reasons he quoted:
Posted by Arun Gupta in web2.0 | Comments[1]
|
|
|
|
|
Monday May 04, 2009
Rails Conf 2009 - Day 1 Trip Report
Rails Conf 2009 started this morning. The first day consists of morning
and afternoon tutorials.
I attended Nick Sieger's JRuby
on Rails tutorial, the slides are available.
A survey in the room showed:
| run
lambda { |env| [ 200, { 'Content-Length' => '2', 'Content-Type' => 'text/html', }, ["hi"] ] } |
| ~/samples/railsconf/sinatra/basic-rack
>~/tools/jruby/bin/jruby
-S rackup [2009-05-04 13:40:18] INFO WEBrick 1.3.1 [2009-05-04 13:40:18] INFO ruby 1.8.6 (2009-03-16) [java] [2009-05-04 13:40:18] INFO WEBrick::HTTPServer#start: pid=90964 port=9292 127.0.0.1 - - [04/May/2009 13:40:27] "GET / HTTP/1.1" 200 2 0.0160 127.0.0.1 - - [04/May/2009 13:40:27] "GET /favicon.ico HTTP/1.1" 200 2 0.0060 127.0.0.1 - - [04/May/2009 13:40:30] "GET /favicon.ico HTTP/1.1" 200 2 0.0100 |
| App
= lambda { |env| [ 200, { 'Content-Length' => '2', 'Content-Type' => 'text/html', }, ["hi"] ] } |
| ~/samples/railsconf/sinatra/basic-rack
>~/tools/jruby/bin/jruby
-S rackup app.rb [2009-05-04 13:43:57] INFO WEBrick 1.3.1 [2009-05-04 13:43:57] INFO ruby 1.8.6 (2009-03-16) [java] [2009-05-04 13:43:57] INFO WEBrick::HTTPServer#start: pid=90990 port=9292 127.0.0.1 - - [04/May/2009 13:44:09] "GET / HTTP/1.1" 200 2 0.0110 |
| class
BasicRack def call(env) body = "Hello from a class" [ 200, { 'Content-Length' => body.size.to_s, 'Content-Type' => 'text/html', }, [body] ] end end run BasicRack.new |

| ~/samples/railsconf/sinatra/basic-rack
>~/tools/jruby/bin/jruby -S gem install shotgun JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Successfully installed configuration-0.0.5 Successfully installed launchy-0.3.3 Successfully installed shotgun-0.2 3 gems installed Installing ri documentation for launchy-0.3.3... Installing RDoc documentation for launchy-0.3.3... |
| ~/samples/railsconf/sinatra/basic-rack
>~/tools/jruby/bin/jruby -J-Djruby.fork.enabled=true -S shotgun [2009-05-04 13:55:46] INFO WEBrick 1.3.1 [2009-05-04 13:55:46] INFO ruby 1.8.6 (2009-03-16) [java] == Shotgun starting Rack::Handler::WEBrick on localhost:9393 [2009-05-04 13:55:46] INFO WEBrick::HTTPServer#start: pid=91089 port=9393 |
| class
BasicRack def call(env) body = if env["PATH_INFO"] == "/foo" "in foo" else "in other" end [ 200, { 'Content-Length' => body.size.to_s, 'Content-Type' => 'text/html', }, [body] ] end end run BasicRack.new |
| class
BasicRackApp def call(env) body = "hello from app" [ 200, { 'Content-Length' => body.size.to_s, 'Content-Type' => 'text/html', }, [body] ] end end class MyMiddleware def initialize(app) @app = app end def call(env) @app.call(env) end end use MyMiddleware run BasicRackApp.new |
| use Rack::CommonLogger |
|
def call(env) status, headers, body = @app.call(env) body.map! { |part| part.upcase} [status, headers, body] end |
| require
'sinatra' |
| ~/samples/railsconf/sinatra/basic-sinatra
>~/tools/jruby/bin/jruby
-rubygems basic-sinatra.rb == Sinatra/0.9.1.1 has taken the stage on 4567 for development with backup from WEBrick [2009-05-04 14:40:14] INFO WEBrick 1.3.1 [2009-05-04 14:40:14] INFO ruby 1.8.6 (2009-03-16) [java] [2009-05-04 14:40:14] INFO WEBrick::HTTPServer#start: pid=91396 port=4567 |
| require
'rubygems' require 'sinatra' not_found do 'hi from other' end get '/foo' do 'hi from foo' end |
| require
'rubygems' require 'sinatra' get '/env' do env.inspect end |
| require
'rubygems' require 'sinatra' get '/' do end post '/' do end put '/' do end delete '/' do end |
| require
'rubygems' require 'sinatra' get '/' do content_type "application/json" { "foo" => "goo" }.to_json end |
| <html> <body> Hello form Sinatra + ERB </body> </html> |
| require
'rubygems' require 'sinatra' get '/' do erb :index end |
| require
'rubygems' require 'sinatra' require 'haml' get '/' do haml :index end |
| %html %body %h1 Hello from HAML |
| require
'rubygems' require 'sinatra' require 'haml' get '/' do erb :index end use_in_file_templates! __END__ @@ index <html> <body> Hello form Sinatra + ERB in file </body> </html> |
| require
'rubygems' require 'sinatra' require 'haml' get '/' do erb :index end get '/foo' do erb :foo end use_in_file_templates! __END__ @@ index <html> <body> Hello form Sinatra + ERB in file </body> </html> @@ foo <h1>FOO!</h1> |
| require
'rubygems' require 'sinatra' require 'haml' helpers do end |
| require
'rubygems' require 'sinatra' require 'haml' module helpers def self.dosomething(arg) end end get '/' do Helpers.dosomething end |
TOTD #81: How to configure "database.yml" to be used with both JRuby and MRI ?
In JRuby-on-Rails
tutorial at Rails
Conf 2009, Nick
Sieger shared a nice little tip on how to configure
"database.yml" to be usable with both JRuby and MRI:
| <% jdbc = defined?(JRUBY_VERSION) ? 'jdbc' : ''
%> development: adapter: <%= jdbc %>mysql encoding: utf8 reconnect: false database: myapp_development pool: 5 username: root password: socket: /tmp/mysql.sock # ... |
Posted by Arun Gupta in General | Comments[0]
|
|
|
|
|
Friday May 01, 2009
JRuby, Rails, and GlassFish Bootcamp - San Francisco, May 19/20, 2009
![]() |
Would you like to power up your Rails
applications using JRuby
and GlassFish ?
And learn that from the engineers who develop the technology. If yes, then we have organized a bootcamp for you! |
Posted by Arun Gupta in web2.0 | Comments[0]
|
|
|
|
|
Thursday April 30, 2009
TOTD #81: How to use nginx to load balance a cluster of GlassFish Gem ?
![]() |
nginx (pronounced as "engine-ex") is an open-source and high-performance HTTP server. It provides the common features such as reverse proxying with caching, load balancing, modular architecture using filters (gzipping, chunked responses, etc), virtual servers, flexible configuration and much more. |
| ~/tools
> curl -L -O http://sysoev.ru/nginx/nginx-0.6.36.tar.gz ~/tools > tar -xzf nginx-0.6.36.tar.gz ~/tools > curl -L -O http://downloads.sourceforge.net/pcre/pcre-7.7.tar.gz ~/tools > tar -xzf pcre-7.7.tar.gz ~/tools/nginx-0.6.36 > ./configure --prefix=/usr/local/nginx --sbin-path=/usr/sbin --with-debug --with-http_ssl_module --with-pcre=../pcre-7.7 ~/tools/nginx-0.6.36 > make ~/tools/nginx-0.6.36 > sudo make install ~/tools/nginx-0.6.36 > which nginx /usr/sbin/nginx |

| ~/samples/jruby >~/tools/jruby/bin/jruby -S rails
runner ~/samples/jruby/runner >~/tools/jruby/bin/jruby script/generate scaffold runlog miles:float minutes:integer ~/samples/jruby/runner >sed s/'adapter: sqlite3'/'adapter: jdbcsqlite3'/ <config/database.yml >config/database.yml.new ~/samples/jruby/runner >mv config/database.yml.new config/database.yml ~/samples/jruby/runner >~/tools/jruby/bin/jruby -S rake db:migrate |
| ~/samples/jruby/runner >~/tools/jruby/bin/jruby -S
glassfish Starting GlassFish server at: 192.168.1.145:3000 in development environment... Writing log messages to: /Users/arungupta/samples/jruby/runner/log/development.log. Press Ctrl+C to stop. |
| ~/samples/jruby/runner >~/tools/jruby/bin/jruby -S
glassfish -p 3001 Starting GlassFish server at: 192.168.1.145:3001 in development environment... Writing log messages to: /Users/arungupta/samples/jruby/runner/log/development.log. Press Ctrl+C to stop. |
| ~/samples/jruby/runner >~/tools/jruby/bin/jruby -S
glassfish -p 3002 Starting GlassFish server at: 192.168.1.145:3002 in development environment... Writing log messages to: /Users/arungupta/samples/jruby/runner/log/development.log. Press Ctrl+C to stop. |
| upstream
glassfish { server 127.0.0.1:3000; server 127.0.0.1:3001; server 127.0.0.1:3002; } |

| proxy_pass http://glassfish; |

| sudo
kill -15 `cat /usr/local/nginx/logs/nginx.pid` sudo nginx |

| log_format
main '$remote_addr - [$upstream_addr]
$remote_user [$time_local] $request ' '"$status" $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log logs/access.log main; |
| 127.0.0.1 - [127.0.0.1:3000]
- [29/Apr/2009:15:27:57 -0700] GET
/runlogs/ HTTP/1.1 "200" 3689 "-" "Mozilla/5.0 (Macintosh;
U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.27.1 (KHTML, like
Gecko) Version/3.2.1 Safari/525.27.1" "-" 127.0.0.1 - [127.0.0.1:3001] - [29/Apr/2009:15:27:57 -0700] GET /favicon.ico HTTP/1.1 "200" 0 "http://localhost/runlogs/" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1" "-" 127.0.0.1 - [127.0.0.1:3002] - [29/Apr/2009:15:27:57 -0700] GET /stylesheets/scaffold.css?1240977992 HTTP/1.1 "200" 889 "http://localhost/runlogs/" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1" "-" |
| 127.0.0.1 - [127.0.0.1:3000]
- [29/Apr/2009:15:28:53 -0700] GET /runlogs/ HTTP/1.1 "200" 3689 "-"
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us)
AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1"
"-" 127.0.0.1 - [127.0.0.1:3002, 127.0.0.1:3000] - [29/Apr/2009:15:28:53 -0700] GET /favicon.ico HTTP/1.1 "200" 0 "http://localhost/runlogs/" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1" "-" 127.0.0.1 - [127.0.0.1:3001] - [29/Apr/2009:15:28:53 -0700] GET /stylesheets/scaffold.css?1240977992 HTTP/1.1 "200" 889 "http://localhost/runlogs/" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1" "-" |
Posted by Arun Gupta in web2.0 | Comments[6]
|
|
|
|
|
Wednesday April 29, 2009
TOTD #80: Sinatra CRUD application using Haml templates with JRuby and GlassFish Gem
TOTD
#79 showed how to run a trivial Sinatra
application using GlassFish
Gem. Sinatra
provides support for Haml,
Erb,
Builder,
Sass,
and Inline templates as described here.
This TOTD will show how to get started with creating a Sinatra CRUD
application using Haml templates.
![]() |
Haml is based on one primary principle - Markup should be beautiful
because beauty makes
you faster. Get started by installing the Haml gem as:
And follow the tutorial, documentation, and reference page for more details. |
| ~/tools/jruby/samples/sinatra-sample >mysql --user root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 664 Server version: 5.1.30 MySQL Community Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> create database hello_development; Query OK, 1 row affected (0.00 sec) mysql> use hello_development; Database changed mysql> CREATE TABLE `runners` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `distance` float, `minutes` int(11), `created_at` datetime, `updated_at` datetime); Query OK, 0 rows affected (0.06 sec) |
| require 'rubygems' require 'sinatra' require 'activerecord' ## Setup ActiveRecord::Base.establish_connection( :adapter => "jdbcmysql", :host => "localhost", :username => "root", :password => "", :database => "hello_development" ) ## Models class Runner < ActiveRecord::Base end ## Controller Actions get '/hi' do "Hello World!" end get '/' do @runner = Runner.find(:all) haml :index end get '/new' do haml :new end get '/:id' do @runner = Runner.find(params[:id]) if (@runner) haml :show else redirect '/' end end post '/' do @runner = Runner.new(:distance => params[:distance], :minutes => params[:minutes]) if @runner.save redirect "/#{@runner.id}" else redirect '/' end end |
| %h1 Listing all runners ... %table %tr %th Distance %th Minutes - @runner.each do |r| %tr %td= r.distance %td= r.minutes %br %a{:href=>"/new"} New Runner |
| %h1 Adding a new runner log ... %form{:method=>"post", :action=>"/"} Distance: %input{:type=>"text", :name=>"distance"} %br Minutes: %input{:type=>"text", :name=>"minutes"} %br %input{:type=>"submit", :value=>"Submit"} %br |
| %h1 Showing a runner log ... Distance: = @runner.distance %br Minutes: = @runner.minutes %br %br %a{:href=>"/"}= "Show All!" |
| . ./hello.rb ./views ./views/index.haml ./views/new.haml ./views/show.haml |
| ~/tools/jruby/samples/sinatra-sample >../../bin/jruby -S glassfish Starting GlassFish server at: 192.168.1.145:3000 in development environment... Writing log messages to: /Users/arungupta/tools/jruby-1.2.0/samples/sinatra-sample/log/development.log. Press Ctrl+C to stop. |





Posted by Arun Gupta in web2.0 | Comments[4]
|
|
|
|
|
Tuesday April 28, 2009
TOTD #79: Getting Started with Sinatra applications on JRuby and GlassFish Gem
![]() |
Sinatra
is a DSL for quickly creating web-applications in Ruby with minimal
effort. Like Rails and Merb, Sinatra is not an MVC framework and
basically follows a flat-file structure instead. The framework define
conventions such as location of static files and
views, bootstrap, dev/production/test environment variables, filters,
helpers, TDD, and much more. Read Getting Started
for complete details. Even though Sinatra is not a MVC framework but sinatra-gen
may be used to generate new Sinatra projects. GlassFish Gem can easily run Rails, Merb, Sinatra, and any other Ruby framework applications based upon Rack. TOTD #70 shows how to run Rails applications and TOTD #53 shows to run Merb applications. This TOTD will explain how to run a trivial Sinatra application. A later blog will describe how to plug a generic Rack-based framework. |
| ~/tools/jruby >./bin/jruby -S gem install
sinatra JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Successfully installed sinatra-0.9.1.1 1 gem installed Installing ri documentation for sinatra-0.9.1.1... Installing RDoc documentation for sinatra-0.9.1.1... |
| require 'rubygems' require 'sinatra' get '/hi' do "Hello World!" end |
| ~/tools/jruby/samples/sinatra-sample
>../../bin/jruby
-S glassfish Log file /Users/arungupta/tools/jruby-1.2.0/samples/sinatra-sample/log/development.log does not exist. Creating a new one... Starting GlassFish server at: 192.168.1.145:3000 in development environment... Writing log messages to: /Users/arungupta/tools/jruby-1.2.0/samples/sinatra-sample/log/development.log. Press Ctrl+C to stop. |

Posted by Arun Gupta in web2.0 | Comments[0]
|
|
|
|
|
Monday April 27, 2009
GlassFish, NetBeans, and Project Kenai at Rails Conf 2009
Did you know that ...
![]() |
|
![]() |
Develop
with pleasure, Deploy with Fun: GlassFish and NetBeans for a better
Rails experience Tuesday, May 5th, 2009, 1:50pm Pavilion 1 |
| And you'll get to meet Project Kenai team, they form the foundation for Sun's connected developer experience. Read about their participation here and meet them to learn about NetBeans and Kenai integration. | ![]() |
Posted by Arun Gupta in General | Comments[5]
|
|
|
|
|
Wednesday April 22, 2009
LOTD #21: Production Deployment Tips for running Rails on GlassFish v2 using Windows
SeaChange
Affinity uses Rails and GlassFish
as their deployment platform. One of their core developers posted
tips based upon their experience so far and they are
available at:
Rails
on GlassFish v2 using Windows
Here are some of the quotes:
Glassfish can really
handle a heavy load
and
handling 400
simultaneous users under a supremely heavy load, the
memory was holding great
All previous links in this series are archived at LOTD.
Technorati: lotd
glassfish
jruby
rubyonrails
windows
Posted by Arun Gupta in web2.0 | Comments[0]
|
|
|
|
|
Thursday April 02, 2009
Silicon Valley Rails Meetup, Mar 2009 - Slides & Pics
I presented at Silicon Valley Rails Meetup yesterday.
The official attendance says 79 and the kitchen area (for the
presentation) was indeed packed!
The
demo gods were hovering very much around and required me to reboot the
machine - live during the presentation. Have you ever rebooted Mac
because of a slow performance, smack in the middle of a demo ? ;-)
Here is a quote from the meetup:
The big win with
glassfish is that it gives you the same environment in deployment and
development.
The slides are available here.
And some pointers to get more information:


Posted by Arun Gupta in web2.0 | Comments[7]
|
|
|
|
|
Tuesday March 31, 2009
ISV & OEMs Webinar Replay: GlassFish- and MySQL-Backed Applications with Netbeans and JRuby-on-Rails
I presented a webinar for ISV and OEMs on "Developing
GlassFish- and MySQL-Backed Applications with NetBeans and
JRuby-on-Rails" last
week.

The slides and a complete recording
of the webinar are now available here.
Technorati: webinar
glassfish
mysql netbeans
jruby rubyonrails
Posted by Arun Gupta in web2.0 | Comments[3]
|
|
|
|
|
Monday March 23, 2009
This is a re-run of an earlier
webinar.
Would you like to know how JRuby,NetBeans, GlassFish, and MySQL can power your Rails
applications ?

This informative
technical webinar explains the fundamentals of JRuby and how
the NetBeans IDE makes developing/debugging/deploying Rails
applications on GlassFish quick, fun and cost-effective.
The webinar starts 10am PT on Mar 31st, 2009 and can be accessed from a
browser.
Register here.
Technorati: jruby
rubyonrails
glassfish
netbeans
mysql webinar
Posted by Arun Gupta in web2.0 | Comments[2]
|
|
|
|
|
Today's Page Hits: 3239
Total # blog entries: 931