Hello Graphistas and Rubyists!

Now Heroku has become a language polyglot platform , we’re happy to announce that we’re enhancing the NOSQL ecosystem for Heroku customers and users by releasing the Neo4j-Graph Database Add-On.

The Neo4j-Graph Database Add-On became “public” this week, so it’s available to all registered beta-testers of the Heroku PAAS platform. This is the first step in our efforts to provide hosted Neo4j Servers to a number of PAAS providers. And the Neo4j Add-On is currently available for free with the test plan, which we think is pretty cool.

+  =

What is a Graph Database ?

A graph database is a type of NOSQL datastore suited for interconnected data. It stores its content as nodes connected via relationships, both of which can have any number of properties (this particular model is known as a property-graph).

Graph databases have constant time query characteristics for local data access which is independent of data set size. They are a perfect fit for storing object networks but don’t rely on fixed schemas, so highly dynamic domains are more than welcome (in both dimensions – properties and connections).

In terms of scalability, Neo4j currently scales up well since graphs tend to require far fewer writes than traditional RDBMS to achieve the same informational goals. Neo4j scales out reasonably too (especially for reads) through master/slave replication (where slaves are writable). An instance of Neo4j can handle billions of nodes and relationships on a single machine typically surpasses other technologies (like RDBMS) when executing the graph equivalent of multi-join queries.

Provisioning a Neo4j Server instance

For the Heroko Neo4j Add-On we’ve created our own hosting infrastructure on AWS EC2 instances co-located in the same region (us-east). As a Heroku user, you can add Neo4j to you application by simply issuing the following command:

> heroku addons:add neo4j:test
A Neo4j Server will then be provisioned for your application (with currently generous amounts of RAM). You may visit the heroku page for your add-on to see the following information.

Neo4j Add-On Settings


Most of this connection information is also available via

> heroku config.

The first link points to the Neo4j Web Administration UI which allows you to visualize and manage certain aspects of your graph database.

The second link (REST-URL) is used by your application to connect to the Neo4j Server.
(Please note that unlike the Neo4j Server available from http://neo4j.org/download this setup requires a username and password for basic authentication).

The Backup & Restore feature allows to you to pull the current content of your database anytime (suspending the server meanwhile) and replacing the available content with alternative data-sets.
For your convenience we began to provide datasets and will add more of them in the future so that you can start to explore larger graphs right away.

Please note that for saving capacity we suspend idle instances after 24 hours of inactivity. The fist request of a suspended instance will take longer than usual as the instance has to be resumed.

Your first Application

The simplest setup for a application using the Neo4j-Server would be using a REST library like rest-client. Anyway the usage with rest-client would look like this.

irb> p JSON.parse(RestClient.get ENV['NEO4J_URL'])

Remember that instances of Neo4j are suspended after periods of inactivity, so the first call to an instance may take a little longer than normal as the instance is resumed.

A gem like neography encapsulates all the low-level details of the API and provides a clean object-oriented way of interacting with the Neo4j-Server.

# i_love_you.rb
require 'sinatra'
require 'neography'

neo = Neography::Rest.new(ENV['NEO4J_URL'] || "http://localhost:7474")

def create_graph(neo)
# procedural API
me = neo.get_root
pr = neo.get_node_properties(me)
return if pr && pr['name']
neo.set_node_properties(me,{"name" => "I"})
you = neo.create_node("name" => "you")
neo.create_relationship("love", me, you)
end

create_graph(neo)

get '/' do
## object-oriented API
me = Neography::Node.load(neo, 0)
rel = me.rels(:love).first
you = rel.end_node
"#{me.name} #{rel.rel_type} #{you.name}"
end

(J)Ruby Server Side Extensions

The Neo4j Heroku Add-On contains one more new piece of functionality that can be added to the Neo4j-Server: the ability to extend behavior of the server in other languages than Java.

Since we want to support efficient execution of code written in dynamic programming languages like Ruby, we’ve provided a means to move code to the server where it is executed performantly close to the underlying database. We employ JRuby on the server to run rack-applications packaged as ruby gems (for easier management versioning).

Those rack applications can use gems like neo4j.rb to access Neo4j directly without any intermediate or remote layers. This allows a more granular, batch oriented domain level REST API to your front-end providing (or consuming) all the information that has to be exchanged with the graph database in one
go.

A simple example of an application split into a persistence back-end and a front-end hosted on heroku is available on the Heroku documentation page or on the Neo4j wiki. We also made the sample code available on github.

Documentation Galore

Everything you read here and even more details are available on our Heroku Neo4j Add-On documentation page. This page is password protected as part of the private beta process. But you can read most of the documentation on the Neo4j Wiki as well.

 

Keywords:  


4 Comments

Anonymous says:

Hi. May I test this addon? I'm founder of http://neo4j.tw

Jeroen says:

Thanks for this post. I would also like to have beta access. Where should I apply?

Marnen says:

Has the JRuby server-side extension stuff gone missing? It's not mentioned on the current Heroku Neo4j documentation page, and the wiki is gone.

Hello Marnen,<br /><br />Yes, the jruby server-side extension is no longer available for Neo4j on Heroku. We&#39;re considering support for it and other extensions in the future, but for now all databases will have a restricted environment on the server side. <br /><br />Best,<br />Andreas

Leave a Reply

Your email address will not be published. Required fields are marked *

Stay Connected

Go
 

Have a Graph Question?

Stackoverflow
Contact Us


Popular Graph Topics

Archives