通过 Rails 托管多个站点 - 我应该使用一个还是多个 Rails 实例?
我正在构建一个 Rails 应用程序,它将托管多个射箭联盟网站。我们将其命名为 myarchery.com,并假设我有 2 个网站:billsleague.myarchery.com 和 jimsleague.myarchery.com。
现在,当我构建这个时,我可以:
让一个 Rails 应用程序提供子域(basecamp 样式),共享所有模型等,但在所有内容上添加帐户属性
使用自己的 Rails 应用程序实例设置每个帐户
我更喜欢全部运行它们在一种情况下 - (B/CI可以在注册、单次登录等时立即设置其网站)。然而,我想看看是否有合法的理由独立运行它们。
我计划使用 apache/passenger 在 Linode 上运行它,如果这会影响你的答案
I am building a rails app that will host multiple archery league websites. Lets call it myarchery.com, and say I have 2 sites: billsleague.myarchery.com and jimsleague.myarchery.com.
Now when I build this I can either:
Have one rails app serve up the subdomains (basecamp style), sharing all models, etc, but putting an account attribute on everything
Set each account up with its own rails app instance
I prefer running them all in one instance - (B/C I can set their sites up immediately when they sign up, have a single login, etc). However, I wanted to see if there legit reason to run them independently.
I plan to run this on a Linode using apache/passenger, if that influences your answer
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用rails3,您可以“免费”获得子域路由。 请参阅http://railscasts.com/episodes/221-subdomains-in-rails-3。
我不明白为什么你需要所有东西的帐户属性;您的正常关联应该允许您确定子对象的所有权。
每个子域运行多个实例可能看起来更简单,但您将在维护方面付出高昂的代价。它只是不能很好地扩展。
Using rails3, you get subdomain routing 'for free'. See http://railscasts.com/episodes/221-subdomains-in-rails-3.
I don't see why you'd need an account attribute on everything; your normal associations should allow you to determine ownership of subobjects.
Running multiple instances per subdomain might seem simpler, but you will pay a heavy price in maintenance. It just does not scale well.
我认为,如果它们是同一个站点,运行一个实例就可以了,但如果您需要以不同的方式对它们进行标记,您可以通过分割不同的位并使用 svn externals 来加载不同的位来受益,例如资产和布局。
无论哪种方式都可以正常工作,将它们全部放在一个实例中可以更轻松地维护代码。
I would think that if they are the same site, running one instance is fine, but if you need to brand them differently, you could benefit from splitting the bits that differ and use, say, svn externals to load in the bits that differ, such as assets and layouts.
Either way works fine, having them all in one instance makes it easier to maintain your code.