Master “Version H & Alibaba & Link Tracking & Logging & Transaction & Lock”


Full catalog of tutorials “with videos” : gitee.com/bingqilinpe…

Basic concepts of microservices

Evolution of architecture

Why microservices?

If go back to 10 years ago, one day Zhang SAN entered the electric business enterprise – and xi Xi mall.

The company was a start-up, with few people, few users on its website, and only one engineer

The project architecture is relatively simple

1. Single architecture

image-20200317144318312

Unexpectedly, the company’s business is getting better and better, and the number of website users is increasing, so the problems of single architecture are exposed. With the increase of visits, the project often goes down

Problem: The architecture is too simple to withstand high concurrency

So, hiring. To upgrade and optimize the Xi Xi mall.

Analyze the direction of the upgrade:

  1. The database and application code are kept on separate servers
  2. Increasing application load Capacity [Cluster]

So increase load balancing.

2. Load balancing

Distributed: A system collaborates with multiple servers to perform system functions

Cluster: The same system is deployed on multiple servers with multiple copies of the same content on each server

image-20200317145056653

Load balancing problems

  1. The cost of
  2. Session

After load balancing is added, application servers are no longer the bottleneck of the system, and the number of application server clusters can be flexibly increased with the increase of traffic.

As the volume of services and data increases, database performance bottlenecks occur.

hiring

Under the efforts of many colleagues, the project was further optimized — read and write separation.

3. Read and write separation

image-20200317145753793

The above structure looks very perfect, but with the increasing business volume of the mall, new problems have been exposed.

Question:

  1. Product Search using database fuzzy query is not good, not accurate, slow

    Fuzzy matching for book query

  2. Data access frequency of different modules is not the same (heat is different), home page data traffic is relatively large, order data traffic is much smaller in comparison. All data are taken from the database, affecting the speed of home page access [cache]

hiring

4. Full-text retrieval cache

All colleagues began to work together to optimize the project, the product search was done using full-text retrieval technology ES, and caching (Redis clustering) was introduced, so the architecture became this sub-sub-.

image-20200317150418119

With the continuous growth and xi Xi mall, the company ushered in the venture capital, venture capital two billion, so the mall development faster, new problems appeared.

Question:

  • The coupling between different service modules is too high. When one module fails, the entire server goes down

  • Maintenance is difficult. If there are 200 application servers in a cluster, then going online means 200 servers need to be deployed

    For example, redeploying the order module means that all servers need to be redeployed

  • Redundant, some modules do not need to be deployed on all servers

Hiring: a team of 100 people for a new optimization and upgrade of the project – service-oriented (SOA), split into different applications according to the different business modules.

So that’s the distributed architecture

5. As a service

Therefore, the company has entered the era of vigorous servitization, but there are several problems to be solved as follows

image-20200317151634243

Each module is a separate project that can be launched independently and this is called a servitization module and when it becomes a project we call it a service home page module — home page service

That’s servitization. That’s microservices. Microservices are special distributed architectures.

  • Five can be deployed if the page view of the home page is large
  • Only one order can be deployed if the order has a small number of visits
image-20210105104120083

Question:

  1. How do services call each other? For example, the order service needs to invoke the data of the goods service. How?

  2. How to load balance? Load balancing between services? How to load balance app access background?

  3. How are services managed? For example: the product service is down, how to inform the order service immediately? If the order service is not notified, the order service will block the request, causing the order to go down, causing a chain failure, and the entire project to crash

  4. Exception handling between services?

    .

Each of these problems requires a new technology to solve, and the new technology introduced is microservices technology, SpringCloud.

New technologies are needed to solve these problems, and these technologies are called microservices (SpringCloud).

Based on the above problems, the whole and xi Xi Mall team crazy efforts to find some technology (SpringCloud), respectively to solve the above problems, the architecture diagram is as follows:

image-20200317153320482

So far, and xi Xi mall has become a microservice architecture.

The main content of servitization microservice is to split different application services according to business modules and solve the problems encountered after splitting

What are microservices

the microservice architectural style [1] is an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API. These services are built around business capabilities and independently deployable by fully automated deployment machinery. There is a bare minimum of centralized management of these services, Which may be written in different programming languages and use of different data storage Technologies.【 official documentation 】

  • Each service can run independently in its own process and each service can be independently deployed and started
  • A series of independent microservices build the system together
  • Each service is an independent business development, and a microservice only focuses on a specific function, such as order management, user management [split by service]
  • Microservices communicate with each other through some lightweight communication mechanism, such as Restful API (HTTP) calls [How order service calls commodity service]
  • It can be developed using different programming languages and data storage technologies

Website link: https://www.martinfowler.com/articles/microservices.html

What is a SpringCloud

SpringCloud is a one-stop solution under distributed micro-service architecture, which is a collection of technologies implemented by various micro-service architectures, commonly known as the whole family of micro-services. Spring Cloud is a development tool set containing multiple sub-projects and a collection of numerous open source frameworks. It makes use of the convenience of Spring Boot development to realize many functions, such as service registration, service discovery, load balancing, etc.

  • Service management requires a technique

  • Service invocation requires a technique

  • Load balancing requires a technique

    .

Where do these technologies come from?

  1. Find their own, the integration between technology without a certain technical strength to do
  2. SpringCloud officially found a set of technologies to solve the problem of micro-services, and made encapsulation and integration, so that users can directly use, do not need to care about the problem of technical integration

Developing microservices is like buying a computer

  1. Build your own, find your own microservices technology is the equivalent of building your own computer
  2. Buying a branded machine using SpringCloud is like buying a lenovo computer, CPU graphics card and so on

What is the relationship between SpringBoot and SpringCloud

Using load balancing requires a lot of configuration, write configuration

  • Write your own configuration
  • SpringBoot is automatically configured

SpringCloud uses SpringBoot as the underlying layer to simplify distributed development through SpringBoot’s automatic configuration

If you find this article helpful

  1. Click “like” to support it, so that more people can see this content.

  2. Share your thoughts with me in the comments section, and record your thought process in the comments section.

  3. If you feel good, you can also follow the personal public account of programming deer to see more articles and explanation videos (thank you for your encouragement and support 🌹🌹🌹)