Micro Spring Cloud Services Development: Getting Started, Advanced and source code analysis - about 1.2 micro service

1.2 About Micro Services

1.2.1 What is a micro-service

ThoughtWorks company's chief scientist Martin Fowler said:

In short, micro-services architecture style is a single application as a set of small service development method, each application runs in its own process, and the lightweight mechanism (usually HTTP resource API) communicate. These services are built around business functions, and can be deployed independently by automatic deployment mechanism. Minimum centralized management of these services, can be written in different programming languages ​​and use different data storage technologies.

James Lewis and Martin Fowler said:

In short, Microservices architectural style is like the little development services into a single application form to run in its own process, and the use of lightweight mechanism for communication (typically HTTP resource API). These services are built around the operational capacity to achieve independence through the deployment of fully automated deployment tools. These services, which may use different programming languages ​​and different data storage technologies, and to maintain a minimum of centralized management.

Features 1.2.2 Micro services

  • Independent deployment, flexible expansion: the traditional single architecture is to deploy the entire system as a unit, while the micro-service is based on each individual component is deployed as a unit.
  • Effective isolation resources: Each service has a separate micro data source, if you want to read and write micro-micro-service A service database B, the service can only be called micro B interface to the external exposure is completed, effectively avoiding contention between Service database and cache resources brought about by problems.
  • By business organization team: micro design services also changed the original R & D team organization. Traditional R & D organization is the level of architecture, and design services to micro-division team has a certain influence, the team divided the organization more inclined to vertical architecture. Of course, only an ideal vertical division of architecture, split the actual organizational structure of the enterprise team will not be so absolute.

1.2.3 the advantages and disadvantages of micro-services

advantage:

  • Each service cohesive enough, small enough, the code is easy to understand, improve development efficiency.
  • Micro services can be developed individually small team.
  • Micro services are loosely coupled, there is a functional significance of service, regardless of deployment phase in the development stage or are independent;
  • Each service can each be extended, and each service can be deployed on suitable hardware servers according to their needs.
  • Improve fault tolerance, memory leaks a service does not make the whole system down.
  • Micro service can use a different language development, and the system will not be a long-term restrictions on technology stack.

Disadvantages:

  • The original micro-services project is split into several independent projects, increasing the complexity of development and testing.
  • Micro-service architecture need to ensure data consistency between the different services, the introduction of asynchronous distributed transactions and compensation mechanisms, bring some challenges for design and development.
  • As the number of services increases management complexity increases.

1.2.4 Micro Component Services common

Although micro-services architecture brings advantages, but it also introduces complexity, we need to use some components to solve the problems caused by the complexity of the technology after improving:

Service registry: Each service instance when you start, you need to think registry registration information such as your IP address. Service when calling another service interface, you can register through the center of inquiry to instances of other services, to initiate a request to the instance.

Load Balancing: As the service can have multiple instances, so whether it is a request from an external client, or initiated between internal service requests micro-service system, we need to introduce load balancing mechanism, to play the role of multi-instance cluster. Load balancing in two ways: the server-side and client-side load balancing load balancing, each has achieved significant representation are Nginx and Ribbon.

Gateway Service: service gateway is the only entry call service may be implemented in this component is user authentication, dynamic routing, gray release, A / B test, the load limiting function. According to the company the size of the size of the flow may be a gateway, it can be more.

Configuration Center: localized configuration information (Properties, XML, YAML, etc.) registered to the distribution center to achieve the migration package in the development, testing, production undifferentiated environment, convenient package. Configuration section can be used alone highly available distributed configuration center, to ensure that a service configuration when a problem occurs, other services can also provide configuration services.

Management API: Writing and updating API documentation, and a convenient form for the caller to view and test in a convenient form. Usually you need to add the concept of version control to ensure that different versions of the service are able to provide services during the upgrade process.

Integrated Framework: micro-duty service components to a single package to provide services, integration framework in the form of micro-configuration of all service components into a unified interface framework, allowing users to use the system in a unified interface.

Distributed Transaction: For important business, need to ensure consistency of data through distributed transaction technology (TCC, high availability messaging service). Depending on the business, properly require some sacrifice consistency of the data, ensure that the final data consistency.

Call chain: a complete record of when to call the business logic micro-services, and it shows such a serial or parallel call relationship. When the system is wrong, you can easily find the point of error. At the same time count the number of calls for each service, to ensure that services can be relatively hot allocate more resources.

Platform support: the system of micro-services, the system becomes more fragmented, the deployment, operation and maintenance, monitoring and other more complicated than single architecture, we need to automate most of the work. At this time, it is necessary to neutralize the disadvantages of these micro-services architecture provides the appropriate support platform or tool.

1.2.5 Spring Cloud and micro Services Architecture

Spring Cloud Spring maintained by the official developer, Spring Boot-based development, provides a complete set of micro-service solutions. Selection Spring Cloud technology is neutral, most components are derived from Netflix's open source products, including the service center Eureka, serving gateway Zuul, load balancing components Ribbon and so on. And these components can be replaced and extended on demand.

In the early years, the prevalence of the use of domestic Internet company Alibaba in Dubbo Github open source components to the application architecture system. However, Dubbo positioning in the future is not to become a total solutions micro services, but to focus on areas of RPC, micro-services become an important component. So that the micro-services derived from the demand for service governance, Alibaba started again to support open source projects, such as the recently announced open source Spring Cloud Alibaba, which can be used as components Dubbo Nacos use as a service center integrated into the ecological Spring Cloud.

From a technical point of view the selection, comparing the two, Dubbo and Spring Cloud, if only convenience and fast, can use Spring Cloud family bucket to build a micro-service, however, calls between Spring Cloud RESTful service through to communication, calling this agreement in terms of efficiency is relatively low, of course, calls between Dubbo service is performed by the RPC, compared RESTful this form, will certainly exceed the performance a lot, but the ecological Dubbo yet some worrying, if the rest of the technology stack needs to re-selection, it will no doubt spend a lot of manpower. But no need to worry, some time ago just graduated from the Apache Spring Cloud Alibaba for our open source project has the perfect solution to this problem, which is a component of Dubbo Spring Cloud is to enable seamless access to Dubbo Spring Cloud.

Published 151 original articles · won praise 1340 · Views 130,000 +

Guess you like

Origin blog.csdn.net/meteor_93/article/details/104019988