This article source: making here | | GitEE, click here

1. Monomer architecture

The single architecture is common in small or medium services. The scenario mode is a single application and a single database. One package (for example, in WAR format or Jar format) that contains all of the business requirements is a more traditional architectural style.

Defects in a single architecture

  1. The complexity is high, the whole project contains many modules, the dependency is vague, and the modification program is easy to trigger unknown problems.
  2. The expansion capability is limited. Single applications can only be expanded as a whole, but cannot be scaled based on the features of service modules.
  3. Poor stability, any minor problem, can lead to the entire application service directly down.

Second, micro-service architecture

Microservice architecture is an architectural concept. The core idea is to decouple the whole service by decomsolving service functions and requirements into different services for management. Application services are created around business patterns and can be independently developed, iterated, and deployed. Make the architecture of the project clearer.

Advantages and disadvantages of micro services

  1. A single service corresponds to a single business function, which is easy to understand, develop and maintain;
  2. Independent deployment of services, according to the number of requests for each service can be deployed to meet the needs of the scale;
  3. Database, services, architecture, business separation and other difficulties, high requirements for technical capabilities;

Iii. Project Introduction

Core content of microservice architecture case, based on several core components of SpringCloud framework, Eureka service registration and discovery component, Feign declarative WebService client component, Zuul dynamic routing gateway component. Conduct multiple data management, multiple service management construction, multiple middleware integration, multi-business separation and other modes, and build comprehensive application cases of SpringCloud micro-service framework.

The core module

  1. Business separation architecture design
  2. Integration of multiple middleware services
  3. Code block management under microservices
  4. Multiple MySQL data source management

Four, technology selection

1. Core framework components

1. Base layer frameworks: Spring5+, SpringBoot2+, SpringCloud2+ 2. Druid, Log4j, FastJson, JodaTime, JavaMail 4. Middleware integration: RocketMQ, Redis, Quart, ElasticSearch 5. Data stores: MySQL, Redis, ElasticSearchCopy the code

2. Code hierarchy

5. Project architecture

1. Architecture diagram

2. Architecture description

  • Client interface services
1. Client service interface; 2. Management service interface; 3. Data entry service interface; 4. Data analysis service interfaceCopy the code
  • Generic Service Interface
1. RocketMQ message queue service; 2. ElasticSearch; 3. Quart timer service; 4. Redis cache service; 5. Basic services: Token authentication service; 6. Basic business: MsgBox message center service;Copy the code
  • Microservice component
1. Routing gateway: Zuul component; 2. Service registration and discovery: Eureka component; 3. Inter-service invocation component: Feign component;Copy the code
  • Data storage container
MySQL, Redis, ElasticSearchCopy the code

Six, source code address

Making address GitEE, https://github.com/cicadasmile, https://gitee.com/cicadasmileCopy the code