Blog

Archive for 2010

Engine Yard Cloud Out Loud S01E03: Sarah Allen

By | December 23rd, 2010 at 9:12AM

Ruby t-shirt that says Ruby makes me happy

This week we interview Sarah Allen of Blazing Cloud. Matt Reider, the Director of Professional Services and Training at Engine Yard, talks with Sarah about why Ruby makes people happy. They discuss the Ruby ecosystem and various methods of teaching people who are new to Ruby / Rails (such as teaching them about gems first).

Matt asked me to edit his mishaps, but I conveniently ignored his request =).

Here is a list of a few places you can go to explore and become a part of the amazing Ruby / Rails ecosystem that Sarah talks about:

Rails Developer Ruby on Rails Community
Ruby Forum
Ruby on Rails in StackOverflow
RailsBridge
RubyFlow
Ruby Meetups
IRC freenode channels: #ruby, #rubyonrails

If you want to take a class to learn more about Ruby on Rails, check out the next Zero to Rails 3 Class offered virtually January 24 to January 27, 2011.

Oh, and check out this clip of Jim Weirich and Chad Fowler performing ‘Has Anybody Seen My Code?’ onstage at Mountain.rb 2010. Thanks Andy Delcambre for sharing the clip.

Like the illustration above? We do too. Thanks to Matt Sears and Ruby Rags for allowing us to share it with you all. Check ‘em out. They’ve got some pretty cool shirts.

Popularity: 2% |

Deployment History in Engine Yard AppCloud

By | December 22nd, 2010 at 6:12PM

Upgrade To The CLI Deployment System

Deployment history is only available on the web using the CLI-based deployment method. If you haven’t already converted your environment to CLI Deploys, now is the time.

Switching your environments to use the CLI deploy system as the strategy for web deployments only takes a few seconds. There have been no reported issues for this well tested deploy system, and about half of all Engine Yard AppCloud environments are using it.

Benefits of CLI Deploy

  • Proven Bundler support
  • Consistent behavior between the command line and web deployments
  • Much faster deployments (compared to updating instances every deploy, which is required by the old web deploy system)
  • Recorded deployment history

To enable CLI Deploy and deployment history on your environments, visit the dashboard and click More Options, then Edit Environment. Show advanced options and switch the pull-down from “Legacy Web Deploy” to “CLI Deploy”. Save the environment and you’re ready to go.

Once enabled, you’ll see a slightly different user interface. The button on the top shows “Update Instances” and only runs instance configuration without deploying your apps. Application deployment has moved to the Applications tab (makes sense, right?).

Deploy from the Applications tab

To deploy applications from the dashboard, click the Applications tab on your environment. You will see a form with “Migrate?” and “Ref” inputs. The migrate check box and input control the migration command to run (or nothing if unchecked) and the ref will autocomplete with your repository’s branch and tag names. Once you click Deploy, you can follow the deployment status by watching the area below the form. This deploy process is exactly the same as using the engineyard CLI gem in your terminal.

Deployments work the same as command line deployments

Most deploys take less than a couple minutes and the “View Log” link will show you the deployment output.

You may notice that each deployment tracks your name. If you’re not in our beta program for collaboration, this may seem a bit confusing. All deploys are done by you right? If you work with a team of developers or deal with multiple Engine Yard accounts on a daily basis, signing up for the collaboration beta program will make you very happy.

Deployment tracking of command line deploys from the engineyard gem is coming soon.

EDIT (23 December 2010): Deployment history from CLI deploys is now enabled as of engineyard gem version 1.3.8.

Popularity: 1% |

Rubinius 1.2 Now Available!

By | December 22nd, 2010 at 11:12AM

Rubinius 1.2 was just released and is available at http://rubini.us. There are a number of new features and improvements since 1.0.

LLVM 2.8

