Getting to know the microservice technology stack

What are microservices?

Are microservices equal to Spring Cloud's?

Not equal, Spring Cloud is only part of it.

Divide a single project into independent projects, each project completes a part of business functions, and will be independently developed and deployed in the future. We call such an independent project a microservice. A large Internet project often contains hundreds or thousands of services, eventually forming a service cluster.
insert image description here

Registration Center

A business is often completed by multiple services. For example, when a request comes, she may call service a first, service a calls service b, and service b calls service c. When there are more and more services, these calling relationships become more and more complex. With such a complex calling relationship, it is not necessary to rely on people to maintain records. So how to deal with it, there is a component - the registration center.

Record the ip, port, and what they can do for each service in the microservice.
When a service needs to call another service, she doesn't need to record the other party's ip information by herself, she just needs to go to the registry and pull it from her Pick.

insert image description here

Configuration Center

At the same time, as there are more and more services, each service has its own configuration file. When we want to change the configuration, if we modify it one by one, it will be too troublesome, so there is another component in the microservice - the configuration center .

Unified management of hundreds of configurations in the service group
Assuming that there are microservice configurations that need to be updated in the future, you only need to find the configuration center,
which will notify the relevant microservices to implement hot update of the configuration.

insert image description here

service gateway

When our microservice is running, users can come to visit us. At this time, our protagonist, the service gateway, comes into play. Since we have so many microservices, how do users know which one to access? And not just anyone can access our microservices.

One part verifies the user's identity, and the
other part is to route the user's request to a specific service and achieve load balancing at the same time

insert image description here

Distributed cache and database

First of all, the database is definitely a cluster, but no matter how many databases there are, there are not as many users. How to improve efficiency and resist high concurrency? This needs - distributed cache.

Distributed cache is also a cluster . The
request comes to the cache first, the cache misses, and then the database is queried.

insert image description here

Distributed search

Simple data can be cached, but some complex data search and analysis can not be done by cache. At this time, we need to use distributed search.

So what does a database do?

It is mainly to do some write operations and data storage with high requirements on the database.

message queue

Why have it? In microservices, a business often uses multiple services across, and the link of the entire business is very long. The invocation duration will be equal to the sum of the invocation durations of each service, so the performance is actually degraded to a certain extent.
So what is asynchronous communication?
That is to say, my service a is not to call service b, but to notify service b, and then my service a ends. Therefore, the service link is shortened, and the response time is also shortened. Its throughput capacity becomes stronger. Concurrency can be greatly improved.

Distributed Log Service

In such a huge microservice, if there is a problem, is it easy to troubleshoot? It is not easy to troubleshoot, so two components need to be introduced to solve this problem. One is - the distributed log service.

It can count the running logs of hundreds of services in the entire microservice, and do a unified storage and analysis. It will be easier to locate problems in the future.

insert image description here

System monitoring link tracking

The other is - system monitoring link tracking

It can monitor the running status of each node in our system, CPU load, memory usage, etc. in real time. Once any problem occurs, you can directly locate a specific method.

Continuous Integration

How to deploy such a large microservice? Also using manual deployment, obviously not. Therefore, we need an automated deployment.

Use Jenkins tools to automatically compile microservices, package them based on docker, and form images for automatic deployment based on technologies such as kubernetes or RANCHER. This set we call continuous integration.
Combined with microservice technology and continuous integration, this is the complete microservice technology stack.

insert image description here

Next, let's get to know the microservice system.

1. Understanding Microservices

With the development of the Internet industry, the requirements for services are getting higher and higher, and the service architecture has gradually evolved from a single architecture to a popular microservice architecture. What are the differences between these architectures?

1.0. Learning Objectives

Understand the pros and cons of a microservices architecture

1.1. Monolithic Architecture

Monolithic architecture : All functions of the business are developed in one project and deployed as a package.

insert image description here
The advantages and disadvantages of the monolithic architecture are as follows:


  • Simple architecture
  • Low deployment cost


  • High degree of coupling (difficult to maintain, difficult to upgrade)
1.2. Distributed Architecture

Distributed architecture : The system is divided according to business functions, and each business function module is developed as an independent project, called a service.

Advantages and disadvantages of distributed architecture:


  • Reduce service coupling
  • Conducive to service upgrade and expansion


  • The service invocation relationship is intricate

Although the distributed architecture reduces service coupling, there are many issues to consider when splitting services:

  • How to define the granularity of service splitting?
  • How to maintain service cluster addresses?
  • How to call between services? remote call
  • How to manage the calling relationship of the service?
  • How is the service health status perceived?

One needs to develop a set of well-established standards to constrain distributed architectures. ----A series of technologies
have emerged. In recent years, the most popular one is microservices? What are microservices?

1.3. Microservices

Architectural characteristics of microservices:

  • Single responsibility: The granularity of microservice splitting is smaller, and each service corresponds to a unique business capability to achieve a single responsibility
  • Autonomy: Team independence, technology independence, data independence, independent deployment and delivery
  • Service-oriented: services provide a unified standard interface, independent of language and technology
  • Strong isolation: isolation, fault tolerance, and degradation of service calls to avoid cascading problems

The above characteristics of microservices are actually formulating a standard for distributed architecture, further reducing the coupling between services, and providing independence and flexibility of services. Achieve high cohesion and low coupling.

Therefore, microservices can be considered as a well-architected distributed architecture solution .

1.4. Microservice technology comparison

insert image description here

insert image description here

But how should the plan be implemented? What technology stack to choose? Internet companies around the world are actively trying their own microservice landing solutions.

One of the most striking in the Java field is the solution provided by SpringCloud. What is SpringCloud?


SpringCloud is currently the most widely used microservice framework in China. Official website address:

SpringCloud integrates various microservice functional components and implements automatic assembly of these components based on SpringBoot, thus providing a good out-of-the-box experience.

Common components include:

insert image description here

In addition, the bottom layer of SpringCloud is dependent on SpringBoot, and there is a version compatibility relationship, as follows:

insert image description here

The next version to learn is Hoxton.SR10, so the corresponding SpringBoot version is version 2.3.x.

1.6. Summary
  • Monolithic architecture: simple and convenient, highly coupled, poor scalability, suitable for small projects. Example: Student Management System

  • Distributed architecture: loose coupling and good scalability, but the architecture is complex and difficult. Suitable for large-scale Internet projects, such as: Jingdong, Taobao

  • Microservices: A Good Distributed Architecture Solution

    ①Advantages: Smaller split granularity, more independent services, and lower coupling

    ②Disadvantages: The architecture is very complex, and the difficulty of operation and maintenance, monitoring, and deployment increases

  • SpringCloud is a one-stop solution for microservice architecture, integrating various excellent microservice functional components

Guess you like