Cyril Rohr
Cyril Rohr.

How to get a major speedup on all OpenNebula command-line and OCCI tools

Long version is at

Short version is: switch to a Nokogiri based XML Stream parser for the XMLRPC client, instead of the (really) slow REXML based stream parser used by default. Then the ONE tools that make XML-RPC requests (i.e. almost all of them, including the OCCI server) will be a hundred times faster.

This is especially useful when you start to have more than 100 VMs running, since you’re not required to wait for more than 1 minute (!) for your onevm list or onevm top to display. These commands are now running in less than 1 second at our local installation.

The patch is really simple (to be applied to the OpenNebula.rb file, tested with OpenNebula 3.0.0):

>         NOKOGIRI_PARSER = begin
>             require 'stream_parser_mixin'
>             true
>         rescue LoadError
>             false
>         end
<             if XMLPARSER
>             if NOKOGIRI_PARSER
>                 @server.set_parser(
>             elsif XMLPARSER

You can get everything up and running with:

$ gem install xmlrpc-streaming nokogiri && \
curl | patch /usr/lib/one/ruby/OpenNebula.rb -

UPDATE: looks like you can get similar performance boost by installing the xmlparser Ruby gem, which uses the Expat XML parsing library (see this doc) and is already supported by OpenNebula for Ruby < 1.9.