We’ve upgraded to using LLVM version 2.8, the latest released version. LLVM powers the high performance compiler Rubinius uses to compile Ruby code all the way down to machine code. This brings some minor performance improvements related to better optimizations, but this mostly paves the way for future high-level optimizations that we’ll be implementing with new LLVM 2.8 features.

Bytecode Verifier

More and more people are beginning to use Rubinius as a platform for other languages, not just Ruby. This is a development we’re all super excited about, but it meant we needed to get a little more serious about making sure that bytecode can’t crash the VM. Previously, we got along fine with no verifier simply because there was only one piece of code that generated Rubinius bytecode, the Rubinius compiler. Now with others also doing so, we needed to make sure they’re generating valid bytecode. The bytecode verifier is a VM operation that is performed lazily, when a method is first invoked. It makes sure that the bytecode is consistent, for instance, only using the amount of stack it has requested and only using the proper number of local variables. With this new safety net in place, people can feel much more confident about generating their own bytecode without causing any hard crashes in the system.

Memory Efficiency

Ruby is being used for larger and larger software projects these days. This makes how system memory efficiency very important. There are two measures of memory efficiency: growth stability and memory usage per object. Growth stability is largely a feature of the garbage collector, and is something that Rubinius has done quite well for some time now and so we focused on improving the memory usage per object.

Specifically, how an object stores its instance variables in memory. Because Ruby does not require instance variable declaration, the simplest way to model instance variables is with a hash. This is precisely what Rubinius used to do. The issue is for classes that have a small number of instance variables. In this case, the size of the hash table is substantial, needing more than 100 bytes of memory just to store one word (either 4 or 8 bytes)! And so we set about to try and reduce this overhead. Because Rubinius uses so many Ruby classes internally, we knew that a fix would have immediate benefits.

The new code is based upon an easily observable assumption about a class, namely that it defines the vast majority (usually all) of its methods before an instance of the class is created. We exploit this by running some code the first time an instance of a class is created which looks at all methods available to instances of this class. This means all methods defined in the class itself, its superclasses, and any mixed in modules. From the methods, we build a table of all instance variables those methods use.

Now we can construct a very good picture of how memory should be laid out for instances of this class, allowing us to store the instance variables in memory without needing a hash table. The memory usage typically goes from 100 bytes to 8 bytes on a 64bit machine. Quite a savings!

Debugger

A good debugger is invaluable when working on code of any kind. One of the big additions since 1.0 is the built-in debugger. Gems such as ruby-debug wouldn’t compile, let alone work, because Rubinius doesn’t share any internals with MRI.

We decided to take a different approach than most debuggers for languages. Typically, the debugger is delivered and used via some kind of command line interface only. We wanted a command line interface, but we didn’t want it to be the only way into the system.

So, instead we built a Debugging API into the VM itself and built the CLI debugger on top of this API. This means it’s available to be used by other projects that want to build new and innovative debuggers. In fact, the CLI interface we ship should be considered a kind of reference implementation. It’s a bit short on features, but shows easily how to use the API and build upon it. We’ve already had people begin to port their debugger logic over to using the Rubinius API so that existing debuggers can be plugged into Rubinius simply.

Using the debugger is easy:

require 'rubinius/debugger'
Rubinius::Debugger.here

This will drop the code into the debugger at the .here method call, allowing you to inspect the call stack and objects on it. You can also use the -Xdebug option to rbx, which will start the debugger before loading the initial program, allowing you to set breakpoints before loading code.

For 1.2, we’ve introduced a special ruby-debug shim gem. This gem doesn’t contain ruby-debug, but instead emulates the most common entrance point to it and invokes the built-in debugger. This means that projects such as Rails which have ruby-debug support integrated in work out of the box.

In future releases, we’ll continue to improve on the debugging APIs as well as the CLI interface. So if you’ve got ideas for improvement, be sure to let us know!

Also we’re looking for a list of projects that begin to add support for the debugging API. This includes frameworks like Rails and editors such as Emacs, VIM, Textmate, etc. If you’re interested in adding support for your favorite project, let us know so we can help!

