开发者

Content Managment of multiple rails applications using a single mysql database

I intend to create multiple rails blogging applications with similar functionalities. To cut down on time spent managing these rails applications I have decided to create a single content management system to oversee them all. eg. content.example.com

In the design of this CMS i have been debating whether to use a single mysql database containing the data for all of the blogging apps. This singular database would be on the CMS app ("content.example.com"), which the other applications would then query for their data.

Blogging App:

//model Blog.rb

class Blog < ActiveRecord::Base  
establish_connection "external_cms"  
end

//database.yml

external_cms:
  adapter: mysql
  database: root/to/external/cms_db
  username: user
  password: password

In this scenario the CMS apps database would become very large quickly, slowing down the queries from the blogging apps. Even with Indexing i'm aware that this might not be a viable option. I've read o开发者_如何转开发n a few blogs also to consider is that the schema.rb and models of the blogging apps would need to be identical to that of the CMS app. In my testing so far ive found that schema.rb does not have to be the same at all (have not tested whether models need to be identical).

Is it common practice to run multiple apps off the same database? And if not is it becuase of the slowing on queries and the headaches associated with needing to keep schema.rb and models identical?

As well as indexing what are other ways in which i can speed up the queries to compensate for a large database?

what are my alternatives to running a single database whilst keeping the one CMS?


This question pops often, it's best for you to read up on multitenancy and whether or not it makes sense for you.

My advice is start with all your blogging apps using the same database and then shard when performance becomes a problem (which it might never).

There are many ways to speed up database access, with the first line of defense being caching.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