Servicization, Microservices and Spring Cloud

As a veteran in the workplace, you may be no stranger to service-oriented (SOA). Today's Web 2.0 architecture is in full swing, and more and more enterprises are undergoing service-oriented transformation, the most famous being Amazon.

Servicing

As early as 2002, Amazon has already begun to carry out service transformation. Amazon CEO Jeff Bezos has an extraordinary understanding and foresight of the market:

  • From today, all teams will provide data and various functions in the form of service interfaces.
  • Communication between teams must be through interfaces.
  • No other form of interop is allowed: no direct linking, no direct reading of other teams' data, no shared memory, no backdoors of any kind. The only permitted means of communication is to invoke the service over the network.
  • The specific implementation technology is not specified, HTTP, Corba, PubSub, and custom protocols are all acceptable.
  • All service interfaces must be designed to be public from the start, no exceptions. That is to say, when designing an interface, it is assumed that the interface can be opened to outsiders, and there is no room for bargaining.
  • Failure to comply with the above rules will result in dismissal

Amazon has used its own actions to prove to the world that serviceization is correct. Amazon turned the existing book-delivery infrastructure into a very good, customizable computing platform that users paid to use. And it's all thanks to the fact that the entire infrastructure has been transformed into a service-oriented architecture. Amazon has transformed itself from an online bookstore into the world's largest cloud service provider.

Microservices

Thanks to James Lewis and Martin Fowler for their definition of the Microservices architecture:

In short, the Microservices architectural style is like developing a small service as a single application, running in its own process, and communicating using lightweight mechanisms (usually HTTP resource APIs). These services are built around business capabilities and independently deployed through fully automated deployment tools. These services, which can use different programming languages ​​and different data storage technologies, are kept to a minimum of centralized management.

