# Question about drb and databases

**URL:** <https://www.ruby-forum.com/t/question-about-drb-and-databases/69551>\
**Category:** Ruby\
**Created:** [September 21, 2006, 6:54pm UTC](https://www.ruby-forum.com/t/question-about-drb-and-databases/69551 "2006-09-21T18:54:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [September 21, 2006, 6:54pm UTC](https://www.ruby-forum.com/t/question-about-drb-and-databases/69551/1 "2006-09-21T18:54:14Z")

</div>

Let’s say I have 2 servers. One has the database, the other doesn’t. The  
main application is being ran on the one with the database. If I was to  
distribute ruby using DRb to the other server does that process need a  
different kind of database connection? Basically what I’m asking is do I  
need to connect to the database using localhost or the IP? Because wont  
the database calls go over the wire like all of the other calls  
therefore a localhost connection should work, right?

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [September 21, 2006, 7:12pm UTC](https://www.ruby-forum.com/t/question-about-drb-and-databases/69551/2 "2006-09-21T19:12:43Z")

</div>

Ben J. wrote:

> Let’s say I have 2 servers. One has the database, the other doesn’t. The  
> main application is being ran on the one with the database. If I was to  
> distribute ruby using DRb to the other server does that process need a  
> different kind of database connection? Basically what I’m asking is do I  
> need to connect to the database using localhost or the IP? Because wont  
> the database calls go over the wire like all of the other calls  
> therefore a localhost connection should work, right?

No – unless I am not understanding you. But if both machines are on the  
same intranet, the IP approach (using an intranet IP) should be fairly  
swift.

Strictly speaking, ‘localhost’ refers to a particular machine’s  
self-identity, not to an intranet machine’s identity.

---

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [September 21, 2006, 7:25pm UTC](https://www.ruby-forum.com/t/question-about-drb-and-databases/69551/3 "2006-09-21T19:25:38Z")

</div>

Paul L. wrote:

> Ben J. wrote:
> 
> > Let’s say I have 2 servers. One has the database, the other doesn’t. The  
> > main application is being ran on the one with the database. If I was to  
> > distribute ruby using DRb to the other server does that process need a  
> > different kind of database connection? Basically what I’m asking is do I  
> > need to connect to the database using localhost or the IP? Because wont  
> > the database calls go over the wire like all of the other calls  
> > therefore a localhost connection should work, right?
> 
> No – unless I am not understanding you. But if both machines are on the  
> same intranet, the IP approach (using an intranet IP) should be fairly  
> swift.
> 
> Strictly speaking, ‘localhost’ refers to a particular machine’s  
> self-identity, not to an intranet machine’s identity.

Right, but if I distribute ruby onto a completely different machine the  
ruby files do not have to be present over there do they? Does it cache  
them on the other server or do everything over the wire?

I’m doing a ruby on rails project here. So, if it does everything over  
the wire, wouldn’t it do the db calls over the wire as well since the db  
calls run through the ActiveRecord files?

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [September 21, 2006, 8:45pm UTC](https://www.ruby-forum.com/t/question-about-drb-and-databases/69551/4 "2006-09-21T20:45:00Z")

</div>

On Sep 21, 2006, at 10:25 AM, Ben J. wrote:

> > > is do I
> 
> the db  
> calls run through the ActiveRecord files?
> 
> Thanks for your help.
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

Hey Ben-

```
You are going to need to use an IP connection for the drb server on

```

the machine without the database. If you want it to be able to run  
queries and work with your models it needs a db connection. Unless  
the only way you access your models is over drb and the models  
include DRbUndumped on the machine with the database. But I think  
that for what you are trying to do, you will need to have the drb  
server on the machine with no database, use an IP address as its host  
in the database.yml file.

-Ezra
