Sunday, August 02, 2009

Which Deployment for JRuby on Rails?

We often get the question "which deployment option is the best for JRuby on Rails?" The truth is that it depends on what you need out of deployment.

If you have a fairly straightforward Rails app without a lot of service dependencies and a greenfield deployment target, your best bet is probably the GlassFish gem right now. It performs really well, can handle high loads and high concurrency, and automatically detects Rails' threadsafe mode, scaling better when it's turned on. I'm no longer a Sun employee, and I still think the GF gem is an outstanding piece of work. Here's my howto on GF gem + JRuby on Rails + Apache. Update: Here's information on using Capistrano with the GlassFish gem.

If you have an existing Java EE or web container like Tomcat, JBoss, GlassFish, WebLogic, or WebSphere, you want to look into Warbler. Warbler packages your application as a .war file, suitable for deployment on any of these standard servers. The Warbler wiki is the best place to learn about deploying with Warbler.

If you're looking for something that's somewhat greenfield but also needs more advanced services like scheduled asynchronous jobs, web services, and some level of EE integration, you should look at JBoss's TorqueBox, a customized JBoss specially tailored for deployment of Rack-based apps (like Rails) on JRuby.

If you're looking for a hosting provider that can take your app and make it "just work", then you should look into Engine Yard's JRuby cloud offering. We don't yet have it 100% ready to go, but it won't be long and it will be fantastic. For now you can give us some direction and input on what that hosting/cloud should look like.

All told, there's a lot of great options for JRuby deployment, and no one of them is going to be perfect for everyone. Choose wisely, and join the JRuby mailing lists if you have questions.


noble said...

not work on GAE?

Michiel de Mare said...

For the Glassfish gem option, a short guide on starting/stopping glassfish with capistrano would be very welcome.

Charles Oliver Nutter said...

Michiel: I will add a link to capistrano information.

noble: GAE works great for deploying applications, but you would need to use an alternative database setup. I was mostly targeting folks who have already build a full-on Railsy application, presumably using a SQL database. There are other resources out there for GAE deployment too.

Jeffrey said...

we use vlad with jruby & gf -

Unknown said...

Hey Charles,

The glassfish gem comes with a GPL (and CDDL) by way of the glassfish server, does this prohibit its use within non-hosted commercial software ? That is can a commercial software product be distributed with the glassfish gem included ?


Charles Oliver Nutter said...

sinclair: GlassFish, like most Sun OSS properties, is licensed GPL v2 but with the "Classpath Exception". The Classpath Exception allows linking the software in question with other "modules" regardless of the terms of those modules and to distribute the result using terms of your choice.

Check out the GlassFish dual license page, way at the bottom:

Of course IANAL, but I believe this allows you to bundle GF with other software just fine, and does not require your part of the software to be GPL.

Anonymous said...

Is it a good practice to host application on pure Glassfish server (not gem) without any additional webserver (like apache, nginx, etc)?

Arun Gupta said...

GlassFish actually does not need any front-end unless you want to run multiple instances at the backend. It comes with Grizzly that provides static file caching and is a highly efficient frontend. There are other reasons you may want to front end such as not exposing your entire App server outside firewall, flexibility to add more instances if the load grows and others.

Are you considering v2 or v3 ?

Here are some entries that might be useful in case you decide to front-end:

GlassFish Gem + nginx:

Apache + mod_prxy_balancer:

Anonymous said...

Arun Gupta, thanks for the resopnse.

I want to run Rails application on Glassfish v3 in Directory-based mode.

Regarding multiple Glassfish instances running behind some WebServer, I thought Glassfish has it's own built-in functions to run in clestered enveronment, or not?

Unknown said...

May we know what is the solution of choice by Engine Yard ? Historically it does not seem to be one of the solution you advise. Why are they still using nginx/mongrel/rack/ruby/rails/merb stack and JRuby only for cloud ?

Mohamed Ajmal said...

Pls help me find a way

think of a Shared tomcat server, how can i upload a juruby file other than by WAR,

Is it possible to Unarchive it locally and upload via .jsp files, which is the only alllowed way in mochahost

Paul said...

This article was very helpful for me. We settled on GlassFish gem. I struggled a little to get things working exactly right though, so I wrote up what finally worked in case any other readers are troubleshooting their own installs: