PDA

View Full Version : How can I access my app's database from another app?


PeterNic
07-06-2007, 05:02 PM
Q: If I already have one application on the grid, and now I want to have a second application access the first app's database, how can I do it?

A: There are two approaches:

#1. Integrate the second app into the first -- just add the second app's appliances to the first application, connect to the database. If you have high volume of traffic between the second app and the database, this is the better approach, especially if the second app cannot function without access to the database (or you plan to integrate the two apps further). See attached diagram (the first app has webin gateway, webfarm web servers and dbase MySQL database; the second app has its own webin2 gateway, webfarm2 web servers and is connected to the same database).

#2. In the first app, add a gateway connected directly to the database, allowing access from the outside (similar to the approach used to allow ssh logins in the LampCluster reference application in AppLogic 2.0). In the second app, use an output gateway in the place of the database, point the gateway's remote_host property to the database gateway. See the second and third diagram (the first app, App1, has its own webin and webfarm, it also has a dbin gateway connected to the database; the second app, App2, has its own webin2 gateway and webfarm2 and talks to the database via the dbout gateway).

If using the second approach, it will make sense to set the allowed_ip property of dbin to the IP address of the dbout gateway, thus allowing traffic to the database only from the second app. Also, in the second approach, if you have high volume of traffic to the database, consider asking your hosting provider to arrange for a separate front-end switch so you are not billed for this as internet traffic. (See http://support.3tera.net/showthread.php?p=172#poststop).

And, for bonus points, approach #3: consider exposing the access to the database through a web services interface instead of through direct access to the SQL database. This way you will decouple the structure of the database in the first app from the structure of the database expected by the second app (and will allow you to add a third app, a fourth app, and so on). Use this approach if the two apps need to stay separate.

Regards,
-- Peter