Spring Cloud (1): Overview of Microservices

1. What is microservice

Microservice is an architectural style and an architectural design method. A large complex software application consists of one or more microservices. Each microservice in the system can be deployed independently, and each microservice is loosely coupled. Each microservice is only focused on doing one task and doing it well. In all cases, each task represents a small business capability.

2. Why do we need microservices

In the traditional development mode, most web applications are built in the style of monolithic architecture, which makes all interfaces, business logic layer, and data persistence layer all packaged in a web application and arranged in one On one server, different modules were highly coupled together before. This development model makes the development cost of multi-team collaborative development extremely high.

3. Problems existing in monolithic applications

  • Development becomes more and more complex as business grows

  • When modifying a single function, the entire system needs to be packaged and deployed

  • Multiple teams operate and manage data at the same time, which is prone to security vulnerabilities

  • Each module is developed using a relatively unified technology. It is difficult to choose a more appropriate technical framework for each module according to the actual situation, and the system's scalability is relatively low.

  • The coupling between modules is high, and it takes time for newcomers to get started

distributed, cluster

Cluster : One server cannot load high concurrent data access, and more servers need to be set up to share the pressure. Solve high-concurrency problems from the physical level, such as opening more ticket windows at train stations during the Spring Festival travel season.

Distributed : Split a large project architecture into several microservices to complete collaboratively. Solve problems at the level of software design, such as dividing the purchase of tickets into statistics of departure and destination, checking whether there are tickets, and purchasing tickets in a unified manner. These small tasks are completed by different people, and finally all the work results are processed. Integration to achieve greater needs.

Fourth, the advantages of microservices

  1. The development, testing, and deployment of each service are independent of each other. More operations can be performed on a specific service, such as load balancing.

  2. When a new requirement is added, traditional projects need to consider the impact of various aspects. Microservices do not have such problems, saving trouble, effort and worry.

  3. After splitting the project using microservices, it is only necessary to ensure the normal operation of the external interface, which greatly reduces the coupling between modules and greatly improves development efficiency.

5. Disadvantages of microservices

  1. The splitting of microservices is based on business and cannot be split at will, so how to split is a very important and challenging task for project architecture.

  2. When it comes to calls between services, it is often necessary to communicate with another service provider. If there are two completely different companies or departments, the communication cost is relatively high; if the external interface of a service needs to be modified, it also needs to communicate with other services. The caller communicates.

  3. Since each service is independent of each other and the data is also independent, how to ensure the consistency of data is a difficult point when the interfaces of multiple services are operated. Data consistency is a difficult problem in microservices.

6. Why choose Spring Cloud

Although microservices also have many disadvantages, the flaws are not hidden. Generally speaking, microservices are still a very good way to implement a distributed architecture. It is a very hot technology at present, and it is also the trend of future technology development. The more common microservice frameworks are Spring Cloud and dubbo. Then why did we choose Spring Cloud? The reasons are as follows:

1. Spring Cloud is completely based on Spring Boot, and the service call is based on REST API, which integrates various mature products and architectures. At the same time, based on Spring Boot, it also makes the overall development, configuration, and deployment very convenient.

2. The Spring series of products have the advantages of complete functions, simple and easy to use, beautiful performance, and standardized documents.

Seven, the overall architecture of Spring Cloud

insert image description here

Eight, the core components of Spring Cloud

Spring Cloud consists of multiple components, mainly service governance Eureka, service communication Ribbon, service communication Feign, service gateway Zuul, service fault tolerance Hystrix, service configuration Config, service monitoring Actuator, service tracking Zipkin and other 8 major components. The learning of Spring Cloud is mainly to learn the use of these components and the integration between these components.
insert image description here

9. How to manage the service

The core of service governance consists of three parts: service providers, service consumers, and registry

Service registration: In the distributed system architecture, each microservice will store its own information in the registration center when it starts.

Service discovery: The service consumer obtains the information of the service provider from the registration center, and calls the service of the service provider through this information. ,

Then Spring Cloud's service governance is implemented using Eureka. How does it work? Let us look forward to Spring Cloud (2): Eureka Server Registration Center

One development engineer is also in the continuous learning stage, and the usual small experiences are shared from time to time. I hope that those who read the text I wrote can avoid detours and wish you success in work and study.
Bloggers have limited experience, if there are any shortcomings, welcome to communicate and improve together~ I hope to make progress together with you who are also in CSDN.

Author | Sweet Little Sweet Potato
Produced | Little Sweet Potato

Guess you like

Origin blog.csdn.net/qq_36836370/article/details/130869680