多租户轨道应用:不同技术的优缺点是什么? [英] Multi-tenant rails application: what are the pros and cons of different techniques?

查看:169
本文介绍了多租户轨道应用:不同技术的优缺点是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最初写了一个客户端的Ruby on Rails应用程序。现在,我正在改变它,以便可以用于不同的客户端。我的最终目标是一些用户(不是我)可以点击一个按钮并创建一个新的项目。然后生成所有必要的更改(新模式,新表,处理代码),而无需任何人需要我编辑database.yml文件或添加新的模式定义。我目前正在使用SCOPED访问。所以我有一个项目模型和其他相关的模型有一个project_id列。



我已经看过Rails中有关多租户应用程序的其他帖子。很多人似乎建议为Postgres中的每个新客户创建一个不同的模式。但是对于我来说,对于新的客户端来说,在数据模型方面有不同的架构并不是很有用。每个客户端将具有相同的表,行,列等。



我对每个客户端的看法是,我的生产数据库首先具有不同项目/客户端的表。并且这些表中的每一个链接到与不同数据几乎相同的一组表。换句话说,一张桌子。或者换句话说,第一张表将映射到具有相同结构的每个客户端的不同数据集。



我是否解释了我的愿景到Postgres实现不同的模式的方式?它看起来像嵌套表吗?或者Postgres还要查询数据库中的所有信息?我目前不使用Postgres,但是如果它符合设计,我会乐意学习。如果您知道使用适合我需要的Rails的数据库软件,请告诉我们。



现在,我正在使用范围来完成多租户应用程序,但它不能感觉到可扩展或干净。但是,如果非技术用户提供可填写的信息,则可以轻松创建新项目。您是否知道多格式Postgres定义是否可以在用户单击按钮后自动工作?我更喜欢这是由Rails处理,而不是由外部脚本处理? (请您以任何方式提供建议)



最重要的是,您是否建议使用任何插件,或者我应该为此任务采用不同的框架?我发现Rails在某些抽象抽象的情况下是有限的,这是我第一次碰到一个Rails扩展问题。



有关多重的任何建议应用程序或我的情况是受欢迎的。欢迎任何澄清或其他建议的问题。



谢谢,
--Dave

解决方案

不要忘记使用默认范围,同时创建名为scops的方式,您现在的工作方式感觉好像可以做得更好。关于这个问题,我遇到了Samuel Kadolph的本指南几个月前,它看起来可能适用于您的情况,并有利于保持您的应用程序没有一些PgSQL的功能。



基本上他描述设置的方式应用程序包括将t the the the the the the the the the the b b b b b b b b b b b b。。。。。。。。。。。。。。

I originally wrote my Ruby on Rails application for one client. Now, I am changing it so that it can be used for different clients. My end-goal is that some user (not me) can click a button and create a new project. Then all the necessary changes (new schema, new tables, handling of code) are generated without anyone needing me to edit a database.yml file or add new schema definitions. I am currently using the SCOPED access. So I have a project model and other associated models have a project_id column.

I have looked at other posts regarding multi-tenant applications in Rails. A lot of people seem to suggest creating a different schema for each new client in Postgres. For me, however, it is not much useful for a new client to have a different schema in terms of data model. Each client will have the same tables, rows, columns, etc.

My vision for each client is that my production database first has a table of different projects/clients. And each one of those tables links to a set of tables that are pretty much the same with different data. In other terms a table of tables. Or in other terms, the first table will map to a different set of data for each client that has the same structure.

Is the way I explained my vision at all similar to the way that Postgres implements different "schemas"? Does it look like nested tables? Or does Postgres have to query all the information in the database anyway? I do not currently use Postgres, but I would be willing to learn if it fits the design. If you know of database software that works with Rails that fits my needs, please do let me know.

Right now, I am using scopes to accomplish multi-tenant applications, but it does not feel scalable or clean. It does however make it very easy for a non-technical user to create a new project provided I give them fillable information. Do you know if it is possible with the multi-schema Postgres defintion to have it work automatically after a user clicks a button? And I would prefer that this be handled by Rails and not by an external script if possible? (please do advise either way)

Most importantly, do you recommend any plugins or that I should adopt a different framework for this task? I have found Rails to be limited in some cases of abstraction as above and this is the first time I have ran into a Rails-scaling issue.

Any advice related to multi-tenant applications or my situation is welcome. Any questions for clarification or additional advice are welcome as well.

Thanks, --Dave

解决方案

Dont forget about using default scopes, while creating named scops the way you are now works it does feel like it could be done better. I came across this guide by Samuel Kadolph regarding this issue a few months ago and it looks like it could work well for your situation and have the benefit of keeping your application free of some PgSQL only features.

Basically the way he describes setting the application up involves adding the concepts of tennants to your application and then using this to scope the data at query time using the database.

这篇关于多租户轨道应用:不同技术的优缺点是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