Query Agent

Query Agent (QA) is yet another tool that developers can use to debug and introspect their running programs. It provides the ability for the VM to export all kinds of low level data such as statistics about the garbage collectors. In addition to raw stats, it provides the ability to trigger functionality by reading and writing values.

For example, to get a live backtrace of all threads, simply read the system.backtrace variable. The values returned are calculated on request and thus reflects the current state of the system.

Implementation wise, Query Agent is a socket based API that is implemented directly by the VM. We opted to use BERT as the wire protocol, which allowed us to easily write a ruby client using the existing BERT encoder/decoder gem.

We hope that people will begin incorporating Query Agent support into their monitoring tools, allowing them to get very rich data and control of their ruby processes.

Heap Dump

Lastly, we have integrated a memory debugging tool directly into the VM. Heap Dump provides the ability to write out the entire object graph to disk in a stable, portable format. That file can then be read back in and analyzed. A very common analysis that is performed is simply to find out how many objects of each class exist in the system. This knowledge alone can help developers figure out object leaks that might exist in their code. There are currently two interfaces to Heap Dump, one in Ruby and one via the Query Agent.

In Ruby:

Rubinius::VM.dump_heap("/path/to/file")

and via the Query Agent:

set system.memory.dump /path/to/file

By having access via Query Agent, it become possible to debugging production processes offline.

We’ve only begun writing tools to analyze the dumps, which is available at
https://github.com/evanphx/heap_dump.

Beyond 1.2

The team has been doing great since the 1.0 release, expanding Rubinius compatibility and improving performance. Coming up in the next few months, we’ve got three key features we’re really excited about: 1.9 support, Microsoft Windows support, and true concurrency. These are big ticket items that we’ve been asked about a lot, and that will push Rubinius into more and more developers hands.

I’d like to thank everyone for all the support this year. It’s been a wonderful year full of great releases. Seeing Rubinius continue to grow and blossom in 2011 should be even better!

Popularity: 3% |

Post-Deploy Notifications on Engine Yard Cloud

By | December 21st, 2010 at 12:12PM

Our latest post is from special guest and Engine Yard customer Matt Cowley. Matt is a freelance developer and the web manager at WMNF Community Radio. He can be found at http://www.madcowley.com. Matt originally published this post to his blog. Many thanks to Matt for pulling together the helpful info, and for allowing us to share it with you.

I’ve got a project hosted on Engine Yard’s cloud servers, with geographically-dispersed team. The developers are often working on separate feature sets, often deployed independently. As a quality-control and awareness measure we wanted to be notified when a deploy was done.

This was pretty easy to set up, and would work with capistrano deployments also.

First we set up a mailer action; I used an existing mailer class for this but you might want to create a separate class just for process-type notifications:

def deploy_notification(attribs)
  subject       "A build of my_project was deployed to #{attribs[:env_name]}"
  from          "MyProject CodeMonkey HQ"
  @from =       "notify@example.com"
  recipients    "bullwinkle@example.com"
  sent_on       Time.now
  body          :revision => attribs[:revision], :env_name => attribs[:env_name]
end

and the corresponding deploy_notification.text.plain.erb:

Heads up code monkeys! New code has been deployed to < %= @env_name %>
 
Details:
 
Environment: < %= @env_name %>
Revision: < %= @revision %>

I’ll probably make that a little fancier with a direct link to the commit on the githubs, and possibly pull in the commit message etc.

Next, we add a rake task to call the mailer; I put this in /lib/tasks/deploy.rake:

namespace :deploy do
  desc "notify developers of deployment"
  task :notify => :environment do
    attribs = {}
    ARGV.each do |arg|
      if arg.match(/TO=(.*)/)
        attribs[:env_name] = $1
      elsif arg.match(/REVISION=(.*)/)
        attribs[:revision] = $1
      end
    end
    SupportMailer.deliver_deploy_notification(attribs)
  end
end

