Skip to content

JRuby, sharing objects across multiple runtimes. JMagLev?

October 8, 2008

MagLev was a show from the last RailsConf (2008). Presentation and demos of the product are really impressive.

Recently, Brian Takita asked in the JRuby mailing list:

JRuby + TerraCotta == Maglev?

What an idea! In the last few days I’ve tried to make something useful and I’m happy to have something to show.

JRuby + Nailgun and JRuby + Terracotta

Screencast: Reproducing Avi Bryant's Demo with JRuby + Nailgun and JRuby + Terracotta. (5 min)

The first demo runs with Nailgun. The basic idea is to share a single Java VM across all clients, so they can share some objects. The second is much more complete, as its clients have their own Java VM. There are many true interpreters running, and they are sharing objects through Terracotta. Terracotta is responsible for sharing memory in Java VM clusters and, despite of its slow startup, has much more to offer. The shared objects (hats and rabbits) could be automatically persisted by Terracotta, as MagLev also does.

I’ve patched JRuby and configured Terracotta to make demos run. I’ll upload the patches and configuration somewhere, ASAP.

Working on JRuby to make it run multiple runtimes (VMs) at the same time is being really fun!


13 Comments leave one →
  1. October 8, 2008 7:10 am

    Awesome demo, very clever solution to the multi-vm problem, this is a very approachable solution, specially for server-side stuff where startup time is not that relevant.

  2. Adrian Madrid permalink
    October 8, 2008 1:10 pm

    Very interesting. Honestly this is what really gets me going when I hear Maglev: sharing automatically replicated/persisted objects through workers. I guess I’ll have to read up more on Terracota.

  3. October 8, 2008 5:55 pm

    Pretty interesting demo. As a Terracotta developer I am happy to see ppl poking our product in interesting ways like this.

    One of my collegue had once played around clustering Jruby with Terracotta sometime back.

    Dunno if you had checked it out or not.

    http://jonasboner.com/2007/02/05/clustering-jruby-with-open-terracotta/

    cheers,
    Saravanan

  4. October 8, 2008 5:59 pm

    Thanks for the link Saravanan. Yes, I’ve seen it, but I took a different approach.

    The main difference is that in my version of the Terracotta integration, all global variables are automatically shared across JVM cluster nodes. It is “transparent”, as it doesn’t require any explicit control in the Ruby code.

  5. October 9, 2008 1:35 am

    Muito bom!

  6. October 9, 2008 8:27 am

    I love it! Transparent JRuby clustering. Good idea there.

    –Ari

  7. October 10, 2008 12:45 am

    Very impressive! Just as impressive as the original MagLev demo that I was lucky enough to see at RailsConf.

  8. Mark permalink
    October 21, 2008 3:35 am

    Very nice.
    1) Are the required JRuby changes likely to make it into a released JRuby?
    2) Was the Terracotta ‘side-of-things’ written as a Terracotta Integration Module (TIM)?

  9. October 21, 2008 1:03 pm

    @Mark

    1) Unfortunately not in the next (1.1.5). There are things that must be tuned yet. I’ve already discussed a bit with Charles Nutter. The main points are: a) global object identity, b) shared metaclasses. But it is already usable.

    2) Not yet. That is my next step; or perhaps I will open the source in github first.

  10. Hubert Łępicki permalink
    January 29, 2009 7:31 pm

    That’s really interesting – however I doubt that your approach with making all global variables accessible from all instances will make big community around it. I think it’s better to specify which variables you need to share, and rest (default) shouldn’t be shared.

Trackbacks

  1. blog.caelum.com.br » JRuby on Rails, no Rails Summit Latin America
  2. Danilo Sato » Blog Archive » [Rails Summit Latin America] Conference Report
  3. Play with JMaglev yourself « Fabio Kung

Leave a Reply

Note: You can use basic XHTML in your comments.

Subscribe to this comment feed via RSS