当前位置:网站首页>The concept of services
The concept of services
2022-08-11 01:11:00 【wylsjz】
1. Microservices
1.1. What is a microservice
Reasonably split a complex monolithic service into multiple sub-services, and interact with each other through loose coupling
1.2 Advantages of Microservices
Advantages:
Single responsibility, scalable, flexible combination, high reliability, more inclusive of the technology stack, more acquainted with newcomers, easier to take over the service code, reducing maintenance costs, each microservice has its own database, and each database is divided into a table (even at the same time).sub-table), which increases the throughput of the service compared to the monolithic application
reduces the coupling of the service
Disadvantages:
High operation and maintenance costs, high complexity, and performance impact
The complexity of splitting is not easy to grasp. Generally, it is split according to functional modules, and the architect guides us to split the work; microservices improve the systemThe complexity of deployment and maintenance is higher, and multiple members are required to collaborate directly
1.3 Problems to be solved by microservices
Service registration, service discovery, load balancing, health check, circuit breaker, current limiting, deployment, degradation, monitoring and alarming, call chain (link tracking)
2. Problems that need to be solved by microservices
HighHigh performance and high concurrency available
2.1 Service registration and discovery (consual)
2.1.1 Client service registration and discovery (client and microservice registration discovery)
The gateway goes directly to the service address
2.1.1 Server service registration and discovery consul (registration discovery between microservices)
First find the load balancer (LB), then find the server address
2.2 Load Balancing
(Each service instance can be accessed, traffic balance):
2.3 Health Check
(Check whether a service is still alive, check it regularly)
2.4 Retry mechanism
2.5 Fusing
Exceed the maximum traffic that the system can bear, return directly to protect the core function services from being affected
2.6 Current Limiting
Limit traffic (such as spike system or something) (both front-end and back-end should be limited)
2.7 Deployment
Containerized, all on k8s
2.8 downgrade
It temporarily abandons requests for some non-core interfaces and data internally, and directly returns a prepared fallback (fallback) error handling information
2.9 Monitoring and alerting: service problems are notified to development and operation and maintenance personnel through some instant messaging tools
2.10 Call chain (link tracking): call relationship between services, troubleshoot problems
2.11 Gateway: Distribute client traffic through the gateway, and requests fall to specific microservices
The service registration and discovery component manages the online and offline of services, the lookup of service addresses, and the long-link communication between microservices and management service components to ensure service survival
Long links can be maintained
2.12 Data synchronization between services: There are data synchronization between microservices (mainly divided into synchronous and asynchronous)
restfulapi: (http1.1) synchronous communication
rpc: internal service communication (http2.0 synchronous procedure call)
mq: can communicate asynchronously
2.grpc
2.1 What is grpc
Remote procedure call, define a service, specify the method that it can call remotely, implement this interface on the server side, and start a grpc service to handle the client's call, have a stub on the client side to be able to use the same method as the server side.
In gRPC, the client application can directly call the method of the server application on another different machine like a local object, making it easier for you to create distributed applications and services
2.2 allows the definition of four types of streaming methods:
Single rpc, server streaming rpc, client streaming rpc, bidirectional streaming rpc
2.3grpc advantage
1. Solve the communication between different language levels and environments
2. Based on http2.0 communication, a binary framing layer is added between the application layer and the transport layer
HTTP 2.0 will all transmitInformation is divided into smaller messages and frames,
and they are encoded in binary format; request headers and response headers are compressed;
single tcp connection multiplexing; server can actively push resources to clients
3. Enables communication between applications
4. gRPC can define interfaces through protoBuf, which can have stricter interface constraints
5. Data can be serialized into binary codes through protoBuf, whichThis drastically reduces the amount of data that needs to be transferred, resulting in a huge performance boost.
6. gRPC can easily support streaming communication
3.Protocol Buffers
3.1 What is Protocol Buffers
Protocol Buffers is a cross-language, cross-platform, scalable data transmission and storage protocol defined by Google.Mainly used for internal services
3.2 Advantages
1. Because the field protocol is placed on both ends of the transmission, the transmission data only contains the data itself, and does not need to contain the field description, so the amount of transmitted data is small, and the parsing efficiency is high (encoding and decoding efficiency is high).
2. Supports multiple languages
3. Compared with json and xml, it expresses the same data and can achieve a compression effect of 3 to 10 times.
4. Field numbers are helpful for backward compatibility
3.3 Disadvantages
Binary format leads to poor readability, version maintenance cost, lack of self-description, and poor versatility
The compiled code volume for the browser environment is large, because the serialization and deserialization methods of pre-loading data will lead to the need to loadextra js code.
3.4 When to consider json
1. I hope the code is more readable
2. The bandwidth is not enough to add more development tools
3. The workload brought by running different types of network services is already too large
4.The server-side application is developed based on js
5. The browser takes data directly from the service
4. Principles for designing microservices:

Reprint
Link: https://www.jianshu.com/p/86a0db11ecd2
边栏推荐
- Apache Commons Configuration远程代码执行漏洞(CVE-2022-33980)分析&复现
- Ambari迁移Spark2到其它机器(图文教程)
- J9数字论:DAO治理更像一种生态过程:治理原生于网络,不断演变
- 成功解决TypeError: can‘t multiply sequence by non-int of type ‘float‘
- MSTP——多生成树(案列+配置)
- apache+PHP+MySQL+word press,安装word press时页面报错?
- 什么是“门”电路(电子硬件)
- Summarize the acquisition of commonly used file information QFileInfo in Qt: suffix, name, path, link
- WinForm (5) control and its members
- 版本号大小的判断方法
猜你喜欢

【redis】发布和订阅消息

【Video】Report Sharing | 2021 Insurance Industry Digital Insights

分库分表ShardingSphere-JDBC笔记整理

leetcode 前K个高频单词

Linux install redis database

Mysql数据库安装配置详细教程

百战RHCE(第四十八战:运维工程师必会技-Ansible学习3-构建Ansible清单)

【openpyxl】过滤和排序

R语言多元线性回归、ARIMA分析美国不同候选人对经济GDP时间序列影响

How to check if the online query suddenly slows down
随机推荐
sed of the Three Musketeers of Shell Programming
复制带随机指针的链表——LeetCode
【js】获取当前时间的前后n天或前后n个月(时分秒年月日都可)
MSTP - Multiple Spanning Tree (Case + Configuration)
Jvm. Profiling tools (jconsole, jvisualvm, arthas, jprofiler, mat)
【C语言】探索数据的存储(整形篇)
单片机人机交互--矩阵按键
dump_stack()
SystemVerilog: 验证知识点点滴滴
Elastic scaling of construction resources
R language multiple linear regression, ARIMA analysis of the impact of different candidates in the United States on the economic GDP time series
Navicat 16-数据库工具
url转成obj或者obj转成url的方法
loop word
[ASM] The relationship between the role of the bytecode operation ClassWriter COMPUTE_FRAMES and visitMaxs
Mysql数据库安装配置详细教程
Two-dimensional array combat project -------- "Minesweeper Game"
[21 Days Learning Challenge] Half Insertion Sort
Mysql database installation and configuration detailed tutorial
vim简单保存窗口标识