Spring Cloud-Introduction to Microservices

1. Introduction to Microservices

Microservice (not a framework but an architectural idea) was proposed by the famous oo (object-oriented, ObjectOriented) expert Martin Fowler. It is used to describe a special way of designing software applications as independently deployed services . In the past two years, the frequency of microservices appearing in major technical conferences, articles, and books has made people aware of its influence on the software field. The system of microservice architecture is a distributed system , which is divided into independent service units according to the business field. It has the characteristics of automatic operation and maintenance, fault tolerance, and rapid evolution. Complex business requirements.

2. What is Microservice?

In short, it is to divide a large application into multiple small modules, each module has its own functions, and each module can call and interact with each other, which is microservices .

The style of microservice architecture is to develop a single program into a microservice. Each microservice runs in its own process and communicates using a lightweight mechanism, usually HTTP RESTFUL API . These services are divided and built around business capabilities, and can be deployed independently through a fully automated deployment mechanism. These services can use different programming languages, as well as different data storage technologies, to ensure minimal centralized management.

3. Why use microservices?

1. The business is becoming more and more complex, the code volume of the single application is increasing, the readability, maintainability and scalability of the code are reduced, the time required for newcomers to take over the code is multiplied, and the cost of business expansion getting bigger.

2. With more and more users, the concurrency of the program is getting higher and higher, and the concurrency capability of the single application is limited.

3. The difficulty of testing is becoming more and more difficult. The business of a single application is in the same program. With the expansion of business and the increase of complexity, the modification or addition of business in a single application may have a certain impact on other businesses. , leading to an increase in the difficulty of testing.

4. Microservice architecture style diagram

insert image description here

Five, the characteristics of microservices

1. According to the business (function), it is divided into an independently running program, that is, the service unit
2. The services communicate with each other through the HTTP protocol. http is a universal protocol (a mode supported by web applications)
3. Automated deployment. (CI/CD-continuous integration, continuous delivery, currently the most used: Jenkins )
4. Different programming languages ​​can be used.
5. Different storage technologies can be used to call the interface of each service through http.
6. Centralized management of services.
7. Microservice is a distributed system.

The Shortcomings of Microservices (Disadvantages)

Everything has two sides, and microservices are no exception. Compared with single projects, microservices still have many advantages, but of course they also have shortcomings.
1. Microservices are relatively simple, with increased complexity and high learning costs
2. Distributed transaction issues
3. Division between services (is it divided by function or by component)? Division of labor problem
4. Increased complexity of service deployment.

Summarize three major problems: propagation of service faults (fuse), division of services, and distributed transactions

However, considering the advantages and disadvantages, the advantages of microservices still outweigh the disadvantages. It is the general trend for medium and large companies and newly developed projects to use microservices.

6. Introduction to Spring Cloud

As a microservice framework of the Java language, Spring cloud relies on Spring Boot and has the characteristics of rapid development, continuous delivery and easy deployment . There are many components of spring cloud, involving all aspects of microservices. Driven by the open source community Spring, Netflix, and pivotal, it has become more and more perfect, and now alibaba has also joined it .

Spring official netflix alibaba Spring cloud inherits some advantages of Spring Boot in development and deployment, improving its efficiency in development and deployment. The primary goal of Spring cloud is to help developers quickly build a distributed microservice system by providing a series of development components and frameworks .

Spring cloud is implemented by packaging other technical frameworks, such as packaging open source Netflix oss components, and implementing a set of microservice frameworks based on annotation, Java configuration, and template-based development .

Spring cloud provides some common components for developing distributed microservice systems, such as service registration and discovery configuration center, fuse, remote call, intelligent routing, micro-agent, control bus, global lock, distributed session, etc.

Dependencies between versions

insert image description here

Common components of Spring Cloud

Service registration and discovery (eureka, nacos, consul)
Service load balancing (ribbon, dubbo)
Service mutual call (openFeign, dubbo)
Service fault tolerance (hystrix, sentinel)
Service gateway (gateway, zuul)
Unified management of service configuration (config-server, nacos, apollo)
service message bus (Bus)
service security component (security, Oauth2.0)
service monitoring (admin) (jvm)
link tracking (sleuth+zipkin)
insert image description here

7. Summary

SpringCloud is a specific implementation of the microservice concept , which helps the microservice architecture provide necessary functions. Currently, there are three commonly used implementations in development:
Dubbo+Zookeeper semi-automatic microservice implementation architecture
SpringCloud Netflix one-stop microservice architecture
SpringCloud Alibaba's new one-stop microservice architecture

Guess you like

Origin blog.csdn.net/wml_JavaKill/article/details/129118976