Using an external (standalone) Neo4j server

312 views
Skip to first unread message

Reuven M. Lerner

unread,
May 3, 2011, 8:07:36 AM5/3/11
to neo4jrb
Hi, everyone. I'm new to Neo4j, and am using it on a site for a
client. So far, I'm pleased and impressed. Thanks to everyone
working on the Ruby driver, as well as the Rails support.

I'm wondering if it's possible to use Neo4jrb in a Rails application
(under JRuby, of course), but without the integrated Neo4j server.
That is, when I type "rails s", I currently get both a Rails server
and a Neo4j server. I'm expecting that we will eventually want to
have our Rails server running on a separate machine from the Neo4j
server, and for them to communicate over the network. Also, I'd like
to run both my Rails server and my Rails console at the same time,
without having one of them in read-only mode. Setting
config.neo4j.storage_path to a URL, which I had sorta hoped would
work, didn't.

I'm sure that there's a relatively easy way to turn off the built-in
Neo4j server and to connect to an external server -- but would someone
please tell me how? (And if there are any serious reasons not to do
this, please let me know.)

Thanks,

Reuven

Andreas Ronge

unread,
May 3, 2011, 1:39:13 PM5/3/11
to neo...@googlegroups.com
Hi

The options are either you use the embedded neo4j.rb with JRuby or
you use the neo4j server and talking HTTP/Rest with it
(http://wiki.neo4j.org/content/Using_the_Neo4j_Server_with_Ruby)
Neo4j.rb does not have any bindings to the neo4j server (Neography does).


I agree it is annoying that the rails console only works in read only
mode if the server
is already running !
If you want to run several rails-neo4j instances at the same time, check this:
http://neo4j.rubyforge.org/guides/ha_cluster.html
Btw, why do you want to run the rails server and neo4j on different machines ?

Cheers
Andreas

> --
> You received this message because you are subscribed to the Google Groups "neo4jrb" group.
> To post to this group, send email to neo...@googlegroups.com.
> To unsubscribe from this group, send email to neo4jrb+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/neo4jrb?hl=en.
>
>

Reuven M. Lerner

unread,
May 4, 2011, 1:14:36 AM5/4/11
to neo4jrb

On May 3, 8:39 pm, Andreas Ronge <andreas.ro...@gmail.com> wrote:

> The options are either you use the embedded neo4j.rb with JRuby or
> you use the neo4j server and talking HTTP/Rest with it
> (http://wiki.neo4j.org/content/Using_the_Neo4j_Server_with_Ruby)
> Neo4j.rb does not have any bindings to the neo4j server (Neography does).

If I understand you correctly, you're saying that if I want to enjoy
the ActiveModel stuff that comes with neo4j.rb, then I have to use it
with JRuby and the embedded server?


>
> I agree it is annoying that the rails console only works in read only
> mode if the server
> is already running !

Yeah, this is a really big annoyance for me, and probably the main
reason why I want to have a separate server running. I'm a very heavy
console user, and hate having to bring things up and down just to play
with things in the console. Being able to use 1.9.2 rather than JRuby
is also appealing, especially given that I have a lot of experience
deploying standard Rails apps, and very little deploying JRuby apps.

> Btw, why do you want to run the rails server and neo4j on different machines ?

Over time, I expect that we'll need multiple Web servers running
against a single Neo4J server -- just as you do when scaling a Web app
that uses a relational database.

Reuven

Andreas Ronge

unread,
May 4, 2011, 2:46:04 AM5/4/11
to neo...@googlegroups.com
On Wed, May 4, 2011 at 7:14 AM, Reuven M. Lerner <reu...@lerner.co.il> wrote:
>
> On May 3, 8:39 pm, Andreas Ronge <andreas.ro...@gmail.com> wrote:
>
>> The options are either you use the embedded neo4j.rb with JRuby or
>> you use the neo4j server and talking HTTP/Rest with it
>> (http://wiki.neo4j.org/content/Using_the_Neo4j_Server_with_Ruby)
>> Neo4j.rb does not have any bindings to the neo4j server (Neography does).
>
> If I understand you correctly, you're saying that if I want to enjoy
> the ActiveModel stuff that comes with neo4j.rb, then I have to use it
> with JRuby and the embedded server?
Yes. In neography you get almost the same syntax as for the
Neo4j::Node and Neo4j::Relationship but no ActiveModel stuff.

>
>
>>
>> I agree it is annoying that the rails console only works in read only
>> mode if the server
>> is already running !
>
> Yeah, this is a really big annoyance for me, and probably the main
> reason why I want to have a separate server running.  I'm a very heavy
> console user, and hate having to bring things up and down just to play
> with things in the console.

Ok, I will see what I can do.

> Being able to use 1.9.2 rather than JRuby
> is also appealing, especially given that I have a lot of experience
> deploying standard Rails apps, and very little deploying JRuby apps.

Yes, using 1.9.2 and deploying on heroku is hard to beat.
But if you got a capistrano script it is also just one line to do the
deployment.
I'm currently using vps.net cloud for some projects and it does not
take too long time to configure the machine and capistrano script.

>
>> Btw, why do you want to run the rails server and neo4j on different machines ?
>
> Over time, I expect that we'll need multiple Web servers running
> against a single Neo4J server -- just as you do when scaling a Web app
> that uses a relational database.

One interesting alternative is deploying several Rails servers bundled
with embedded HA enabled Neo4j instances.

Krasimir Angelov

unread,
May 4, 2011, 3:53:17 AM5/4/11
to neo...@googlegroups.com
So even if you run HA cluster, all these (RoR app and neo4j instances) will run on same machine? is this correct or I'm getting it wrong?

Andreas Ronge

unread,
May 4, 2011, 3:58:54 AM5/4/11
to neo...@googlegroups.com
No, you would typically run it on different machines and have a load
balancer in front of it like Apache.

Andreas Ronge

unread,
May 4, 2011, 4:01:42 AM5/4/11
to neo...@googlegroups.com
Sorry I think I misunderstood you. You should run the RoR app and the
embedded neo4j instance in the same process/machine
but you will have several machine running RoR app each with an
embedded HA Neo4j db.

Krasimir Angelov

unread,
May 4, 2011, 4:49:11 AM5/4/11
to neo...@googlegroups.com
So I may have few machines, each one running both Rails app and embedded Neo4j instance, but all these Neo4j instances will be in HA cluster. Correct?

Andreas Ronge

unread,
May 4, 2011, 6:12:58 AM5/4/11
to neo...@googlegroups.com
Yes, they all will be in a cluster so that the database will be synchronized.

Andreas Ronge

unread,
May 4, 2011, 6:22:36 AM5/4/11
to neo...@googlegroups.com
>> I agree it is annoying that the rails console only works in read only
>> mode if the server
>> is already running !
>
> Yeah, this is a really big annoyance for me, and probably the main
> reason why I want to have a separate server running.  I'm a very heavy
> console user, and hate having to bring things up and down just to play
> with things in the console.

I think the best and easiest solution would be to have a console page
visible in your rails application.
Maybe one can even steal some of the code from IRB and expose that as
a web page ?
Who wants to implement this :-)

Another alternative, which I think is more complicated, is running the
embedded database as an HA instance.
Then the rails console start up with a HA enabled neo4j.rb.

Krasimir Angelov

unread,
May 4, 2011, 9:57:47 AM5/4/11
to neo...@googlegroups.com
Cool. Thanks for the answers.

Krasimir Angelov

unread,
Oct 20, 2011, 6:47:45 AM10/20/11
to neo...@googlegroups.com
Here's something I saw lately - http://devender.wordpress.com/2011/10/17/neo4j-running-embedded-server-with-webconsole/

Can it help somehow? May be not for rails console but for using the webconsole...

Reply all
Reply to author
Forward
0 new messages