Goal: SaaS system

Recently, due to the needs of the project, I will make a SaaS system, the direction is similar to fleet management, the requirements are not known, but there is a direction.

Basically it is SaaS, and then the number of users will not be very large, after all, the number of people who drive big trucks or cars is there.

(I am Java after midnight, in nuggets this share the next experience, those who rely on copy of the handling author, do not copy to other platforms at will, which day of leisure to complain)

Therefore, I have studied in advance and summed up my previous experience. I hope I will not step on the pit. Here I also share my construction ideas.

Now that you have chosen SaaS, you should already know something about SaaS, and the concept of SaaS will not be repeated here.

Data isolation solutions industry

Since it is preparation for construction, let’s first sort out the isolation of data:

Three methods in the industry:

1. Database isolation, i.e. one database per tenant. The benefit is data problems and quick recovery, but the cost is high.

2. Database schema isolation (with MySQL), in fact, there is still a database (DB), but different user accounts, the advantage is that there is a library, but there are problems in data recovery will affect each other.

3. Use service field isolation for the same database and schema (user). The sharing level is the highest and the isolation level is the lowest. The advantage is that a database is enough to support more than N tenants, disadvantages, security in the design and code must be considered, remember to codereView. Then this database backup, database restore what is also more difficult.

Decide on a plan

Ok, of these three plans, I will directly choose the third one for the following reasons:

1. Limited by its business type, there will not be too much volume.

2. Multiple tenants with a library are enough to support the recent 2-3 years’ business volume. If it is really done and developed well, it is estimated that there will be reconstruction with great probability, right, according to the experience of Internet development.

3, the first one must be excluded, because at the beginning of each service provider to create a new database, the cost is limited.

4. It is estimated that ES will be introduced later, otherwise the statistical design of the third scheme will be more convenient as an operational design.

Then continue to analyze the preliminary preparation, a complete business request process, in general, is initiated by the user request, network transmission, firewall (gateway), business logic execution, return data. Then remove the network part and the operation and maintenance of disaster recovery and other processing to the operation and maintenance network management team, our r & D business implementation is to consider the middle link.

High concurrent thinking

In order to highlight the rationality of our architecture design, pioneering, that is, 3 high, high performance, high availability, high expansion, these 3 high is a high concurrency perfect framework (at least the current Internet development top is so).

High performance: behind the code implementation, to do a good job is.

High availability: cluster up.

High scale: If you need to temporarily scale up the server during peak times, when there is activity, you need to go right away.

After choosing a plan, the next chapter continues….

To build a library

Build a tenant master list as well

CREATE TABLE car_tenant_base( idint(11) DEFAULT NULL, tenant_codeVarchar (255) DEFAULT NULL COMMENT 'varchar ',tenant_nameVarchar (255) DEFAULT NULL COMMENT 'vstore ',contact_addressVarchar (255) DEFAULT NULL COMMENT 'l address ',contact_phoneVarchar (255) DEFAULT NULL COMMENT '1 ',contact_emailVarchar (255) DEFAULT NULL COMMENT 'address ',contact_nameVarchar (255) DEFAULT NULL COMMENT 'contact ',legal_nameVarchar (255) DEFAULT NULL COMMENT '主 体 名',create_timedatetime DEFAULT NULL, update_timedatetime DEFAULT NULL, create_uservarchar(255) DEFAULT NULL, update_userdatetime DEFAULT NULL, Delete_falg ‘tinyint(4) DEFAULT ‘0’ COMMENT’ logical delete 0- DEFAULT, 1- delete ‘) ENGINE=InnoDB DEFAULT CHARSET= utf8MB4;

`