Lightweight Microservice Architecture [Reading Notes 1]

1. Why Microservice Architecture (Why)

 Reason: The traditional application architecture is unreasonable, resulting in a new architecture pattern.

 1.1 The main problems of traditional application architecture (Problems)

  When a system includes three business modules A, B, and C, and it is found through the monitoring program that A and B consume 20% of the system resources, but C takes up 80%, after the system runs for a period of time, business C will become the system bottleneck, thereby reducing the performance of the system. 

 1.2 Solve the problems of traditional application architecture (Solutions)

  Generally speaking, it is only necessary to copy the same program and deploy it to another server, except that the application is "horizontally expanded" through a load balancer on multiple servers. When a resource is requested, it first passes through the load balancer and forwards the request to the specific application server behind through a routing algorithm (such as round robin or hashing). This method is also called a reverse proxy.

 1.3 Others

  • Waste of system resources (mentioned in 1.1)
  • The deployment efficiency is too low (if the code is modified, the entire application needs to be deployed)
  • Single technology selection (only one language can be used)

2. What is Microservice Architecture (What)

 2.1 Concept

  The application meets the following requirements, specifically:

  • Divide service types according to business modules
  • Each service can be deployed independently with project isolation
  • Invoke services through a lightweight API
  • The service needs to ensure good high availability

 2.2 Microservice Delivery Process

  Using the microservice architecture to develop applications is actually designing, developing, testing, and deploying microservices one by one, and each service does not depend on each other.

3. What are the characteristics and challenges of microservices

 3.1 Features

  • Micro granularity (divided according to business functions)
  • Unity of Responsibility
  • Operational isolation type (each service is isolated from each other and does not affect each other)
  • Management automation

 3.2 Challenges

  • High operation and maintenance requirements (automatic technology to deploy, effective monitoring of microservices, and high availability of the system)
  • Distributed complexity (the essence of microservices is a distributed architecture, for distributed systems, network latency, system fault tolerance, distributed transactions)
  • Strong deployment dependencies (in complex business situations, multiple services may work together to complete one thing, and services do not call each other, but there may be sequential requirements for calls)
  • High communication costs (services run in isolation in their own processes, calling microservices from clients requires cross-process calls, and inter-process calls must consume more resources than intra-process calls, bringing communication cost overhead)

4. How to build microservices (How)

 4.1 Microservice Technology Selection

  Using Spring Boot as the microservice development framework, it has embedded Tomcat, which can directly run a jar package to publish microservices. When publishing microservices, you can connect ZooKeeper to register microservices to realize "service registration". In fact, there is a memory stump model called ZNode in ZooKeeper, and the nodes on the tree are used to store the configuration information of microservices. Use Node.js to process requests sent by browsers, connect to ZooKeeper in Node.js, discover service configurations, and implement "service discovery". Forward requests to Tomcat through Node.js to implement "reverse proxy". In addition, Node.js natively provides clustering features to ensure high availability. In order to realize the automatic deployment of microservices, you can build an automatic deployment system through Jenkins, and use Docker to containerize the services.

  

  1) Deploy the service using Jenkins

  2) Use Spring Boot to develop services

  3) Use Docker to package the service

  4) Register the service with ZooKeeper

  5) Call the service using Node.js

  On the basis of Spring Boot, Spring officially encapsulates Netflix-related components and provides an open source project called Spring Cloud.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324823741&siteId=291194637