开发者

Most appropriate web framework for multi-tenant / multi-template SAAS application

开发者 https://www.devze.com 2023-03-07 06:44 出处:网络
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, butI thought I\'d a

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 rustie开发者_如何转开发r, 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.


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.


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...


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.)


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

0

精彩评论

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