最适合多租户/多模板 SAAS 应用程序的 Web 框架

发布于 2024-11-08 16:46:25 字数 643 浏览 4 评论 0原文

我正在构建一个新的 SAAS 应用程序,并正在寻找一些关于最合适的框架的建议。我意识到没有一个框架能够完成所有这一切,但我想我应该询问社区并尝试找到一个能够解决最困难问题的框架。

要求

  1. 单一代码源。 (每个客户将有一个子域或一个不同的域,但每个人都应该在相同的代码库和相同的服务器上运行)
  2. 应该能够更新编程源一次并让所有租户都选择它
  3. 会话信息应该是保存在缓存存储中,或仅保存在 cookie 中(无共享状态)
  4. 内置多租户数据库功能。(根据用于访问应用程序的域,框架应自动使用分配给该域的数据库连接信息)
  5. 每个客户/domain 可能有自己的网络模板页。模板需要根据每个客户进行分配,并保留在应用程序代码之外
  6. 安全性和快速原型设计比速度更重要
  7. 将会有很多 CRUD 类型屏幕,因此需要简单的内置功能

我有相当长的 Java和 PHP 经验,但只会将 PHP 视为最后的手段。我的 Scala、Python 和 Ruby 经验有点生疏,但如果它们能提供显着的优势,我不介意加快速度。我看过这部剧!框架并喜欢它(很好地满足了#1、#2、#6),但多租户方面不是很强。我已经使用 Grails 完成了几个项目,它可以处理除 #3 和 #5 之外的所有内容,并且可以通过 hack 来完成其余的工作。

I'm building a new SAAS application and was looking for some advice on the most appropriate framework to use. I realize that no single framework will likely be able to do all this, but I thought I'd ask the community and try to find one that solves the hardest problems.

Requirements

  1. Single code source. (each customer will have either a subdomain, or a distinct domain, but everyone should be running off the same code base and same servers)
  2. Should be able to update the programming source once and have all the tenants pick it up
  3. Session information should either be kept in a cached store, or just in cookies (no shared state)
  4. Multi-tenant database functionality built in. (Based on the domain used to reach the application, the framework should automatically use the database connection information assigned to that domain)
  5. Each customer/domain may have their own template for the web pages. Templates need to be assignable on a per-customer basis and kept outside the application code
  6. Security and rapid prototyping is more important than speed
  7. There will be a lot of CRUD type screens, so simple built in functionality for this is desired

I have pretty lengthy Java and PHP experience, but would only consider PHP as a last resort for this. My Scala, Python and Ruby experience is a bit rustier, but I would not mind coming up to speed if they offer a significant advantage. I've looked at the Play! Framework and like it (fulfills #1, #2,#6 very well), but the multi-tenant aspects are not very strong. I've done several projects using Grails and it handles everything except #3 and #5, and can be hacked to do the rest.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

辞慾 2024-11-15 16:46:25

我想说第三点与 grails/play/无论什么一般都相当独立。如果您需要共享缓存,有很多提供者可以提供此服务,并且 Grails 中的大多数提供者都有插件。

grails 中的多租户非常成熟,并且比 Sebastien 回答中的博文中的解决方案侵入性要小得多。无论您使用单租户(多个数据库)还是多租户,对于您的代码来说都或多或少是透明的,并且大多数令人头疼的问题都被抽象化了。请注意,您需要执行一些智能索引(例如在多列索引中包含租户 ID 等),以免在数据开始增长时速度变得非常糟糕。

至于外部化视图,您可以将它们放入数据库中,也可以将它们符号链接到您的 web 应用程序中,然后将它们保存在单独的编号文件夹中。然后,在租户插件中,您可以使用 TenantUtils.getCurrentTenant() 并简单地从适当的文件夹中渲染 "/" + (tenantID ?: "default") + "/whatever/view/路径”。这样,如果您愿意,布局等可以在租户之间共享,并且您只需将租户特定的内容放入租户特定的文件夹中即可。

您或许也可以在游戏中执行此操作,或者,但我认为没有任何事情可以阻止您在 Grails 中很好地执行此操作。

我在这个问题上花费了 0.02 美元。

I would say that the third point is rather independent of grails/play/whatever in general. If you need a shared cache there is a multitude of providers for this and there are plugins for most of them in Grails.

The multi-tenancy in grails is pretty mature and much less intrusive than the solution from the blogpost in Sebastiens answer. Whether or not you use single tenancy (multiple databases) or multi tenancy is more or less transparent to your code and most of the headaches are abstracted away. Do be aware that you need to do some smart indexing (like including the tenant id in a multi column index etc) to not get very sad speeds when your data starts to grow.

As for externalized views, you can either slap them in the database or symlink them into your webapp and just keep them in separate numbered folders. Then from the tenant plugin, you can use TenantUtils.getCurrentTenant() and simply render from the appropiate folder "/" + (tenantID ?: "default") + "/whatever/view/path". This way, layouts etc can be shared across tenants if you so please and you simply put tenant specific stuff in the tenant specific folders.

You can probably do this in play too, or , but I don't see anything hindering you from doing this just fine in Grails.

My $0.02 on this question.

猫瑾少女 2024-11-15 16:46:25

实际上玩!非常适合您正在寻找的东西。

阅读这篇文章:
http://www .lunatech-research.com/archives/2011/03/04/play-framework-writing-multitenancy-application-hibernate-filters

效果很好。您甚至可以使这个过滤器工作,这样您就可以向客户公开 CRUD 模块,他们只会获得自己的数据...

对于非常大的应用程序,分片似乎尚不支持(我认为尚未处理休眠分片)。
有一个 multidb 插件可以处理多个数据库,但它似乎还不能很好地工作......

Actually Play! fits well to what you'r looking for.

Read this post:
http://www.lunatech-research.com/archives/2011/03/04/play-framework-writing-multitenancy-application-hibernate-filters

It works great. You can even make this filter work so that you can expose the crud module to customers and they'll only get their own data...

For very large applications, sharding seems not supported yet (no hibernate shards handled yet i think).
There's a multidb plugin to work with multiple db, but it seems not working very well yet...

满身野味 2024-11-15 16:46:25

我听说 Grails 的 多租户插件 为几种不同的方法提供了一些很好的工具的多租户。

“每个客户/域可能有自己的网页模板。
模板需要根据每个客户进行分配并保存
在应用程序代码之外”

我假设您的意思是它们每个都有自己的布局/皮肤。有几种技术可以执行此操作:

  • 您可以手动分配 布局 基于租户。

  • 编写您自己的租户感知 LayoutDecoratorMapper 并覆盖默认的 GrailsLayoutDecoratorMapper在 sitemesh.xml

  • 弄清楚如何覆盖和增强一些内部工具动态解析视图(per租户)或资源(GrailsViewResolver、GrailsConventionGroovyPageLocator、GrailsResourceLoader 等)

I've heard that Grails' Multi-Tenant plugin offers some good tooling for several different methods of multi-tenancy.

"Each customer/domain may have their own template for the web pages.
Templates need to be assignable on a per-customer basis and kept
outside the application code"

I assume you mean they each have their own layout/skin. There are several techniques to execute this:

  • You could manually assign layouts based on tenant. <meta name="layout" content="${tenantName}/main" />

  • Write your own tenancy aware LayoutDecoratorMapper and override the default GrailsLayoutDecoratorMapper in sitemesh.xml

  • Figure out how to override and enhance Some internal tools dynamically resolve views(per tenant) or resources (GrailsViewResolver, GrailsConventionGroovyPageLocator, GrailsResourceLoader, etc.)

小苏打饼 2024-11-15 16:46:25

在 PHP 中,您可以使用 Innomatic Platform 构建多租户(隔离数据库)应用程序:
http://www.innomatic.org

In PHP you can use Innomatic Platform for building multi-tenant (isolated databases) applications:
http://www.innomatic.org

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文