Table of contents
- Understanding Microservices
- Distributed service architecture case
- euraka registration center
- Ribbon load balancing principle
- nacos registration center
Understanding Microservices-Service Architecture Evolution
monolithic architecture
Monolithic Architecture : All functions of the business are developed in one project and packaged into one package for deployment.
Advantages :
- simple structure
- Low deployment cost
Disadvantages :
- High coupling
distributed architecture
Distributed architecture : The system is split according to business functions, and each business module is developed as an independent project, called a service.
Advantages :
- Reduce service coupling
- Conducive to service upgrade and expansion
Service Governance
Issues to consider for distributed architectures:
- What is the granularity of service splitting?
- How to maintain the service cluster address?
- How to implement remote calls between services?
- How to perceive the service health status?
microservice
Microservice is a distributed architecture solution with well-designed architecture. Microservice architecture features:
- Single responsibility: Microservice split granularity is smaller, each service corresponds to a unique business capability, so as to achieve a single responsibility and avoid repeated business development
- Service-oriented: Microservices expose business interfaces to the outside world
- Autonomy: independent team, independent technology, independent data, independent deployment
- Strong isolation: service calls should be isolated, fault-tolerant, downgraded, and cascading problems should be avoided
summary:
Monolithic architecture features?
- Simple and convenient, highly coupled, poor scalability, suitable for small projects. Example: Student Management System
Distributed architecture characteristics?
- Loose coupling and good scalability, but the structure is complex and difficult. Suitable for large-scale Internet projects, such as JD.com and Taobao
Microservices: A Good Distributed Architecture Solution
- Advantages: smaller split granularity, more independent services, and lower coupling
- Disadvantages: the structure is very complex, and the difficulty of operation and maintenance, monitoring and deployment is increased
Understanding microservices - comparison of microservice technologies
microservice structure
The microservice solution requires a technical framework to implement it. Internet companies around the world are actively trying their own microservice implementation technology. The most well-known in China are SpringCloud and Alibaba's Dubbo.
Microservice technology comparison
Dubbo | SpringCloud | SpringCloudAlibaba | |
---|---|---|---|
registration center | zookeeper、Redis | Eureka、Consul | Nacos、Eureka |
Service remote call | Dubbo protocol | Feign (http protocol) | Dubbo、Feign |
configuration center | none | SpringCloudConfig | SpringCloudConfig、Nacos |
service gateway | none | SpringCloudGateway、zuul | SpringCloudGateway、zuul |
Service Monitoring and Protection | dubbo-admin, weak function | Hystrix | Sentinel |
business needs
1.SpringCloud+Feign
- Use Spring Cloud technology stack
- The service interface adopts Restful style
- Service call adopts Feign method
2.SpringCloudAlibaab+Feign
- Use the SpringCloudAlibaba technology stack
- The service interface adopts Restful style
- Service call adopts Feign method
3. SpringCloudAlibaba + Hammer
- Use the SpringCloudAlibaba technology stack
- The service interface adopts the Dubbo protocol standard
- Service call adopts Dubbo method
4. Dubbo original mode
- Based on Dobbo's old technology system
- The service interface adopts the Dubbo protocol standard
- Service call adopts Dubbo method
Understanding microservices-SpringCloud
SpringCloud
- SpringCloud is currently the most widely used microservice framework in China. Official website address: http://spring.io/projects/spring-cloud.
- SpringCloud integrates various microservice functional components, and realizes the automatic assembly of these components based on SpringBoot, thus providing a good out-of-the-box experience:
Service Registry Discovery:
- Eureka、Nacos、Consul
Unified configuration management:
- SpringCloudConfig、Nacos
Service remote call:
- OpenFeign、Dubbo
Unified gateway routing:
- SpringCloudGateway、Zuul
Service link monitoring:
- Zipkin、Sleuth
Flow control, downgrade, protection:
- Hystix、Sentinel