The ideal and reality of micro service

Time:2020-10-1

The ideal and reality of micro service

With the increasing popularity of cloud native microservices, many people begin to be interested in the knowledge content of microservices. The purpose of this article is to eliminate illiteracy (meaning that Xiaobai can enter). I hope it can help you. If you have any questions, you are welcome to discuss and study together.

Where does micro service come from? —Evolution of service architecture

In the early days of the Internet, 2G was still a buzzword, and people’s needs were very simple. A static website told you who I was and a message board let you contact me, which could meet the needs of information dissemination and mutual exchange. So the farmers provided us with such a solution:Interface + business processing + data processingAll things can be done through a zip package, which is the service architectureEra of single architecture

The ideal and reality of micro service

The picture is original by the author

With the popularity of 3G, more and more people can access the Internet through PC. at this time, the emergence of BBS and portal consulting website began to attract a large number of audience. When beautiful interaction is more eye-catching and interesting information instantly triggers tens of millions of users to watch online, the “concurrency” problem arises, so coders work overtime to divide the system into front-end and back-end. By splitting out reusable middleware, business processing ability can be improved and concurrency problems can be solvedThe coming of the era of layered architecture

The ideal and reality of micro service

The picture is original by the author

Later, the Internet entered the era of micro blog, almost all netizens have blog, open the mobile phone and brush Weibo. At this time, when the hierarchical architecture faces more complex service requirements, it is more and more shackled in the application expansion, service invocation, expansion and so on, so the service architecture has entered the era of service-oriented architecture (SOA). There are a lot of things about SOA on the Internet. Here are some key words:Centralized service governance, ESB (Enterprise Service Bus) centralization, communication between services through precisely defined interfaces, lower coupling, higher scalability and higher maintenance cost.

The ideal and reality of micro service

The picture is original by the author

A few years later, e-commerce launched online promotion activities in various seasons, accompanied by a series of requirements, such as continuous delivery, gray-scale publishing, service current limiting, fault-tolerant protection, link tracking, log monitoring, elastic scaling, and so on. At the same time, programmers are increasingly bald and their degrees are getting deeper and deeper. When the pressure of operation and maintenance can not keep up with the rapid development of business,Micro service era coming。 It can be understood in this way that microservice architecture is also a way to realize distributed SOA architecture. Its advantages are small and decentralized, but the corresponding problem is that you have to manage more and more micro services. How to split and manage microservices is a touchstone to test the ability.

Before and after that, the service architecture has been updated iteratively, focusing on how users can save costs and improve efficiency to solve emerging new problems,Microservice is one of the products of the evolution history of service architecture

What is micro service?

The ideal and reality of micro service

The picture is original by the author

The most popular definition of microservice was proposed by Martin Fowler and James Lewis in 2014. According to the old men:

  • Microservice is a concept of the architecture layer. By decomposing (business units), the project can be disassembled into N units without strong dependence (decoupling). The dependency conditions required by self-preparation can be achieved, so that it can run independently and be deployed independently, and is no longer restricted by the environment and location.
  • Microservice architecture style is a way to develop a single application by using a set of small services. Each service runs in its own process and uses lightweight mechanism to communicate with each other. Usually, it uses a lightweight mechanism such as HTTP resource API to communicate with each other. These services are built around business functions and can be deployed independently through automatic deployment mechanism. These services use No With programming language implementation, as well as different data storage technology, and maintain a minimum of centralized management.

The ideal and reality of micro service

According to the 2019 architecture and design trend report released by InfoQ, the microservice architecture has gone through the blind pursuit stage, and is gradually becoming mature and practical.

The ideal and reality of micro service

Image source: InfoQ’s 2019 architecture and Design Trends Report

How to choose? What suits is the best

Before we choose, let’s see what we can choose?

1. Classification of microservice framework

At present, there are many microservice frameworks in the market, and they have their own strengths. What are the common microservice frameworks?

If we look at the common types of microservice frameworks, they can be divided into four categories.

  • Component class — users can load and use it on demand. Kubernetes, Eureka / consult / etcd, Zipkin / Jagger, etc.
  • Integration class — the advantage of integration class is that it simplifies the development of distributed system infrastructure, and provides service discovery registration, configuration center, message bus, load balancing, data monitoring, etc. The common ones are spring cloud, Dubbo, etc.
  • Grid class: istio, linkerd, Kong mesh, etc.
  • No service class: Currently, it is mainly used by large factories, and the common ones are knative, openfaas, kubeless, fission, etc.