Microservices include the following characteristics:

  • Components are provided as services: as the name suggests, microservices are also service-oriented.
  • Organize around business functions: Microservices tend to divide and disassemble the service structure around business functions. Such a service is a software with a complete implementation for the business domain, which includes the use of interfaces, persistent storage, and inter-day interactions. So the team should be cross-functional, encompassing the full range of development technologies: user experience, database, and project management.
  • A product is not a project: the traditional development model focuses on delivering some software that is considered complete. Once development is complete, the software is handed over to maintenance or implementation, and the development team can then be disbanded. Microservices, on the other hand, require the development team to be accountable for the entire lifecycle of the software product. This requires developers to pay attention to the operation of software products every day, and to contact users more closely, and to undertake some after-sales support at the same time. The smaller the service granularity, the easier it is to facilitate the relationship between the user and the service provider. Amazon's philosophy is "You build, you run it", which is also the cultural philosophy of DevOps.
  • Strengthen terminals and weaken channels: Microservice applications are committed to loose coupling and high cohesion, and they prefer a simple REST style rather than complex protocols (such as WS or BPEL or centralized frameworks). Or use a lightweight message bus (such as RabbitMQ or ZeroMQ, etc.) to publish messages.
  • Decentralized governance: This is a big difference from traditional centralized management. Microservices split the components of a monolithic framework into different services, which will give you more options when building them.
  • Decentralized data management: When a monolithic application uses a single logical database for data persistence, enterprises often choose to use a database within the scope of the application. Microservices let each service manage its own database: whether it's a different instance of the same database, or a different database system.
  • Infrastructure automation: The development of cloud computing, especially AWS, has reduced the complexity of building, publishing, and operating microservices. Microservices teams rely more on automating the infrastructure, and publishing is pretty boring after all. Docker, which has become popular in recent years, is also a good choice (see "A Brief Description of Docker" https://waylau.com/ahout-docker/ ).
  • Fault-tolerant design: Task services may fail due to unreliable suppliers. Microservices should provide day-to-day failure detection and recovery for each application's service and data center.
  • Improve the design: Since the design is constantly changing, the services provided by microservices should be able to be replaced or obsolete, rather than long-term development.

So what are the differences between SOA and microservices?

MSA vs. SOA

Microservice Architecture (MSA) is similar to Service Oriented Architecture (SOA), for example, both are service oriented. Usually SOA means a large and comprehensive monolithic solution. This makes design, development, testing, and release more difficult. Any small code changes will lead to the need to re-test and deploy the entire system. The microservice architecture just disintegrates all services, sets a reasonable granularity, maintains low coupling between each service, and each service survives its complete life cycle, minimizing the impact on each other.

SOA needs to standardize the entire system, while each service in MSA can have its own development language and development method, which greatly improves flexibility.

Spring Cloud

Literally, Spring Cloud is a framework dedicated to distributed systems and cloud services.

Spring Cloud is a new member of the entire Spring family and an inevitable product of the recent popularity of cloud services.

Spring Cloud provides developers with tools to quickly build some common patterns in distributed systems, such as:

  • Configuration management
  • Service registration and discovery
  • breaker
  • Intelligent routing
  • inter-service call
  • load balancing
  • Micro proxy
  • control bus
  • one-time token
  • global lock
  • leadership election
  • Distributed session
  • cluster status
  • Distributed Messaging
  • ......

Using Spring Cloud, developers can implement these patterns for services and applications out of the box. These services can run in any environment, including distributed environments, as well as developers' own laptops and various hosting platforms.

Spring Cloud 与 Spring Boot

Spring Cloud builds services based on Spring Boot. In this way, when developing Spring Cloud components, you can rely on Spring Boot to achieve rapid development.

For Spring Boot content, see the author's video course "Spring Boot-based Blog System Practice" ( http://coding.imooc.com/class/125.html ).

Spring Cloud and Microservices

Spring Cloud is a powerful tool for building distributed systems, and microservices are one of the most popular types of distributed systems. Therefore, Spring Cloud naturally supports the construction of microservices.

In the early years, domestic Internet companies prevalently adopted Dubbo to build microservices. Today, there is a better choice, and that is Spring Cloud. According to data, the number of users of Spring Cloud has shown explosive growth, both at home and abroad. Moreover, Dubbo is mainly to solve problems such as service communication and service registration, while Spring Cloud is a complete solution for providing microservice architecture.

How Spring Cloud implements microservices

Having said so many theories, how does the microservice architecture actually land? The course "Spring Cloud-based Microservices in Practice" ( https://coding.imooc.com/class/177.htmll ) gives the real answer.

In the course "Microservices Based on Spring Cloud", the author implemented a complete weather forecast system based on the Spring Boot + Spring Cloud technology stack. In the course, we start with Spring Boot and quickly build a weather forecast system with high concurrency capability and friendly interface from 0 to 1. Then analyze the pros and cons of monolithic architecture, introduce the concept of microservice architecture, and realize the splitting of microservices from 1 to 0. Finally, Spring Cloud technology is introduced to implement the governance of these microservices, focusing on topics such as service registration and discovery, service interaction, service consumption, load balancing, API gateway, configuration center, service fuse, and automatic expansion.

By studying this course, students can not only learn the latest surrounding technology stacks of Spring Boot and Spring Cloud (this course is based on the latest Spring Boot 2.0.0.M4 and Spring Cloud Finchley.M2), but also master how to use the above technologies to integrate and build a framework The ability to be familiar with the characteristics of the monolithic architecture and the microservice architecture, and finally realize the practical ability to build the microservice architecture.

What technologies are needed to build a Spring Cloud microservice system

The related technologies involved in the course "Microservices Based on Spring Cloud" ( https://coding.imooc.com/class/177.htmll ) include:

  • XML parsing: JABX
  • JSON Serialization: Jackson
  • Cache: Redis
  • Timer: Quartz Scheduler
  • Java Template Technology Thymeleaf 
  • Front-end style: Bootstrap
  • API Gateway: Zuul
  • Service registration and discovery: Eureka Server, Eureka Client
  • Service interaction: RestTemplate, Apache HttpClient
  • Service consumption: Ribbon, OpenFeign
  • Load Balancer: Ribbon
  • Configuration Center: Config Server, Config Client
  • Service circuit breaker: Hystrix
  • Project build: Gradle

Through the study of this course, you will be able to master the ability to architect microservice systems!

References

To learn Spring Cloud microservices, in addition to the above courses, Lao Wei also wrote a number of open source books related to microservices ( https://waylau.com/books/ ), note that they are all free books! ! !

Guess you like

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