Multi-Tenant Rails 3 App on Heroku using PostgreSQL

痴心易碎 提交于 2019-12-20 14:39:55

问题


I have a multi-tenant app on Heroku (multiple Accounts that know nothing about each other), and I'm unsure as how to best architect my database. Postgres's schemas look awesome, but heroku doesn't handle large numbers of them well.

Now, my Rails app is mainly serving JSON, as most of the templates are rendering client-side (using Backbone.js). So I'm considering moving to MongoDB because 1) each tenant could get one top level 'account' document, and everything could be nested below and 2) its storage format so closely resembles JSON. We are still in beta, so it could be pulled off. Are those valid reasons to use Mongo? Is former even an intelligent way to use Mongo?

If I were to stick with postgres, should everything belong_to the top level Account model (with indexes)? If so, how would I handle joins? Is it possible to perform mult-index joins (total postgres noob)?

We have about 60k entries in one table so far, yet a single account may only have 200-1000, so I'm worried about joining on the entire table.

Really appreciate any help.

Update:

We ended up moving to a VPS (Rackspace Cloud) and implementing postgres's schemas. No regrets with this move as it runs much faster than it did on Heroku, and we have more control of the server.


回答1:


Check out this gem which was written to do multi-tenancy with postgres http://railscraft.tumblr.com/post/21421806379/multi-tenanting-ruby-on-rails-applications-on-heroku



来源:https://stackoverflow.com/questions/11111617/multi-tenant-rails-3-app-on-heroku-using-postgresql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!