Saas design ideas multi-tenant system architecture

Original link: https://blog.csdn.net/cnpinpai/article/details/91967335

ToB Saas fire system is very recent years. Many start-up companies are trying to create enterprise-level applications cRM, HR, sales, Desk Saas system. Many start-up companies also took a large Saas venture. After all Saas advantages compared to the traditional software is very obvious.  

The most recent year, the honor system architecture of a Crm saas, on the line for months, in all aspects than satisfied. The whole system creation process, step on a lot of the pit, the harvest will be more. To summarize Saas system architecture features:

Saas grading system :

5 levels of SaaS maturity model architecture - from the "chaos" to "Utopia."

The first level (confusion) 0 : Each time a new client, a new instance of the software will. Level 1 (controlled chaos) : All clients are running on the same version of the software, and any of the customization are achieved by modifying the configuration. Level 2 (multi-tenant [multi-tenant], high-rise buildings [Highrise]) : All customers are ready to run on the same version of the software, and they all run on the same "instance." Level 3 (multi-tenant, the expansion [Build-Out]) : At this point you already have a multi-tenant, single version of the software model. But you can still be extended by hardware extensions (scale-out) manner. Level 4 (Utopia) : Like Level 3, unless you can find an effective way to run different versions on different "instance" of software.

Applications must support multi-tenancy:

    Multi-tenant can be divided into several different categories (e.g., below the list shown in FIG.):     1.1, simple cloud virtualization, wherein only the shared hardware.     1.2, shared applications, use a different database for each tenant.     1.3, shared applications and databases (the highest efficiency, true multi-tenant).

1. hierarchical design

Saas hierarchical system is about:

640?wx_fmt=png

Saas System Hierarchy

Saas system hierarchy : tenant identification> Application Layer> data access layer> buffer layer> Database

Business codes are written in the application layer.

Tenant identification may be implemented spring interceptors, then transmitted to the rear ThreadLocal

Databases and caching layer to the application layer should be transparent. When programmers write code, and only care about business logic, we should not worry about multi-tenancy.

2. Data to be transparent isolation

saas system that is simple, any system seems to add tenant_id (tenant id) becomes saas the system. For example, the original user login is:

640?wx_fmt=png

Change

640?wx_fmt=png

For saas complex business systems, so practice is very dangerous and very low development efficiency. If you think about the time that programmers write sql forgot to add "and tenant_id = 1", the results could be disastrous.

Better approach is to rewrite the SQL database access layer.

640?wx_fmt=png

Sql rewritten according to the connection pool TenatnContext.

So good is that, a program to ape the system up to get down, and you will not be a string of information leaks from each other. And secondly, the future make points table and warehouses is also very convenient, the upper application without modification.

3. Tenant identification scheme

Better approach is to identify the tenant by url. The system is to generate a random tenants of third-level domains, such as abc.crm.baidu.com. If customers want to use your own domain name, we can go to the third-level domains generated in cname, and management systems which do bind.

Such a tenant can have two domain names, access saas, a randomly generated third-level domains, the other tenants own domain name. May come inside the code name, to determine that the tenant is then initialized TenantContext.

If you do not want to do through the domain name, it can be judged by the login name. This way to involve tenants switching problem.

4. Intelligent DNS

5. 租户管理系统(计费,订购,定制,充值,催缴)

Saas系统是必须考虑计费系统和租户控制系统。这个系统需要都是独立设计。比如那个租户购买了那些模块,一个月多少钱。租户可以创建最多的用户数。计费到期邮件提醒等功能。

计费方式一般有两种,周期性计费,类似月租方案,和使用量计费,用多少付多少。周期性计费比较简单。也可以两者结合起来。

6. 定制化开发

SAAS的优势在于一套系统多人使用,似乎和定制化开发有冲突。比如A客户想要A功能,B客户不想要。但定制化开发是无法避免的,比如CRM系统这样复杂的系统,不可能一套系统满足所有公司的要求。定制化开发尽可能分系统,分模块去做。然后通过控制台中配置不同租户订购不同模块,那些模块可以在前端页面上显示。不同的子系统需要分开部署。前端可通过nginx根据url分发,比如 abc.crm.baidu.com/bi/xxx/xx这个地址,就分发到BI子系统。不要尝试OSGI去搞模块化,这个是个大坑。

还有开发和产品,现有需求一定要分析清楚,不要一上线发现后患无穷。新功能尽量做的独立可以配置。

7. 灰度升级

SAAS付费企业客户对系统问题都特别敏感。为了减少升级可能出现问题的影响范围,一般都采用灰度升级策略。如果使用了url来区分不同租户,灰度升级配置就会很方便。可以配置nginx 来根据域名做分发,比如租户A(aaa.com)到实例1(版本1.0),租户B(bbb.com)到实例2(版本). 当需要域名配置非常多的时候,nginx配置文档会乱。这块时候可以考虑使用nignx_lua来写一些扩展模块。

8. 容量估计

9. Saas平台架构分层分析

Saas平台架构需要完成从用户申请链接saas到用户对自己购买的功能模块的应用整个过程,用户用起saas看似简单快捷,但这个过程却需要saas平台架构默默完成的非常复杂的处理过程。通过对saas平台架构的了解,可以清晰的分化数据的处理过程,让用户也可以明白saas平台架构处理数据的优势。下面介绍:saas平台架构分为哪几部分。

saas platform architecture the presentation layer:

saas platform architecture can be used in the presentation layer clients may have browser or local client. If you need is a Web browser interface technology, interactive technology and other technologies (such as: HTMl5 technology, CSS3 technology, Ajax technology, etc.) support if you need a software client remote desktop technology, software, interactive technology and other technical support.

saas platform architecture of the scheduling layer:

saas platform architecture scheduling layer reflects one of the characteristics of distributed systems. Is responsible for identifying and scheduling layer is first AAA authentication request by each user, then the load reasonable scheduling, traffic characteristics of the traffic processor. You can scale through the application of such architecture SaaS platform. Also in storage, caching, etc. In order to meet the needs of scale, scheduling level platform also must have good scalability.

saas platform architecture of the business layer:

saas platform architecture business layer is responsible for receiving scheduling requests forwarded by layer, but also to perform the actual business logic of the received request. In general the implementation of business logic using a single server is enough. Thus the actual business layer is constituted by a row composed of server peer, each server perform the same business logic.

saas platform architecture of the data layer:

Saas platform database cluster architecture for processing and storing strong relationship for demanding transactional business data, such data are currently still using traditional database clustering technology to solve, database cluster saas platform architecture is mainly based on business wherein split developing the program data. (: The user operation log) while the mass but the relationship is not strong distributed database for storing data.

These are "thinking Saas system architecture, multi-tenant architecture Saas analysis" of the introduction of saas platform architecture can be seen from the data processing application saas platform has a strong advantage, such as user saas very convenient and simple as long as the browser or native client interface, saas platform processes data to go through layers certified safe and reliable product saas, saas saas platform optimized data to improve performance.

Saas multi-tenant system architecture should also meet the following requirements:

640?wx_fmt=png

Saas is booming, recent sales easily Tencent heavily blessing, optimistic about the future of SaaS system!

Guess you like

Origin blog.csdn.net/xmt1139057136/article/details/100588987