当前位置:网站首页>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
边栏推荐
猜你喜欢
How to do patent mining, the key is to find patent points, in fact, it is not too difficult
Volatile和CAS
Some Experiences of Embedded Software Logging
postgresql parameter meaning
ABP中的数据过滤器
The statistical data analysis, interview manual"
J9 Digital Theory: DAO governance is more like an ecological process: governance is native to the network and continues to evolve
3d打印出现stl文件物体不是流形,意味着不是水密体...解决办法
力扣------用栈操作构建数组
详谈二叉搜索树
随机推荐
MySQL进阶查询
How to convert url to obj or obj to url
C # - delegate detailed usage
Linux安装redis数据库
Mysql数据库安装配置详细教程
Dual machine thermal for comprehensive experiment (VRRP + OSPF + + NAT + DHCP + VTP PVSTP + single-arm routing)
池化技术有多牛?来,告诉你阿里的Druid为啥如此牛逼!
Distributed. Performance optimization
【爬虫】scrapy创建运行爬虫、解析页面(嵌套url)、自定义中间件(设置UserAgent和代理IP)、自定义管道(保存到mysql)
EN 12467纤维水泥平板产品—CE认证
[Server data recovery] Data recovery case of lvm information and VXFS file system corruption caused by raid5 crash
R language multiple linear regression, ARIMA analysis of the impact of different candidates in the United States on the economic GDP time series
微信小程序内部A页面向内嵌H5页面跳转,并且传参
Pico 4更多参数曝光:Pancake+彩色透视,还有Pro版本
Shell 文本三剑客 Sed
apache+PHP+MySQL+word press,安装word press时页面报错?
微信小程序通过URL Scheme动态的渲染数据
J9数字论:DAO治理更像一种生态过程:治理原生于网络,不断演变
循环单词
两个数组的交集