Finally, for Engine Yard integration, in deploy/after_restart.rb:

# notify dev team of deploy
run "cd #{release_path} && rake deploy:notify TO=#{@configuration[:environment]} REVISION=#{@configuration[:revision]}"

That gets called by the engineyard chef scripts after the deploy finishes. For capistrano deployments, you could do the same in an “after deploy:restart” call.

That’s it. Hope it’s helpful.

Again, many thanks to Matt Cowley for this post originally published to his MadCode blog on November 24, 2010.

Popularity: 1% |

Connecting the Worlds of Java and Ruby with JRuby Webinar

By | December 20th, 2010 at 12:12PM

Thanks to everyone who took the time to watch our latest webinar on Ruby, JRuby and Rails. The full video recording is now available for viewing, as are the presentation slides. We realize one hour is not sufficient time to do any of the three topics justice, so we’re planning to do a series of upcoming webinars to delve deeper into specific topics. Please let us know in the comments section about specific topics you’d like addressed.

The slides from the presentation can also be downloaded.

We ran out of time before getting to all your questions. Here are my responses to the questions we weren’t able to field during the live webinar.

What are the best communities or places to go to ask questions and learn more about JRuby on Rails?

Certainly JRuby.org and the JRuby mailing lists, and to some extent the Rails mailing lists if the questions are not too JRuby-specific. We on the JRuby team also monitor JRuby-related questions on StackOverflow.com, and there is a volume of questions there already.

The JRuby team also is usually present in the IRC room #jruby on irc.freenode.net, so feel free to stop by there to chat. You can also follow @jruby on Twitter to stay on top of important updates.

Do you have any prediction or comments on Ruby/JRuby adoption in the enterprise in the next couple of years?

I’m personally bullish on JRuby adoption and consider it part of my mission on the JRuby team to make it happen. It’s hard to say in exact terms how it will increase, but a number of factors, such as the growing acceptance and maturity of Ruby and Rails, the participation at JRuby-related events, the new Using JRuby book, and the availability of knowledge, training, and documentation around Ruby and JRuby should all play a role.

We also typically have a hard time knowing exactly how many people are using JRuby, because of course they’re not required to tell us. We are usually surprised at conferences and meetups to hear of another organization successfully using JRuby in their own projects.

Any business looking to try to inject new life into their Java-based projects should look at JRuby to help accelerate development of their systems and take advantage of the array of innovations the Ruby and Rails communities have brought to web development and cloud computing.

How is the gem support in JRuby? For example, can I use Nokogiri?

Gem support is generally good. For Nokogiri in particular, check out the 1.5 beta releases which will have a pure-Java backend to replace the previous issues suffered with the FFI implementation.

We tend to lag a bit behind the community for releases of gems that contain C extensions. The new C extension API support in the upcoming JRuby 1.6 release will mitigate that a bit, but we also rely on the community to help us port the most popular gems when it’s apparent that a Java-backed API would be more useful.

How is the refactoring support in Ruby dev tools?

It’s not up to par with Java-based refactoring tools, but rarely do you need that level of control. Tools like RubyMine help with renaming, extraction and organization of code. Of course any refactoring exercises should be supported by a solid test suite, and fortunately Ruby has a strong culture of testing to reinforce that.

We are building iPad, iPhone and Android apps in HTML5, based on jQuery. Can we use JRuby with an Engine Yard background running?

Sounds like a great choice! We’d be happy to help you get up and running.

How to access a Spring context from a JRuby on Rails controller?

We actually have a nice JRuby on Rails article on the JRuby wiki on this topic. It should still basically work, let us know if you have any problems following it.

Any info on including JRuby as a scripting framework in a NetBeans platform application?

I haven’t heard any specifics around NetBeans RCP development using JRuby, but it sounds like a good idea. Start with documentation on the JRuby wiki on JRuby’s embedding API to get an idea of some possibilities.

As always, feel free to contact us for help or more ideas. We want to hear from you.

Popularity: 2% |