About: multi database performance on Substruct

Hello,

I forked the sweet Substruct and applied Advanced Recipe 83: I associate a different shop (separate database) to each ‘installation’ according to the subdomain the application is accessed from. Do you think it makes sense? Basically AR queries main database once to fetch ‘installation’ object and connects to installation.database if the subdomain is configured or loads the demo database/shop instead. It seems a good idea (to me) to keep every (admin) account clearly separated and it’s by far easier not to completely re-write Substruct logic to manage more than one admin. Passenger on dreamhost.

the demo database/shop instead. It seems a good idea (to me) to keep
every
(admin) account clearly separated and it's by far easier not to
completely
re-write Substruct logic to manage more than one admin. Passenger on
dreamhost.

Sounds good to me if you can manage it :slight_smile:
-=R

So where's the fork?

Why you need to go for the isolated database for each tenant (shop)?
What are all the advantages and disadvantages of this? How you will
achieve this technically in ROR application? How the active records will
know what connection to use?

Just curious to know since we are also analyzing deep in what are all
the pros and cons in using the isolated database for each tenant. We
have some thought on this design. Just curious to know what others are
thinking on this.

Why you need to go for the isolated database for each tenant (shop)?

I’m trying to add multi admin/shop support to the application and, seen the original database structure, it seems easier just to use one database for each shop.

What are all the advantages and disadvantages of this?

This is what I’m trying to find out. So far, so good but I didn’t see any other application dealing with multiple database and when you’re the only one you’re usually on the wrong path!

how you will achieve this technically in ROR application? How the active records will know what connection to use?

This is quite easy: using subdomains for shops I just ask AcriveRecord to connect to the ‘current’ database, basically every database is a copy of the original one, I wrote some

new rake code (and found out later that I’m not allowed to script-create database, but this is another story!)

There is only one model, ‘Installation’ that always connects to the main database and it’s used to switch between shops. I’m trying to find out if shop switch can create a mess, but

everything is okay by far…

@installation = Installation.for(request.host, request.subdomains)

ActiveRecord::Base.establish_connection(:adapter => “mysql”,

:host => “localhost”,

:username => “root”,

:password => “”,

:database => @installation.database)

see http://mek.venicebuy.eu/ and http://usul.venicebuy.eu/ are running online

Just curious to know since we are also analyzing deep in what are all

the pros and cons in using the isolated database for each tenant. We

have some thought on this design. Just curious to know what others are

thinking on this.

I wish I could see this application with heavy load and we could understand! :slight_smile:

How you do the authentication and authorization in your multi-tenant
application? Are you using any authentication and authorization
plug-ins?

I’m using the normal Substruct authorization methods: each subdomain not only load the appropriate database (and every admin has his own password for his db), but also
create a different session and things stay clean and work (so far)!