According to the current mainstream ecosystem, there are three major ecosystems

  • Spring cloud family( https://www.springcloud.cc/ )
  • Dubbo family( http://dubbo.apache.org/en-us/ )
  • Yunyuanyuan family( https://www.cncf.io/ )

The official address is provided here for you to learn. This article will not discuss in detail. Each family needs to stay up late to lose a handful of hair, and concentrate on practice and learning to master it.

In a word, the core of microservice is service governance, and service governance needs a good microservice framework, otherwise microservice may be a disaster! But as a user, it’s best to choose the one that suits your actual situation.

2. Choose your own microservice framework

So how do we choose a microservice framework? Depending on business characteristics and technical capabilities. First choose the direction, then study the technical details. The following ideas on direction selection are for your reference:

If your business module and service governance are integrated, rely on specific development language and development framework, adjust rules and policies through configuration, and upgrade the function of service governance by relying on business online, then you may be more suitable for integrated service governance. You can choose your own way in spring cloud and Dubbo ecology.

If your business module and service governance are separate, independent of development language and development framework, configure various runtime rules and policies through dynamic adjustment, and upgrade service governance functions independently of business module, then you may be more suitable for service governance in service grid. You can choose your own way in the cloud native family, such as try istio.

3. When will microservices be introduced?

Microservices are not omnipotent. In other words, microservices are not suitable for you.

The ideal and reality of micro service

1) Time of day

In the early stage of business operation, if you are a single business system architecture, if the business volume is not large and the complexity is not high, if you pursue fast response, develop services, save costs and improve efficiency, then you may not really need microservices. For example, if you just want to use CMS to build a company website, you may not need to use microservices. As your business enters the expansion period, your system architecture begins to move towards service-oriented architecture. With the continuous expansion of business, the complexity of business system is increasing, but the efficiency is declining, then you can start to consider business splitting and using microservices.

2) Geographical location

If we want to carry out microservice transformation, we also need to have certain resource conditions, such as physical machine resources, network resources. For example: suppose an e-commerce platform, the status quo is shown in the figure. If the business framework is less complex, consider not using a microservice architecture. If microservice transformation is needed, at least the following resources need to be planned:

  • Hardware resources: host / container, database
  • Software resources: registry, split services, load balancing, gateway, cache, monitoring software
  • Human resources: at least architects need to build microservices, front-end, back-end, and testing. The role of operation and maintenance can be replaced by R & D + microservice platform.

The ideal and reality of micro service

3) Man and man

If you want to enjoy the advantages of microservices, you need to accept the challenges brought by microservices. For example:

  • Although the service boundary of microservices is limited, each team can independently maintain and evolve its own services, but when the services are expanded to dozens or even hundreds, the complexity brought by distribution needs to be considered.
  • If different services can be deployed and expanded independently, it is a challenge to maintain different versions and compatibility.
  • If different services can adopt different technology stacks, and only need to complete the interaction according to the agreed communication protocol, then a series of complex problems, such as authentication / authentication / certificate management between services, how to keep consistency after sharing and separating data, are the challenges to be faced.
  • ……

In short, the use of microservices also needs the right time, the right place and the right people. The process of using microservices should not be accomplished overnight. Service governance is a huge challenge.

Is your business suitable for microservices? I collected some of the simplest questions for a quick self-test:

The ideal and reality of micro service

04 implementation method of microservice

To put it simply, 4 steps:

The ideal and reality of micro service

In fact, there may be a “pit” in every step, which is all knowledge and can be independent chapters. Therefore, this paper does not expand in detail, and then write related content articles in detail.

However, demo can quickly help us find out. Here I choose the micro service platform of Jingdong Zhilian cloud to experience.

Why are public cloud products on the cloud?

Because the system of microservices is too complex and huge, if you build it yourself, one person can’t determine the work content of a team.

It is also because the “cloud” is a managed service, with less operation and maintenance, more WYSIWYG components, open source, multiple availability zones, simple and fast enough to start, and low learning and use costs.

Briefly summarize my learning path:

1. Experience high availability registry on “cloud”

If you have a mature microservice project and are currently in the process of going to the cloud, you want to enjoy the multi availability zone deployment of the registry brought by the “cloud” and ensure the cluster high availability to the maximum extent. Then you can directly use the namespace registry function of the microservice platform. At present, the microservice frameworks supported by jdsf include: spring cloud, Dubbo and JSF. The general steps are as follows:

The ideal and reality of micro service

For an example, see: https://docs.jdcloud.com/cn/jd-distributed-service-framework/basic-example 。

2. Experience call chain analysis service to locate performance bottleneck conveniently

If you have a mature microservice project and are currently in the process of going to the cloud, you can use the call chain analysis service of the microservice platform directly if you want to grasp the call relationship between services more conveniently and comprehensively, accurately discover the service bottlenecks and hidden dangers of the system, and reduce the operation and maintenance investment. Currently supported protocols: Zipkin, thrift, http.

The ideal and reality of micro service

For an example, see: https://docs.jdcloud.com/cn/jd-distributed-service-framework/basic-example 。

3. Experience application deployment

If you have already used jdsf service on the cloud, you can also use the mature and flexible deployment scheme provided by jdsf platform to publish microservice applications. At present, the application type supports: cloud host application and k8s application.

The ideal and reality of micro service

For an example, see: https://docs.jdcloud.com/cn/jd-distributed-service-framework/demo-deploy-k8s

4. Experience open service for customers

If you need to open the service to your users, if you have already used the registry service of the microservice platform, the microservice gateway can automatically complete service discovery and load balancing when calling, without using other load balancing or gateway services. If your service has been published to the load balancing service in the intranet through other ways, you can also realize seamless connection with API gateway through microservice gateway to avoid public network exposure and no longer need to apply for public IP and generate public network traffic fees.

The ideal and reality of micro service

For an example, see: https://docs.jdcloud.com/cn/jd-distributed-service-framework/gw_ VPC

How about microservices? Is it not so abstract, so difficult and so crazy?! More will be broken down next time.

The ideal and reality of micro service

The ideal and reality of micro service

Welcome to click“Jingdong Zhilian cloud”Learn more!

The ideal and reality of micro service

The ideal and reality of micro service

Recommended Today

The first Python Programming challenge on the Internet (end)

Date of establishment: March 28, 2020Update Date: April 22, 2020 (end)Personal collection Tool.pywebsite:http://www.pythonchallenge.com/Note: please quote or change this article at will, just mark the source and the author. The author does not guarantee that the content is absolutely correct. Please be responsible for any consequences Title: the first Python Programming challenge on the web Find […]