from spring To SpringBoot Until then SpringCloud, Now? “ Interview to build rocket 、 Screw in ” From the history of the development of micro services, it can be shown incisively and vividly , Except for big Internet companies like Ali , Rarely used SpringCloud, But you have to learn , Because you go out for an interview and you'll find , The interview will be asked ！
see , Recently, Ali launched a set of internal SpringCloud note （ Four copies in total ） covers SpringCloud All the technical content of , At the same time, it also includes the interview hot spots （ I don't know if Ali intended to ......） To make a long story short , From every dimension , It's all a rare note ！
Let's share this note for free , Limited by the length of the article , The editor can only show you part of the content , complete PDF The free access to the full-color version is at the end of the article ！
Let's get to the point ！
DAY1： Micro service Basics
Distributed system using microservice architecture communicates with each other through network . We describe the calling relationship between microservices through service providers and service consumers .
Service providers : The callee of the service , The party that provides the calling interface
Serving consumers : The caller of the service , The party that relies on other services
We take e-commerce system as an example , The user initiates a purchase request to the order microservice . Before saving the order, you need to call the commodity microservice to query the current commodity inventory , Unit price and other information . In this case , Order micro service is a service consumer , Commodity micro service is a service provider .
Service registration Eureka Basics
Service registration Eurek senior
Eureka Alternative Consul
The service call Ribbon introduction
After the above learning , Service registration and service discovery have been implemented . When you start a service , Can pass HTTP To register information in the registry , And through SpringCloud Provides a tool to get a list of Registry Services . But there are still many problems in the call between services , How to call microservices more conveniently , How to choose multiple micro service providers , How to load balance and so on .
The service call Ribbon senior
DAY2： The service call Feign、 Service registration and discovery summary 、 The high concurrency problem of microservice architecture
Through the registry, we have realized the service registration and service discovery of microservices , And through Ribbon Load balancing is realized , Has been aided by Feign Microservices can be called gracefully . So what about the performance of the microservices we wrote , Is there a problem ?
Service failure Hystrix And alternatives
18 end of the year Ntflix Official announcement Hystrix It's stable enough , No longer actively developing Hystrix , The project will be in maintenance mode . For now Hystrix It's more stable , also Hystrix Just stop developing new versions , It's not a complete stop to maintenance , Bug What will still be maintained . So in the short term , Hystrix Still in use . But in the long run , Hystrix It will always reach its life cycle , that Spring Cloud Is there any alternative product in the ecology ?
DAY3： Overview of microservice gateway
After learning the previous knowledge , Microservice architecture has taken shape . But there are still some problems : Different microservices - There will be different network addresses , The client must remember dozens or even hundreds of addresses when accessing these microservices , This is too complex for the client side and difficult to maintain . Here's the picture ：
Microservice gateway Zuul
Microservice gateway GateWay
Zuul 1.x It's based on blocking I0 Of API Gateway as well as Servlet; until 2018 year 5 month , Zuul2.x( be based on Netty , It's also non blocking , Supports long connections ) Just released , but Spring Cloud There are no plans for integration yet .Spring CloudGateway Than Zuul 1.x The performance and function of the series are better as a whole .
Overview of microservice link tracking
In actual enterprise development , Message middleware is one of the most important components -. Message middleware mainly solves application decoupling , Asynchronous messaging , Flow cutting , Achieve high performance , High availability , Scalable and ultimately - The structure of causation . Different middleware, its implementation way , The internal structure is different . As is common RabbitMQ and Kafka, Due to the differences in the architecture of the two message oriented middleware , image RabbitMQ Yes exchange , kafka Yes Topic , partitions Partition , The differences of these middleware lead to our actual project development, which has caused us some difficulties , If we use one of the two message queues , The business requirements behind , I want to go to another - - Migration of message queues , There is no doubt that this is a disaster , A lot of things have to be pulled down and redone , Because it's coupled to our system , Now springc loud stream It gives us a way to decouple .
DAY4：Spring Cloud Stream
Spring Cloud Conig
Open source configuration center Apollo
100％ Free access ： Forward this article （ Sorting is not easy to ）+ Pay attention to me , Then scan the code and get it for free ！