Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Sprng cloud Learning Notes (1) basic knowledge of microservices

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

I. the basic concept of micro-service

The most popular architecture design in recent years is probably the micro-service architecture. Before learning spring cloud, let's first understand what the micro-service architecture is. To put it simply, the micro-service architecture is a style of system architecture design. Its purpose is to split the originally independent system into several small services, all of which run in their own independent processes. The services communicate and cooperate with each other through HTTP or RESTful API. The split small services are built around a certain item of the system or some highly coupled businesses. And each service has its own data storage and business development, automated test cases and independent deployment mechanism.

The main difference between micro-service and single system is that in a single system, due to the continuous expansion of project requirements, our original system will become more bloated, and if there are some minor problems, we have to update the service of the whole system. And modification problems may lead to problems in other modules. This is not what we want to see. The micro-service architecture is to deploy the elder brother function module separately and break it into parts. When we need to update a module, we only need to update the corresponding service, and there is no need to deploy and update the whole system, so that the stability of the system is greatly improved. Componentization of services is the greatest advantage of micro-service architecture.

Although micro-services have many advantages, they have to face problems that do not exist in the original system architecture, such as

1. Interface consistency: although we have split the service, the logical dependency will not be deleted, but since the single code dependency has changed into the communication between services, we should maintain the consistency of the communication protocol in the communication of each service, otherwise when we modify the original interface, the corresponding service caller will also modify it.

2. Distributed complexity: since split services are deployed and run independently, all distributed problems should be taken into account, such as network timeouts, distributed transactions and messages.

3. The challenge of operation and maintenance: in micro-services, the workload of operation and maintenance will increase exponentially because the whole service is divided into many services and deployed separately. Organizing and compiling these programs in an orderly manner creates many new challenges for operation and maintenance.

Although microservices have these problems, the advantages of agile development and automated deployment are still favored by excellent architects and developers, and colleagues are also the goals that architects strive to achieve.

When we implement the micro-service architecture, the system allows each service to manage its own database and realize the decentralization of data management. Although decentralization can make data management more detailed, data storage and performance can be optimized by using appropriate technologies. However, the biggest problem in microservices is data consistency. Distribution itself is very difficult to implement, so in the service architecture, we put more emphasis on the non-physical invocation between services. for data consistency, we only require that the state of the data is consistent in the final processing. If errors are found in the process, they are handled through compensation mechanisms or fault-tolerant threads, that is, we need to ensure the final consistency of data in micro-services.

II. Frame selection

Through some of the above introduction, we believe that we have a corresponding understanding of the micro-service framework, and then we will select the framework on how to construct the micro-service. In the past, the company has been using spring + netty to build micro-services, and api has been used to call between services. To ensure data consistency through fault-tolerant threads to deal with, zk for configuration management, the overall architecture is still relatively stable. But is there a formed micro-service framework? After all, I don't have enough confidence in my own set of things, . ) and then asked du Niang

Discovered the artifact of spring cloud (well, it just smashed everything into it).

III. Brief introduction of spring cloud

Spring cloud is a micro-service architecture development tool based on spring boot. It integrates configuration management, service governance, circuit breakers, routing only, micro-agents, control buses, global locks, decision campaigns, distributed replies and cluster states used in the micro-service architecture.

Operations such as management provide a simple way of development.

The common tools he integrates are as follows

Spring Cloud Config

Configuration Management tool Spring Cloud NetFlix

Core components, integration of open source components

Eureka service governance components, service registration, service discovery, etc.

Hystrix fault-tolerant management component to realize circuit breaker

Ribbon load balancing

Feign declared service invocation component

Zuul network management component

Archaius external configuration component Spring Cloud Bus

Event message bus, which is used to propagate state changes in the cluster, such as refresh configuration Spring Cloud Cluster

Implementation of Spring Cloud Consul based on election algorithm and general state mode

Service Discovery and configuration Management tool Spring Cloud Stream

Consumption of cache and mq for service Spring Cloud AWS

Simplify the integration of AWS components Spring Cloud Security

Security Toolkit Spring Cloud Zookeeper

Zookeeper component

From this, we can see that it integrates the tools commonly used in our micro-service framework, and we can build micro-services more quickly using spring boot. In the following time, we will learn and delve into the various components of spring cloud. Enhance the design and understanding of the micro-service framework.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report