@Sathish ,
I would strongly encourage you to do two things:
-
Read Using JRuby http://pragprog.com/book/jruby/using-jruby . You
can
work though it quickly and the examples and material contained in it
will
give you some ideas about how you can use JRuby to improve the
performance
of your clients app. You might also want to check out Deploying
JRubyhttp://pragprog.com/book/jkdepj/deploying-with-jrubyas it has a
lot of useful information about some of the main deployment
options.
2.
Spend some time reading through articles on the JRuby
wikihttps://github.com/jruby/jruby/wikias they should provide a way
to deepen the knowledge gleaned from the book,
without requiring you to spend too much time on any of them.
This should give you a better idea about JRuby, and the how and why it
is
typically used by other developers. This video, Why JRuby
Workshttp://confreaks.com/videos/1281-rubyconf2012-why-jruby-workssummarizes
some of this reasoning as well, and might be an even better
starter point.
It might be the case that you could switch the rails app to JRuby, have
it
run with very few changes, and get an immediate performance boost simply
due to JRubys better performance. The material I recommended will
assuredly instruct you in how to do this.
As for going asynchronous, it might be possible to use the Play
framework,
via JRuby, to build an asynchronous application. I dont know of anyone
who
has done that, personally, although it has probably been tried. You
cannot
just take a rails app, suddenly slap in JRuby and Play and have it be
asynchronous however. Rails and Play are each frameworks in their own
right, and Im not even sure where one would begin to hook them together.
Usually, when people talk about asynchronous code in conjunction with
Rails, they mean running selected parts of the Rails stack in an
asynchronous way. Typically I/O heavy parts. Most often, they mean
running
it with an asynchronous server.
The two libraries most typically used to do async programming in Ruby
are
EventMachine http://rubyeventmachine.com/ and
Celluloidhttp://celluloid.io/,
specifically Celluloid I/O https://github.com/celluloid/celluloid-io.
Of
those two, Id most highly recommend Celluloid, for many reasons, but
especially because it doesnt just give you Celluloid I/O for writing
asynchronous code, but instead Celluloid provides an entire concurrency
toolkit built around the Actor model. (Play framework is also built on
top
of the Actor model abstraction, but I believe Play hides this all from
you
instead of making it available to the end user).
Probably your easiest option for adding some async sauce to a Rails app
would be to swap out the server for one written with one of those two
libraries I mentioned above. Id suggest
Reelhttps://github.com/celluloid/reel-rack.
That said, you might get better improvements just switching to JRuby
for
the native threading capability and then using something like
Pumahttp://puma.io/which is specifically intended for use in Rack
applications like those
built with Rails, or one of the other deployment options recommended in
the
book I mentioned. TorqueBox http://torquebox.org/ would be another
great
choice.
It will depend on your clients use case, and you should definitely try
several things and do some benchmarking.