[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN111614570A - A flow control system and method for service mesh - Google Patents

A flow control system and method for service mesh Download PDF

Info

Publication number
CN111614570A
CN111614570A CN202010313396.0A CN202010313396A CN111614570A CN 111614570 A CN111614570 A CN 111614570A CN 202010313396 A CN202010313396 A CN 202010313396A CN 111614570 A CN111614570 A CN 111614570A
Authority
CN
China
Prior art keywords
service
flow
token
service data
data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010313396.0A
Other languages
Chinese (zh)
Other versions
CN111614570B (en
Inventor
程渤
韩庆绵
程帅
陈俊亮
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing University of Posts and Telecommunications
CETC 54 Research Institute
Original Assignee
Beijing University of Posts and Telecommunications
CETC 54 Research Institute
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing University of Posts and Telecommunications, CETC 54 Research Institute filed Critical Beijing University of Posts and Telecommunications
Priority to CN202010313396.0A priority Critical patent/CN111614570B/en
Publication of CN111614570A publication Critical patent/CN111614570A/en
Application granted granted Critical
Publication of CN111614570B publication Critical patent/CN111614570B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/215Flow control; Congestion control using token-bucket
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/24Traffic characterised by specific attributes, e.g. priority or QoS
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/24Traffic characterised by specific attributes, e.g. priority or QoS
    • H04L47/2408Traffic characterised by specific attributes, e.g. priority or QoS for supporting different services, e.g. a differentiated services [DiffServ] type of service

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

本发明实施例提供一种用于服务网格的流量控制系统及方法,该系统包括:限流子系统,用于通过令牌桶限流算法,对限流服务数据的流量进行限流控制,并将关键服务数据转发到服务降级子系统;服务降级子系统,用于根据服务质量等级,对所述限流子系统转发的关键服务数据的网络带宽进行服务等级控制,得到流量控制后的关键服务。本发明实施例通过对不同类型的服务数据进行限流和服务降级,提高了窄带宽网络环境下服务网格的服务质量。

Figure 202010313396

Embodiments of the present invention provide a flow control system and method for a service mesh. The system includes: a flow-limiting subsystem, configured to perform flow-limit control on the flow of the flow-limited service data through a token bucket flow-limit algorithm, and forward the key service data to the service degradation subsystem; the service degradation subsystem is used to perform service level control on the network bandwidth of the key service data forwarded by the current limiting subsystem according to the service quality level, and obtain the key after the flow control. Serve. The embodiments of the present invention improve the service quality of the service grid in the narrow bandwidth network environment by performing current limiting and service degradation on different types of service data.

Figure 202010313396

Description

一种用于服务网格的流量控制系统及方法A flow control system and method for service mesh

技术领域technical field

本发明涉及流量控制技术领域,尤其涉及一种用于服务网格的流量控制系统及方法。The present invention relates to the technical field of flow control, and in particular, to a flow control system and method for a service grid.

背景技术Background technique

随着微服务架构的提出,给服务设计架构领域带来了巨大的影响,越来越多的传统服务架构正在朝着微服务架构转变,并衍生出Service Mesh服务网格架构,将基础通信交给服务网格去完成。基于限流和服务降级等技术,实现窄带宽网络环境下服务网格中服务质量的保证,是微服务网格中不可或缺的。With the introduction of the micro-service architecture, it has brought a huge impact on the field of service design architecture. More and more traditional service architectures are transforming towards the micro-service architecture, and the Service Mesh service grid architecture is derived, which combines basic communication with Let the service mesh do it. Based on technologies such as current limiting and service degradation, it is indispensable in microservice grids to ensure service quality in service grids in a narrow-bandwidth network environment.

虽然服务网格可以通过提供熔断、限流和降级等方式去保证服务稳定,并以迅速的通信解决一般情况下微服务集群的服务质量的保证,例如,Sentinel组件提供限流、降级和负载保护等功能,用于解决高并发、业务流量激增、负载过高和网络延迟等问题;csemesher可以简化用户对于微服务的开发和维护,提供一体化的微服务治理方式,用于改善微服务生存环境。但在不断变化的网络环境情况下,现有的服务网格工具的保障服务质量还有待提高。Although service meshes can ensure service stability by providing circuit breakers, current limiting, and downgrades, and use rapid communication to ensure the quality of service of microservice clusters in general, for example, Sentinel components provide current limiting, downgrade, and load protection and other functions to solve problems such as high concurrency, surge in business traffic, high load and network delay; csemesher can simplify the development and maintenance of microservices for users, and provide an integrated microservice governance method to improve the living environment of microservices . However, in the ever-changing network environment, the service quality of the existing service mesh tools needs to be improved.

因此,现在亟需一种用于服务网格的流量控制系统及方法来解决上述问题。Therefore, there is an urgent need for a flow control system and method for a service mesh to solve the above problems.

发明内容SUMMARY OF THE INVENTION

针对现有技术存在的问题,本发明实施例提供一种用于服务网格的流量控制系统及方法。In view of the problems existing in the prior art, the embodiments of the present invention provide a system and method for traffic control for a service mesh.

第一方面,本发明实施例提供了一种用于服务网格的流量控制系统,包括:In a first aspect, an embodiment of the present invention provides a flow control system for a service mesh, including:

限流子系统,用于通过令牌桶限流算法,对限流服务数据的流量进行限流控制,并将关键服务数据转发到服务降级子系统;The current limiting subsystem is used to control the flow of the current limiting service data through the token bucket current limiting algorithm, and forward the key service data to the service degradation subsystem;

服务降级子系统,用于根据服务质量等级,对所述限流子系统转发的关键服务数据的网络带宽进行服务等级控制,得到流量控制后的关键服务。The service degradation subsystem is used for performing service level control on the network bandwidth of the key service data forwarded by the current limiting subsystem according to the service quality level, so as to obtain the key service after the flow control.

进一步地,所述系统还包括:微服务资源管理子系统,用于对微服务进行持续性监控和状态诊断。Further, the system further includes: a microservice resource management subsystem, which is used for continuous monitoring and status diagnosis of the microservice.

进一步地,所述限流子系统包括:Further, the current limiting subsystem includes:

过滤器模块,用于对接收到的任务请求进行过滤,并根据所述任务请求进行解析,得到所述任务请求对应的服务器名和端口;A filter module, configured to filter the received task request, and parse according to the task request to obtain the server name and port corresponding to the task request;

流量控制策略执行模块,用于对令牌桶限流算法进行优化,并根据优化后的令牌桶限流算法生成策略触发式动态令牌。The flow control policy execution module is used to optimize the token bucket current limiting algorithm, and generate policy-triggered dynamic tokens according to the optimized token bucket current limiting algorithm.

进一步地,所述服务降级子系统包括:Further, the service degradation subsystem includes:

转发控制模块,用于将任务请求存入到请求线程池中,并根据配置信息和所述任务请求,将所述任务请求转发到目标服务,以得到所述任务请求对应的服务实例,或者,根据配置信息和所述任务请求,直接获取所述任务请求对应的服务实例;The forwarding control module is used to store the task request in the request thread pool, and forward the task request to the target service according to the configuration information and the task request, so as to obtain the service instance corresponding to the task request, or, According to the configuration information and the task request, directly obtain the service instance corresponding to the task request;

数据压缩降级模块,用于根据网络带宽、服务实例CPU和内存信息,对所述关键服务数据进行数据压缩降级处理,得到数据压缩后的关键服务数据。A data compression and downgrade module is configured to perform data compression and downgrade processing on the key service data according to the network bandwidth, service instance CPU and memory information, and obtain the key service data after data compression.

进一步地,所述微服务资源管理子系统包括:Further, the microservice resource management subsystem includes:

服务配置管理模块,用于提供操作接口,以供用户部署业务服务和编辑服务配置信息;The service configuration management module is used to provide an operation interface for users to deploy business services and edit service configuration information;

服务监控模块,用于对主机节点资源情况和微服务进行监控;The service monitoring module is used to monitor the resource status of the host node and microservices;

服务状态管理模块,用于对存在于服务网格中的服务进行监控,并诊断对应的service和pod运行状态。The service status management module is used to monitor the services existing in the service mesh and diagnose the corresponding service and pod running status.

第二方面,本发明实施例提供了一种用于服务网格的流量控制方法,包括:In a second aspect, an embodiment of the present invention provides a traffic control method for a service mesh, including:

获取任务请求对应的服务数据,并对所述服务数据进行解析判断,若所述服务数据为限流服务数据,则通过令牌桶限流算法,对所述限流服务数据的流量进行限流控制;Obtain the service data corresponding to the task request, and analyze and judge the service data. If the service data is the current-limiting service data, the flow of the current-limiting service data is limited by the token bucket current-limiting algorithm. control;

若所述服务数据为关键服务数据,则根据服务质量等级,对所述关键服务数据的网络带宽进行服务等级控制,得到流量控制后的关键服务。If the service data is key service data, then according to the service quality level, the service level control is performed on the network bandwidth of the key service data, and the key service after flow control is obtained.

进一步地,所述若所述服务数据为关键服务数据,则根据服务质量等级,对所述关键服务数据的网络带宽进行服务等级控制,得到流量控制后的关键服务,包括:Further, if the service data is key service data, then according to the service quality level, perform service level control on the network bandwidth of the key service data, and obtain the key service after flow control, including:

根据服务实例压缩比例公式,获取服务质量压缩比例,以根据所述服务质量压缩比例生成的服务质量等级,对所述关键服务数据的网络带宽进行服务等级控制,所述服务实例压缩比例公式为:According to the service instance compression ratio formula, the service quality compression ratio is obtained, and the service quality level generated according to the service quality compression ratio is used to perform service level control on the network bandwidth of the key service data. The service instance compression ratio formula is:

Figure BDA0002458529770000031
Figure BDA0002458529770000031

其中,Ratio(Si)表示第i个待降级服务的压缩比例,Bi表示当前时刻的用户任务请求端和服务器端之间的网络带宽;a1、a2和a3分别表示权值参数,a1+a2+a3=1;U(Ci)表示当前时刻CPU的使用率,U(Mi)表示当前时刻内存的占用率,B0表示用户任务请求端和服务器端之间的网络带宽默认值,U(C0)表示CPU的使用率默认值,U(M0)表示内存的占用率默认值。Among them, Ratio(S i ) represents the compression ratio of the i-th service to be downgraded, B i represents the network bandwidth between the user task requesting end and the server end at the current moment; a 1 , a 2 and a 3 respectively represent the weight parameters , a 1 +a 2 +a 3 =1; U(C i ) represents the CPU usage rate at the current moment, U(M i ) represents the memory usage rate at the current moment, and B 0 represents the connection between the user task requester and the server side The default value of network bandwidth, U(C 0 ) represents the default value of CPU usage, and U(M 0 ) represents the default value of memory usage.

进一步地,在所述若所述服务数据为限流服务数据,则通过令牌桶限流算法,对所述限流服务数据的流量进行限流控制之前,所述方法还包括:Further, before the flow of the current-limiting service data is controlled by the token bucket current-limiting algorithm if the service data is the current-limiting service data, the method further includes:

对令牌桶限流算法进行优化,得到优化后的令牌桶限流算法;Optimize the token bucket current limiting algorithm to obtain the optimized token bucket current limiting algorithm;

根据所述优化后的令牌桶限流算法,生成策略触发式动态令牌。According to the optimized token bucket current limiting algorithm, a policy-triggered dynamic token is generated.

进一步地,所述根据所述优化后的令牌桶限流算法,生成策略触发式动态令牌,包括:Further, generating a policy-triggered dynamic token according to the optimized token bucket current limiting algorithm includes:

获取每次令牌申请的时间,当下一次令牌申请的请求到达之后,获取当前时刻和上一时刻的令牌申请时间差;Get the time of each token application, after the next token application request arrives, get the token application time difference between the current moment and the previous moment;

根据所述令牌申请时间差和令牌添加速率,获取当前时刻的令牌可添加数;Obtain the number of tokens that can be added at the current moment according to the token application time difference and the token adding rate;

根据所述令牌可添加数、令牌桶最大数量和当前剩余令牌数量,获取令牌桶的最终添加令牌数。Obtain the final number of tokens added to the token bucket according to the number of tokens that can be added, the maximum number of tokens in the token bucket, and the current number of remaining tokens.

第三方面,本发明实施例提供一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述程序时实现如第二方面所提供的方法的步骤。In a third aspect, an embodiment of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, the processor implementing the program as described in the second aspect when the processor executes the program Steps of the provided method.

本发明实施例提供的一种用于服务网格的流量控制系统及方法,通过对不同类型的服务数据进行限流和服务降级,提高了窄带宽网络环境下服务网格的服务质量。A flow control system and method for a service grid provided by the embodiments of the present invention improves the service quality of the service grid in a narrow bandwidth network environment by performing current limiting and service degradation on different types of service data.

附图说明Description of drawings

为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the accompanying drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description These are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained according to these drawings without creative efforts.

图1为本发明实施例提供的用于服务网格的流量控制系统的结构示意图;FIG. 1 is a schematic structural diagram of a flow control system for a service mesh provided by an embodiment of the present invention;

图2为本发明实施例提供的限流子系统的结构示意图;FIG. 2 is a schematic structural diagram of a current limiting subsystem provided by an embodiment of the present invention;

图3为本发明实施例提供的服务降级子系统的结构示意图;3 is a schematic structural diagram of a service degradation subsystem provided by an embodiment of the present invention;

图4为本发明实施例提供的微服务资源管理子系统的结构示意图;FIG. 4 is a schematic structural diagram of a microservice resource management subsystem provided by an embodiment of the present invention;

图5为本发明实施例提供的用于服务网格的流量控制系统的整体框架图;5 is an overall framework diagram of a flow control system for a service mesh provided by an embodiment of the present invention;

图6为本发明实施例提供的用于服务网格的流量控制方法的流程示意图;6 is a schematic flowchart of a flow control method for a service mesh provided by an embodiment of the present invention;

图7为本发明实施例提供的限流执行步骤的示意图;7 is a schematic diagram of a current limiting execution step provided by an embodiment of the present invention;

图8为本发明实施例提供的服务降级控制的流程示意图;8 is a schematic flowchart of a service degradation control provided by an embodiment of the present invention;

图9为本发明实施例提供的策略触发式动态令牌的示意图;9 is a schematic diagram of a policy-triggered dynamic token provided by an embodiment of the present invention;

图10为本发明实施例提供的电子设备结构示意图。FIG. 10 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.

具体实施方式Detailed ways

为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the purposes, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments These are some embodiments of the present invention, but not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

图1为本发明实施例提供的用于服务网格的流量控制系统的结构示意图,如图1所示,本发明实施例提供了一种用于服务网格的流量控制系统,包括:FIG. 1 is a schematic structural diagram of a flow control system for a service mesh provided by an embodiment of the present invention. As shown in FIG. 1 , an embodiment of the present invention provides a flow control system for a service mesh, including:

限流子系统101,用于通过令牌桶限流算法,对限流服务数据的流量进行限流控制,并将关键服务数据转发到服务降级子系统。The current limiting subsystem 101 is configured to perform current limiting control on the flow of the current limiting service data through the token bucket current limiting algorithm, and forward the key service data to the service degradation subsystem.

在本发明实施例中,限流子系统101主要是对非关键服务的数据流量(即限流服务数据)进行限流。具体地,在本发明实施例中,限流子系统101需要实现对服务请求的拦截,首先判断该请求是否限流,将非限流服务(即关键服务)转发到服务降级子系统102中;对于需限流服务,基于令牌桶限流算法,通过获取网络带宽配置数据,对令牌桶算法中令牌的放置速率和令牌桶大小进行控制,从而对该限流服务数据的流量进行控制。在本发明实施例中,将令牌桶算法应用于服务网格中,从而控制各个微服务的流量控制,进而实现根据网络情况,分配相应等级的网络带宽给相应优先级较高的服务,并通过设置白名单,使关键服务的响应不受流量控制的限制。In this embodiment of the present invention, the current limiting subsystem 101 mainly performs current limiting on data traffic of non-critical services (ie, current limiting service data). Specifically, in this embodiment of the present invention, the current-limiting subsystem 101 needs to implement interception of a service request, firstly judging whether the request is current-limited, and forwarding the non-current-limiting service (that is, the key service) to the service degradation subsystem 102; For the service that needs to be limited, based on the token bucket current limiting algorithm, by obtaining the network bandwidth configuration data, the token placement rate and the token bucket size in the token bucket algorithm are controlled, so as to control the flow of the current limiting service data. control. In the embodiment of the present invention, the token bucket algorithm is applied to the service grid, so as to control the flow control of each micro-service, and then realize that according to the network conditions, the network bandwidth of the corresponding level is allocated to the service with the corresponding higher priority, and By setting a whitelist, the response of critical services is not restricted by flow control.

服务降级子系统102,用于根据服务质量等级,对所述限流子系统转发的关键服务数据的网络带宽进行服务等级控制,得到流量控制后的关键服务。The service degradation subsystem 102 is configured to perform service level control on the network bandwidth of the key service data forwarded by the current limiting subsystem according to the service quality level, so as to obtain the flow-controlled key service.

在本发明实施例中,服务降级子系统102用于在窄带宽和弱连接的网络环境下,使用相应的服务降级策略,通过监控网络情况,实现服务实例的服务等级选择,进而实现在特殊网络情况下,根据降级算法计算的降级比例,对数据进行压缩,通过牺牲服务响应数据质量的代价,提高了服务对用户的响应概率,尽最大可能自动实现服务质量的切换,以使数据尽可能的传输。需要说明的是,在本发明实施例中,服务降级子系统102也可以通过手动的方式设置预设服务质量等级。In the embodiment of the present invention, the service degradation subsystem 102 is configured to use a corresponding service degradation policy in a network environment with narrow bandwidth and weak connection, and realize the service level selection of the service instance by monitoring the network conditions, and then realize the service level selection of the service instance in the special network. In this case, the data is compressed according to the degradation ratio calculated by the degradation algorithm. By sacrificing the cost of the service response data quality, the response probability of the service to the user is improved, and the switching of service quality is automatically realized as much as possible, so that the data is as good as possible. transmission. It should be noted that, in this embodiment of the present invention, the service degradation subsystem 102 may also manually set the preset service quality level.

本发明实施例提供的一种用于服务网格的流量控制系统,通过对不同类型的服务数据进行限流和服务降级,提高了窄带宽网络环境下服务网格的服务质量。A flow control system for a service grid provided by an embodiment of the present invention improves the service quality of the service grid in a narrow bandwidth network environment by performing current limiting and service degradation on different types of service data.

在上述实施例的基础上,所述系统还包括:微服务资源管理子系统,用于对微服务进行持续性监控和状态诊断。On the basis of the above embodiment, the system further includes: a microservice resource management subsystem, which is used for continuous monitoring and status diagnosis of the microservice.

在本发明实施例中,微服务资源管理子系统用于提供操作接口,以供用户端部署业务服务,编辑服务配置信息,监控服务网格及服务网格的服务使用情况,从而实现用户端对微服务进行持续性监控及服务状态诊断。In the embodiment of the present invention, the micro-service resource management subsystem is used to provide an operation interface for the client to deploy business services, edit service configuration information, and monitor the service grid and the service usage of the service grid, so as to realize the user-end pairing Microservices perform continuous monitoring and service status diagnosis.

图2为本发明实施例提供的限流子系统的结构示意图,可参考图2所示,在上述实施例的基础上,所述限流子系统包括:FIG. 2 is a schematic structural diagram of a current limiting subsystem provided by an embodiment of the present invention. Referring to FIG. 2, on the basis of the foregoing embodiment, the current limiting subsystem includes:

过滤器模块,用于对接收到的任务请求进行过滤,并根据所述任务请求进行解析,得到所述任务请求对应的服务器名和端口。The filter module is used for filtering the received task request, and analyzing the task request to obtain the server name and port corresponding to the task request.

在本发明实施例中,过滤器模块用于对来自服务网格的外部请求进行过滤,并通过用户的任务请求,解析出该请求的服务名和端口。具体地,在本发明实施例中,过滤器模块首先对请求进行解析判断,将请求参数封装成实体,并将请求转发对应的请求响应返回给用户。在本发明实施例中,根据过滤器模块的功能需求,使用统一格式的url对业务服务进行访问,过滤器模块从Redis中读取关于流量控制的配置开关参数,选择直接转发请求或者需要经过流量控制策略,并设置Servlet作为过滤器入口接收用户端的请求,当用户端的请求到达时,使用初始化方法将request和response放入上下文对象中,解析用户请求中的URI,取出其中真实请求的服务名和访问端口号,获取配置项信息。需要说明的是,在本发明实施例中,若已开启限流模式,则匹配限流白名单,若该任务请求存在于白名单中,则根据服务名和端口号,调用请求前置处理器封装请求实体,并直接转发到相应的服务,继而将请求响应转发给用户端,否则对该任务请求进行限流控制;若能从令牌桶中获取到通行令牌,则将该任务请求转发给相应的服务,否则拦截该请求。In this embodiment of the present invention, the filter module is configured to filter external requests from the service grid, and parse out the requested service name and port through the user's task request. Specifically, in the embodiment of the present invention, the filter module first parses and judges the request, encapsulates the request parameters into an entity, and returns the request response corresponding to the forwarding of the request to the user. In the embodiment of the present invention, according to the functional requirements of the filter module, a uniform format url is used to access the business service, the filter module reads the configuration switch parameters related to flow control from Redis, and chooses to forward the request directly or needs to pass the flow Control the strategy, and set the Servlet as the filter entry to receive the request from the client. When the request from the client arrives, use the initialization method to put the request and response into the context object, parse the URI in the user request, and take out the service name and access of the real request. Port number to obtain configuration item information. It should be noted that, in this embodiment of the present invention, if the current limiting mode is enabled, the current limiting whitelist is matched, and if the task request exists in the whitelist, the request preprocessor package is called according to the service name and port number. The request entity is directly forwarded to the corresponding service, and then the request response is forwarded to the client, otherwise the task request is flow-limited; if the pass token can be obtained from the token bucket, the task request is forwarded to The corresponding service, otherwise intercept the request.

流量控制策略执行模块,用于对令牌桶限流算法进行优化,并根据优化后的令牌桶限流算法生成策略触发式动态令牌。The flow control policy execution module is used to optimize the token bucket current limiting algorithm, and generate policy-triggered dynamic tokens according to the optimized token bucket current limiting algorithm.

在本发明实施例中,流量控制策略执行模块用于对令牌桶限流算法进行优化,并根据网络环境和流量控制算法,通过优化后的令牌桶限流算法,计算出当前任务请求的响应或者拦截。可参考图2所示,流量控制策略执行模块主要用来构造令牌桶,并响应过滤器模块对令牌的申请,具体地,流量控制策略执行模块通过对令牌桶算法进行优化,按既定的令牌生成策略触发式动态生成令牌,当有令牌申请时,根据令牌桶大小和令牌现在的数量选择分配策略。在本发明实施例中,令牌桶是基于Redis实现的,保证数据读写的原子性使得令牌桶的保持数据一致性。经过令牌桶计算之后,流量控制策略执行模块向过滤器模块返回申请的结果,如果得到令牌则放行,否则对用户请求进行拦截。In the embodiment of the present invention, the flow control policy execution module is used to optimize the token bucket current limiting algorithm, and calculates the current task request through the optimized token bucket current limiting algorithm according to the network environment and the flow control algorithm. Respond or intercept. Referring to Figure 2, the flow control policy execution module is mainly used to construct a token bucket and respond to the filter module's application for a token. Specifically, the flow control policy execution module optimizes the token bucket algorithm according to the established The token generation strategy triggers the dynamic generation of tokens. When there is a token application, the allocation strategy is selected according to the size of the token bucket and the current number of tokens. In the embodiment of the present invention, the token bucket is implemented based on Redis, which ensures the atomicity of data read and write so that the token bucket maintains data consistency. After the token bucket is calculated, the flow control policy execution module returns the result of the application to the filter module, if the token is obtained, it is released, otherwise the user request is intercepted.

图3为本发明实施例提供的服务降级子系统的结构示意图,可参考图3所示,在上述实施例的基础上,所述服务降级子系统包括:FIG. 3 is a schematic structural diagram of a service degradation subsystem provided by an embodiment of the present invention. Referring to FIG. 3, on the basis of the foregoing embodiment, the service degradation subsystem includes:

转发控制模块,用于将任务请求存入到请求线程池中,并根据配置信息和所述任务请求,将所述任务请求转发到目标服务,以得到所述任务请求对应的服务实例,或者,根据配置信息和所述任务请求,直接获取所述任务请求对应的服务实例。The forwarding control module is used to store the task request in the request thread pool, and forward the task request to the target service according to the configuration information and the task request, so as to obtain the service instance corresponding to the task request, or, According to the configuration information and the task request, the service instance corresponding to the task request is directly obtained.

在本发明实施例中,转发控制模块用于将任务请求存入请求线程池中,在系统进行初始化时,转发控制模块读取配置信息和任务请求,判断是获取服务实例或者是直接转发该任务请求到目标服务。当用户配置降级类型是服务实例间降级时,则转发控制模块将监听网络带宽和获取配置信息,查询集群中对应的服务,并根据当前网络带宽和用户配置的阈值,选择服务相对应的服务实例,并将真实服务实例的名称和虚拟ip返回给请求转发控制模块,以使得转发控制模块动态配置istio中的流量规则,将流量迁移到相应版本的服务实例上。进一步地,转发控制模块将存储在请求线程池中的请求转发给真实服务,真实服务将请求响应发送到转发控制模块,并通过过滤器模块响应给用户。In the embodiment of the present invention, the forwarding control module is used to store the task request in the request thread pool. When the system is initialized, the forwarding control module reads the configuration information and the task request, and determines whether to obtain a service instance or directly forward the task. request to the target service. When the user configuration downgrade type is the downgrade between service instances, the forwarding control module will monitor the network bandwidth and obtain configuration information, query the corresponding service in the cluster, and select the service instance corresponding to the service according to the current network bandwidth and the user-configured threshold , and return the name and virtual IP of the real service instance to the request forwarding control module, so that the forwarding control module can dynamically configure the traffic rules in istio and migrate the traffic to the service instance of the corresponding version. Further, the forwarding control module forwards the request stored in the request thread pool to the real service, and the real service sends the request response to the forwarding control module, and responds to the user through the filter module.

数据压缩降级模块,用于根据网络带宽、服务实例CPU和内存信息,对所述关键服务数据进行数据压缩降级处理,得到数据压缩后的关键服务数据。A data compression and downgrade module is configured to perform data compression and downgrade processing on the key service data according to the network bandwidth, service instance CPU and memory information, and obtain the key service data after data compression.

在本发明实施例中,可参考图3所示,数据压缩降级模块用于对关键服务数据进行压缩,以达到数据压缩降级的目的。针对集群中的某一个降级服务响应数据需要降级的比例,从网络带宽、服务实例CPU和内存三个维度进行考虑,使用自适应服务降级算法,根据降级阈值和当前网络带宽自动实现数据压缩的功能。In the embodiment of the present invention, as shown in FIG. 3 , the data compression and degradation module is used to compress key service data, so as to achieve the purpose of data compression and degradation. According to the proportion of a downgraded service response data in the cluster that needs to be downgraded, considering the three dimensions of network bandwidth, service instance CPU and memory, the adaptive service downgrade algorithm is used to automatically realize the function of data compression according to the downgrade threshold and the current network bandwidth. .

图4为本发明实施例提供的微服务资源管理子系统的结构示意图,可参考图4所示,在上述实施例的基础上,所述微服务资源管理子系统包括:FIG. 4 is a schematic structural diagram of a microservice resource management subsystem provided by an embodiment of the present invention. Referring to FIG. 4 , on the basis of the foregoing embodiment, the microservice resource management subsystem includes:

服务配置管理模块,用于提供操作接口,以供用户部署业务服务和编辑服务配置信息。The service configuration management module is used to provide an operation interface for users to deploy business services and edit service configuration information.

在本发明实施例中,通过服务配置管理模块提供操作接口,实现对微服务资源的前台管理,以使得用户通过该模块部署业务服务和编辑服务配置信息。具体地,用户端通过浏览器访问前台进行相关操作,并发送http请求给后台服务器,通过后台服务器的逻辑功能处理单元处理请求,逻辑功能处理单元向网格集群和数据库发送数据请求,网格集群和数据库将响应请求发送给逻辑功能处理单元,逻辑功能处理单元处理数据并返回给前端浏览器。In the embodiment of the present invention, an operation interface is provided through a service configuration management module to realize foreground management of micro-service resources, so that users can deploy business services and edit service configuration information through this module. Specifically, the client accesses the foreground through the browser to perform related operations, and sends an http request to the background server. The request is processed through the logic function processing unit of the background server. The logic function processing unit sends data requests to the grid cluster and the database. The grid cluster And the database sends the response request to the logic function processing unit, and the logic function processing unit processes the data and returns it to the front-end browser.

服务监控模块,用于对主机节点资源情况和微服务进行监控。The service monitoring module is used to monitor the resource status of the host node and microservices.

在本发明实施例中,服务监控模块的服务监控功能,用于两个层面的监控,一是整体监控,主要是指对服务在集群中的分布以及各个主机节点的运行状态进行统一监控;另一个是指对具体微服务运行指标的监控,包括吞吐量和资源使用情况等指标。In the embodiment of the present invention, the service monitoring function of the service monitoring module is used for monitoring at two levels. One is overall monitoring, which mainly refers to the unified monitoring of the distribution of services in the cluster and the running status of each host node; the other is the overall monitoring. One refers to the monitoring of specific microservice operation indicators, including indicators such as throughput and resource usage.

服务状态管理模块,用于对存在于服务网格中的服务进行监控,并诊断对应的service和pod运行状态。The service status management module is used to monitor the services existing in the service mesh and diagnose the corresponding service and pod running status.

在本发明实施例中,服务状态管理模块对存在于服务网格中的服务进行服务详情的查看,并对该服务网格对应服务实例的运行状态进行诊断。具体地,在本发明实施例中,设置要查看详情的服务,继而将请求发送到后台SvcController控制器,后台逻辑根据服务的名称,从数据库中查询该服务的数据,并根据服务名称查询kubernetes集群中的该服务对应的service和pod信息。In the embodiment of the present invention, the service state management module checks the service details of the service existing in the service grid, and diagnoses the running state of the service instance corresponding to the service grid. Specifically, in this embodiment of the present invention, a service whose details are to be viewed is set, and then the request is sent to the background SvcController controller. The background logic queries the data of the service from the database according to the service name, and queries the kubernetes cluster according to the service name. The service and pod information corresponding to the service in .

图5为本发明实施例提供的用于服务网格的流量控制系统的整体框架图,可参考图5所示,在本发明实施例中,流量控制系统包括微服务资源管理子系统,配置存储中心、限流子系统、服务降级子系统和业务集群,其中,配置存储中心中设置有限流白名单、流量控制配置中心(用于存储流量控制配置信息)、服务降级配置中心(用于存储服务降级配置信息)和服务管理数据库。FIG. 5 is an overall frame diagram of a flow control system for a service mesh provided by an embodiment of the present invention. Referring to FIG. 5, in an embodiment of the present invention, the flow control system includes a The center, the current limiting subsystem, the service degradation subsystem and the business cluster, among which, the limited current whitelist, the flow control configuration center (used to store the flow control configuration information), and the service degradation configuration center (used to store the service) are set in the configuration storage center. downgrade configuration information) and the service management database.

图6为本发明实施例提供的用于服务网格的流量控制方法的流程示意图,如图6所示,本发明实施例提供了一种用于服务网格的流量控制方法,包括:FIG. 6 is a schematic flowchart of a flow control method for a service mesh provided by an embodiment of the present invention. As shown in FIG. 6 , an embodiment of the present invention provides a flow control method for a service mesh, including:

步骤601,获取任务请求对应的服务数据,并对所述服务数据进行解析判断,若所述服务数据为限流服务数据,则通过令牌桶限流算法,对所述限流服务数据的流量进行限流控制。Step 601: Acquire the service data corresponding to the task request, and analyze and judge the service data. If the service data is the current-limiting service data, use the token bucket current-limiting algorithm to control the traffic of the current-limiting service data. Perform current limiting control.

步骤602,若所述服务数据为关键服务数据,则根据服务质量等级,对所述关键服务数据的网络带宽进行服务等级控制,得到流量控制后的关键服务。Step 602 , if the service data is key service data, perform service level control on the network bandwidth of the key service data according to the service quality level to obtain a flow-controlled key service.

在本发明实施例中,图7为本发明实施例提供的限流执行步骤的示意图,可参考图7所示,具体步骤为:In an embodiment of the present invention, FIG. 7 is a schematic diagram of a current limiting execution step provided by an embodiment of the present invention. Referring to FIG. 7, the specific steps are:

步骤701,判断该流量类别key是否存在,若存在,则至步骤703,若不存在,则至步骤702。需要说明的实际,本发明实施例是基于分布式缓存的集群限流,需要根据不同的流量类别做流量分配,因此,在第一次访问时,需要初始化流量类别令牌桶;Step 701 , determine whether the traffic class key exists, if so, go to step 703 , if not, go to step 702 . It should be noted that the embodiment of the present invention is based on distributed cache-based cluster current limiting, and traffic allocation needs to be performed according to different traffic categories. Therefore, when accessing for the first time, the traffic category token bucket needs to be initialized;

步骤702,如果该流量类别key不存在,初始化该流量类别令牌桶;Step 702, if the traffic class key does not exist, initialize the traffic class token bucket;

步骤703,若存在,计算需要放置的令牌数;Step 703, if it exists, calculate the number of tokens to be placed;

步骤704,将当前请求时间和当前key的最后放置令牌时间做比较,定义delta为时间差,放置令牌数=delta/r,r表示添加令牌的速率,其中,在放入令牌时,保证令牌数不超过令牌桶的容量,同时,重置放入令牌的时间;Step 704, compare the current request time with the last token placement time of the current key, define delta as the time difference, the number of tokens placed=delta/r, and r represents the rate at which tokens are added, wherein, when placing tokens, Ensure that the number of tokens does not exceed the capacity of the token bucket, and at the same time, reset the time to put tokens;

步骤705,在令牌桶的容量范围内放入令牌;Step 705, put the token within the capacity range of the token bucket;

步骤706,如果获取令牌成功,即令牌桶的容量可以放入令牌,则至步骤710;若不能放入当前令牌桶,则至步骤707;Step 706, if the token acquisition is successful, that is, the capacity of the token bucket can be put into the token, then go to step 710; if it cannot be put into the current token bucket, go to step 707;

步骤707,判断是否存在空闲令牌桶,若存在,则至步骤709;否则,获取令牌失败,拦截请求;Step 707, determine whether there is an idle token bucket, if so, go to step 709; otherwise, the token acquisition fails, and the request is intercepted;

步骤708,拦截请求;Step 708, intercept the request;

步骤709,在空闲令牌桶中放置令牌;Step 709, placing the token in the free token bucket;

步骤710,允许请求。Step 710, allow the request.

图8为本发明实施例提供的服务降级控制的流程示意图,可参考图8所述,具体步骤为:FIG. 8 is a schematic flowchart of a service degradation control provided by an embodiment of the present invention. Referring to FIG. 8, the specific steps are:

步骤801,判断是否有自定义降级策略对当前请求服务进行服务降级选择,若有,至步骤803,若没有,则至步骤802;Step 801, determine whether there is a custom downgrade policy to perform service downgrade selection for the currently requested service, if yes, go to step 803, if not, go to step 802;

步骤802,通过数据压缩降级模块,对业务服务实例自动执行预算降级策略;Step 802, through the data compression downgrade module, automatically execute the budget downgrade policy on the business service instance;

步骤803,从Etcd中查询服务实例信息;Step 803, query service instance information from Etcd;

步骤804,从降级配置中心存储的降级配置信息中获取实例版本配置;Step 804, obtain the instance version configuration from the downgrade configuration information stored in the downgrade configuration center;

步骤805,制定流量分配策略,对数据进行服务等级控制;Step 805, formulate a traffic allocation strategy, and perform service level control on the data;

步骤806,接受用户访问服务的请求,返回相应服务质量的数据。Step 806: Accept the user's request for accessing the service, and return the data of the corresponding service quality.

本发明实施例提供的一种用于服务网格的流量控制方法,通过对不同类型的服务数据进行限流和服务降级,提高了窄带宽网络环境下服务网格的服务质量。The embodiment of the present invention provides a flow control method for a service grid, which improves the service quality of a service grid in a narrow bandwidth network environment by performing current limiting and service degradation on different types of service data.

在上述实施例的基础上,所述若所述服务数据为关键服务数据,则根据服务质量等级,对所述关键服务数据的网络带宽进行服务等级控制,得到流量控制后的关键服务,包括:On the basis of the above embodiment, if the service data is key service data, then according to the service quality level, perform service level control on the network bandwidth of the key service data, and obtain the key service after flow control, including:

根据服务实例压缩比例公式,获取服务质量压缩比例,以根据所述服务质量压缩比例生成的服务质量等级,对所述关键服务数据的网络带宽进行服务等级控制,所述服务实例压缩比例公式为:According to the service instance compression ratio formula, the service quality compression ratio is obtained, and the service quality level generated according to the service quality compression ratio is used to perform service level control on the network bandwidth of the key service data. The service instance compression ratio formula is:

Figure BDA0002458529770000101
Figure BDA0002458529770000101

其中,Ratio(Si)表示第i个待降级服务的压缩比例,Bi表示当前时刻的用户任务请求端和服务器端之间的网络带宽;a1、a2和a3分别表示权值参数,a1+a2+a3=1;U(Ci)表示当前时刻CPU的使用率,U(Mi)表示当前时刻内存的占用率,B0表示用户任务请求端和服务器端之间的网络带宽默认值,U(C0)表示CPU的使用率默认值,U(M0)表示内存的占用率默认值。Among them, Ratio(S i ) represents the compression ratio of the i-th service to be downgraded, B i represents the network bandwidth between the user task requesting end and the server end at the current moment; a 1 , a 2 and a 3 respectively represent the weight parameters , a 1 +a 2 +a 3 =1; U(C i ) represents the CPU usage rate at the current moment, U(M i ) represents the memory usage rate at the current moment, and B 0 represents the connection between the user task requester and the server side The default value of network bandwidth, U(C 0 ) represents the default value of CPU usage, and U(M 0 ) represents the default value of memory usage.

在本发明实施例中,对于某一个降级服务Si,当有请求到来时,获取前一个网络采集周期的网络的带宽Bi,并将该带宽Bi作为为当前时刻的网络带宽。由于需要根据当前网络的带宽动态的调整服务响应数据的质量,因此需要获取服务端与客户端之间的网络带宽数据,在本发明实施例中,使用iperf工具,调用dmc命令,来检测客户端与服务器端的网速Bi;通过kubernetes监控集群中服务实例的资源使用信息,采集当前时刻CPU的使用率U(Ci)和当前时刻内存的占用率U(Mi)的数据。进一步地,本发明实施例根据系统的实际情况,设置正常环境和资源情况下的默认值B0、U(C0)和U(M0),并设置权值参数{α1,α2,α3}对各项指标的影响权重进行标识,从而通过以上数据进行降级比例的限制。In the embodiment of the present invention, for a certain downgraded service S i , when a request comes, obtain the network bandwidth B i of the previous network collection period, and use the bandwidth B i as the network bandwidth at the current moment. Since the quality of the service response data needs to be dynamically adjusted according to the current network bandwidth, it is necessary to obtain the network bandwidth data between the server and the client. In this embodiment of the present invention, the iperf tool is used to call the dmc command to detect the client and server-side network speed B i ; monitor the resource usage information of service instances in the cluster through kubernetes, and collect data on the current CPU usage U(C i ) and the current memory usage U(M i ). Further, according to the actual situation of the system, the embodiment of the present invention sets default values B 0 , U(C 0 ) and U(M 0 ) under normal environment and resource conditions, and sets weight parameters {α 1 , α 2 , α 3 } identifies the impact weight of each index, so as to limit the degradation ratio through the above data.

进一步地,在本发明实施例中,通过服务实例压缩比例公式计算出每个服务实例需要压缩到的比例,从中选择Ratio值最大的服务实例,返回相应的服务实例ip,为了最大限度的减少服务数据质量降低的幅度,选择压缩比例最小的服务实例,即选择压缩到比例最大的服务实例用于响应服务请求。Further, in the embodiment of the present invention, the ratio to which each service instance needs to be compressed is calculated by the service instance compression ratio formula, and the service instance with the largest Ratio value is selected from the service instance, and the corresponding service instance ip is returned, in order to minimize the service instance. The degree of data quality reduction, select the service instance with the smallest compression ratio, that is, select the service instance compressed to the largest ratio to respond to service requests.

在上述实施例的基础上,在所述若所述服务数据为限流服务数据,则通过令牌桶限流算法,对所述限流服务数据的流量进行限流控制之前,所述方法还包括:On the basis of the above embodiment, before the flow of the current-limiting service data is controlled by the token bucket current-limiting algorithm if the service data is the current-limiting service data, the method further includes: include:

对令牌桶限流算法进行优化,得到优化后的令牌桶限流算法;Optimize the token bucket current limiting algorithm to obtain the optimized token bucket current limiting algorithm;

根据所述优化后的令牌桶限流算法,生成策略触发式动态令牌。According to the optimized token bucket current limiting algorithm, a policy-triggered dynamic token is generated.

在上述实施例的基础上,所述根据所述优化后的令牌桶限流算法,生成策略触发式动态令牌,包括:On the basis of the above embodiment, generating a policy-triggered dynamic token according to the optimized token bucket current limiting algorithm includes:

获取每次令牌申请的时间,当下一次令牌申请的请求到达之后,获取当前时刻和上一时刻的令牌申请时间差;Get the time of each token application, after the next token application request arrives, get the token application time difference between the current moment and the previous moment;

根据所述令牌申请时间差和令牌添加速率,获取当前时刻的令牌可添加数;Obtain the number of tokens that can be added at the current moment according to the token application time difference and the token adding rate;

根据所述令牌可添加数、令牌桶最大数量和当前剩余令牌数量,获取令牌桶的最终添加令牌数。Obtain the final number of tokens added to the token bucket according to the number of tokens that can be added, the maximum number of tokens in the token bucket, and the current number of remaining tokens.

图9为本发明实施例提供的策略触发式动态令牌的示意图,可参考图9所示,在本发明实施例中,对令牌桶算法进行优化改进,提供了一种策略触发式动态令牌桶算法。传统令牌桶算法需要配置一个专用的线程一直重复运行,为了减少对Redis操作的次数,提高流量控制模块的性能,因此,本发明实施例将令牌生成设计成触发式生成方式。FIG. 9 is a schematic diagram of a policy-triggered dynamic token provided by an embodiment of the present invention. Referring to FIG. 9 , in the embodiment of the present invention, the token bucket algorithm is optimized and improved to provide a policy-triggered dynamic token. Bucket algorithm. The traditional token bucket algorithm needs to configure a dedicated thread to run repeatedly. In order to reduce the number of Redis operations and improve the performance of the flow control module, the embodiment of the present invention designs the token generation as a trigger generation method.

具体地,在本发明实施例中,通过设置变量,记录每次令牌申请的时间,当下一次来自过滤器模块对令牌申请的请求到达之后,计算当前时刻与上一次时刻的令牌申请时间差,根据添加令牌的速率计算这段时间可以添加的令牌数,计算方式表示为:Specifically, in the embodiment of the present invention, the time of each token application is recorded by setting a variable, and after the next request for token application from the filter module arrives, the time difference between the current moment and the last token application time is calculated. , calculate the number of tokens that can be added during this period according to the rate of adding tokens, and the calculation method is expressed as:

Figure BDA0002458529770000121
Figure BDA0002458529770000121

其中,currMillis表示当前申请的时刻,lastMillis表示上次申请令牌的时刻,r表示添加令牌的速率,单位为个/秒。最终添加到令牌桶的令牌数表示为:Among them, currMillis represents the moment of the current application, lastMillis represents the moment of the last token application, and r represents the rate of adding tokens, in units/second. The number of tokens finally added to the token bucket is expressed as:

resultPermits=min(reservePermits,maxPermits-storedPermits);resultPermits=min(reservePermits,maxPermits-storedPermits);

其中,maxPermits表示令牌桶的大小,storedPermits表示当前存在的令牌的数量。Among them, maxPermits represents the size of the token bucket, and storedPermits represents the number of tokens currently existing.

进一步地,在本发明实施例中,对于部署到服务网格中的服务用户根据业务,需要将其分成不同的等级,即将其划分成了多种类别的流量。一般情况下,对多分类的流量会为每类流量定义一个单独的令牌桶,与其它类别实现隔离,但使用这样的解决方式会带来网络资源浪费和带宽使用率低等效能问题,当某一种类别的令牌桶中的令牌已全部使用完,相应类别的请求被拦截或处于等待状态;同时,另一种类别的请求频率由于业务的需要并不会那么高,以至于令牌桶中的令牌一直处于较多的数量,对于这样的情况,网络资源就处于一个浪费的状态;并且,令牌供不应求的类别请求,会因为没有令牌被拦截或处于排队状态延迟响应,服务质量因此受到了影响。鉴于以上的问题,本发明实施例使用了半隔离令牌桶,实现多分类流量的控制整形,使得某一类流量的令牌在满足最低需求的情况下,允许其它分类使用剩余的令牌。Further, in the embodiment of the present invention, the service users deployed in the service grid need to be divided into different levels according to the business, that is, divided into various types of traffic. In general, for multi-classified traffic, a separate token bucket is defined for each class of traffic to achieve isolation from other classes. However, using such a solution will bring about performance problems such as wasted network resources and low bandwidth usage. When The tokens in a certain type of token bucket have been used up, and the corresponding type of requests are blocked or in a waiting state; at the same time, the request frequency of another type is not so high due to business needs, so that the There are always a large number of tokens in the bucket. In this case, network resources are in a wasted state; and, for requests for categories that are in short supply, the response will be delayed because no tokens are intercepted or queued. The quality of service suffers as a result. In view of the above problems, the embodiments of the present invention use semi-isolated token buckets to implement control and shaping of multi-category traffic, so that tokens of a certain type of traffic are allowed to use the remaining tokens for other categories under the condition that the tokens of a certain type of traffic meet the minimum requirements.

图10为本发明实施例提供的电子设备结构示意图,参照图10,该电子设备可以包括:处理器(processor)1001、通信接口(Communications Interface)1002、存储器(memory)1003和通信总线1004,其中,处理器1001,通信接口1002,存储器1003通过通信总线1004完成相互间的通信。处理器1001可以调用存储器1003中的逻辑指令,以执行如下方法:获取任务请求对应的服务数据,并对所述服务数据进行解析判断,若所述服务数据为限流服务数据,则通过令牌桶限流算法,对所述限流服务数据的流量进行限流控制;若所述服务数据为关键服务数据,则根据服务质量等级,对所述关键服务数据的网络带宽进行服务等级控制,得到流量控制后的关键服务。FIG. 10 is a schematic structural diagram of an electronic device provided by an embodiment of the present invention. Referring to FIG. 10 , the electronic device may include: a processor (processor) 1001, a communications interface (Communications Interface) 1002, a memory (memory) 1003, and a communication bus 1004, wherein , the processor 1001 , the communication interface 1002 , and the memory 1003 communicate with each other through the communication bus 1004 . The processor 1001 can call the logic instruction in the memory 1003 to execute the following method: obtain the service data corresponding to the task request, and analyze and judge the service data, if the service data is the current-limiting service data, pass the token Bucket current limiting algorithm, to perform current limiting control on the flow of the current limiting service data; if the service data is key service data, perform service level control on the network bandwidth of the key service data according to the service quality level, and obtain Critical services after flow control.

此外,上述的存储器1003中的逻辑指令可以通过软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。In addition, the above-mentioned logic instructions in the memory 1003 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present invention can be embodied in the form of a software product in essence, or the part that contributes to the prior art or the part of the technical solution. The computer software product is stored in a storage medium, including Several instructions are used to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, Read-Only Memory (ROM, Read-Only Memory), Random Access Memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program codes .

另一方面,本发明实施例还提供一种非暂态计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现以执行上述各实施例提供的用于服务网格的流量控制方法,例如包括:获取任务请求对应的服务数据,并对所述服务数据进行解析判断,若所述服务数据为限流服务数据,则通过令牌桶限流算法,对所述限流服务数据的流量进行限流控制;若所述服务数据为关键服务数据,则根据服务质量等级,对所述关键服务数据的网络带宽进行服务等级控制,得到流量控制后的关键服务。On the other hand, an embodiment of the present invention further provides a non-transitory computer-readable storage medium on which a computer program is stored, and the computer program is implemented when executed by a processor to execute the service mesh provided by the above embodiments The traffic control method, for example, includes: acquiring service data corresponding to the task request, and analyzing and judging the service data, if the service data is the current-limiting service data, using the token bucket current-limiting algorithm to limit the The flow of the streaming service data is flow-limited; if the service data is key service data, the network bandwidth of the key service data is subject to service level control according to the service quality level to obtain a flow-controlled key service.

以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性的劳动的情况下,即可以理解并实施。The device embodiments described above are only illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in One place, or it can be distributed over multiple network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution in this embodiment. Those of ordinary skill in the art can understand and implement it without creative effort.

通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到各实施方式可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件。基于这样的理解,上述技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在计算机可读存储介质中,如ROM/RAM、磁碟、光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行各个实施例或者实施例的某些部分所述的方法。From the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, and certainly can also be implemented by hardware. Based on this understanding, the above-mentioned technical solutions can be embodied in the form of software products in essence or the parts that make contributions to the prior art, and the computer software products can be stored in computer-readable storage media, such as ROM/RAM, magnetic A disc, an optical disc, etc., includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform the methods described in various embodiments or some parts of the embodiments.

最后应说明的是:以上实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的精神和范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, but not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that it can still be The technical solutions described in the foregoing embodiments are modified, or some technical features thereof are equivalently replaced; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims (10)

1. A flow control system for a services grid, comprising:
the flow limiting subsystem is used for carrying out flow limiting control on the flow of the flow limiting service data through a token bucket flow limiting algorithm and forwarding the key service data to the service degradation subsystem;
and the service degradation subsystem is used for controlling the service level of the network bandwidth of the key service data forwarded by the flow limiting subsystem according to the service quality level to obtain the key service after flow control.
2. The flow control system for a services grid according to claim 1, wherein said system further comprises: and the micro-service resource management subsystem is used for carrying out continuous monitoring and state diagnosis on the micro-service.
3. The flow control system for a services grid according to claim 1, wherein the flow limiting subsystem comprises:
the filter module is used for filtering the received task request and analyzing the received task request according to the task request to obtain a server name and a port corresponding to the task request;
and the flow control strategy execution module is used for optimizing the token bucket flow limiting algorithm and generating a strategy triggered dynamic token according to the optimized token bucket flow limiting algorithm.
4. The flow control system for a services grid according to claim 1, wherein said service downgrading subsystem comprises:
the forwarding control module is used for storing a task request into a request thread pool, and forwarding the task request to a target service according to configuration information and the task request so as to obtain a service instance corresponding to the task request, or directly obtaining the service instance corresponding to the task request according to the configuration information and the task request;
and the data compression degradation module is used for performing data compression degradation processing on the key service data according to the network bandwidth, the service instance CPU and the memory information to obtain the key service data after data compression.
5. The flow control system for a services grid according to claim 2, wherein said micro-service resource management subsystem comprises:
the service configuration management module is used for providing an operation interface for a user to deploy business service and edit service configuration information;
the service monitoring module is used for monitoring the resource condition of the host node and the micro-service;
and the service state management module is used for monitoring the service existing in the service grid and diagnosing the corresponding service and pod running states.
6. A method of flow control for a services grid, comprising:
acquiring service data corresponding to a task request, analyzing and judging the service data, and if the service data is current-limiting service data, performing current-limiting control on the flow of the current-limiting service data through a token bucket current-limiting algorithm;
and if the service data is key service data, performing service level control on the network bandwidth of the key service data according to the service quality level to obtain the key service after flow control.
7. The method of claim 6, wherein if the service data is key service data, performing service level control on the network bandwidth of the key service data according to a service quality level to obtain a flow-controlled key service, comprises:
obtaining a service quality compression ratio according to a service instance compression ratio formula, and performing service level control on the network bandwidth of the key service data according to a service quality level generated according to the service quality compression ratio, wherein the service instance compression ratio formula is as follows:
Figure FDA0002458529760000021
wherein Ratio (S)i) Representing the compression ratio of the ith service to be degraded, BiThe network bandwidth between the user task request end and the server end at the current moment is represented; a is1、a2And a3Respectively represent weight parameters, a1+a2+a3=1;U(Ci) Indicates the CPU utilization at the present time, U (M)i) Indicating the occupancy rate of the memory at the current time, B0Indicating a default value of network bandwidth, U (C), between the user task request side and the server side0) Indicates the CPU utilization default, U (M)0) Indicating the occupancy rate default of the memory.
8. The method of claim 6, wherein before performing flow restriction control on the flow of the limited service data through a token bucket flow restriction algorithm if the service data is the limited service data, the method further comprises:
optimizing the token bucket current limiting algorithm to obtain an optimized token bucket current limiting algorithm;
and generating a strategy triggering type dynamic token according to the optimized token bucket current limiting algorithm.
9. The method of traffic control for a service grid according to claim 8, wherein said generating policy-triggered dynamic tokens according to said optimized token bucket throttling algorithm comprises:
acquiring the time of each token application, and acquiring the time difference between the current time and the previous time of the token application after the request of the next token application arrives;
obtaining the token adding number at the current moment according to the token application time difference and the token adding rate;
and obtaining the final added token number of the token bucket according to the token addable number, the maximum token bucket number and the current remaining token number.
10. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the steps of the flow control method according to any one of claims 6 to 9 are implemented when the program is executed by the processor.
CN202010313396.0A 2020-04-20 2020-04-20 Flow control system and method for service grid Active CN111614570B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010313396.0A CN111614570B (en) 2020-04-20 2020-04-20 Flow control system and method for service grid

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010313396.0A CN111614570B (en) 2020-04-20 2020-04-20 Flow control system and method for service grid

Publications (2)

Publication Number Publication Date
CN111614570A true CN111614570A (en) 2020-09-01
CN111614570B CN111614570B (en) 2022-07-01

Family

ID=72198261

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010313396.0A Active CN111614570B (en) 2020-04-20 2020-04-20 Flow control system and method for service grid

Country Status (1)

Country Link
CN (1) CN111614570B (en)

Cited By (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111897659A (en) * 2020-09-29 2020-11-06 腾讯科技(深圳)有限公司 Method, system and device for controlling service processing frequency and electronic equipment
CN112187521A (en) * 2020-09-09 2021-01-05 上海微亿智造科技有限公司 Apollo-based system for realizing industrial internet distributed service degradation
CN113162802A (en) * 2021-04-02 2021-07-23 东云睿连(武汉)计算技术有限公司 Communication method, equipment and storage medium based on InfiniBand
CN113518041A (en) * 2021-06-15 2021-10-19 新华三大数据技术有限公司 Message processing method and device
CN113806096A (en) * 2021-09-24 2021-12-17 上海通联金融服务有限公司 Distributed current-limiting in-row pre-system high-availability improving method based on sentinel
CN114036031A (en) * 2022-01-05 2022-02-11 阿里云计算有限公司 Scheduling system and method for resource service application in enterprise digital middleboxes
CN114422447A (en) * 2021-12-25 2022-04-29 中国海洋大学 Multi-service multi-network converged communication scheduling method and system, medium, terminal and application
CN114615073A (en) * 2022-03-22 2022-06-10 广州方硅信息技术有限公司 Access flow control method, device, equipment and medium
CN114844835A (en) * 2022-07-04 2022-08-02 眉山环天智慧科技有限公司 Self-adaptive dynamic current limiting method and device
CN115002211A (en) * 2022-07-28 2022-09-02 成都乐超人科技有限公司 Cloud-native-based after-sale micro-service implementation method, device, equipment and medium
CN115189973A (en) * 2022-09-13 2022-10-14 以见科技(苏州)有限公司 Method and system for software security and encryption
CN115988072A (en) * 2022-12-15 2023-04-18 中国电信股份有限公司 Network element traffic management method, device and system based on layered architecture
CN115987902A (en) * 2022-12-20 2023-04-18 平安银行股份有限公司 Service current limiting method and device, computer equipment and storage medium
CN116582497A (en) * 2023-04-21 2023-08-11 中国测绘科学研究院 Method for shaping self-adaptive traffic of high-efficiency GIS service under single server condition
CN116743833A (en) * 2023-08-16 2023-09-12 雄安国创中心科技有限公司 Method and device for enhancing communication capability and network control capability of terminal and service
CN115988072B (en) * 2022-12-15 2025-02-18 中国电信股份有限公司 Network element traffic management method, device and system based on layered architecture

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102665187A (en) * 2012-02-29 2012-09-12 华中科技大学 Intelligent pipeline control method based on intelligent terminal
CN103281251A (en) * 2013-06-18 2013-09-04 北京百度网讯科技有限公司 Data transmission method and system between data centers and subsystem of data transmission system
US20150140983A1 (en) * 2012-05-04 2015-05-21 Vodafone Ip Licensing Limited Telecommunication networks
CN110475585A (en) * 2017-03-27 2019-11-19 王诠中 Implement the System and method for of physical stimulation service

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102665187A (en) * 2012-02-29 2012-09-12 华中科技大学 Intelligent pipeline control method based on intelligent terminal
US20150140983A1 (en) * 2012-05-04 2015-05-21 Vodafone Ip Licensing Limited Telecommunication networks
CN103281251A (en) * 2013-06-18 2013-09-04 北京百度网讯科技有限公司 Data transmission method and system between data centers and subsystem of data transmission system
CN110475585A (en) * 2017-03-27 2019-11-19 王诠中 Implement the System and method for of physical stimulation service

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
WES LLOYD等: "Serverless Computing: An Investigation of Factors Influencing Microservice Performance", 《2018 IEEE INTERNATIONAL CONFERENCE ON CLOUD ENGINEERING》 *
孙杰平: "论Service Mesh在微服务架构中的优势", 《通信世界》 *
蔡亚楠: "基于微服务的软件体系结构设计方法研究与应用", 《CNKI优秀硕士学位论文全文库》 *

Cited By (23)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112187521A (en) * 2020-09-09 2021-01-05 上海微亿智造科技有限公司 Apollo-based system for realizing industrial internet distributed service degradation
CN111897659A (en) * 2020-09-29 2020-11-06 腾讯科技(深圳)有限公司 Method, system and device for controlling service processing frequency and electronic equipment
CN113162802A (en) * 2021-04-02 2021-07-23 东云睿连(武汉)计算技术有限公司 Communication method, equipment and storage medium based on InfiniBand
CN113518041A (en) * 2021-06-15 2021-10-19 新华三大数据技术有限公司 Message processing method and device
CN113518041B (en) * 2021-06-15 2023-05-16 新华三大数据技术有限公司 Message processing method and device
CN113806096A (en) * 2021-09-24 2021-12-17 上海通联金融服务有限公司 Distributed current-limiting in-row pre-system high-availability improving method based on sentinel
CN114422447A (en) * 2021-12-25 2022-04-29 中国海洋大学 Multi-service multi-network converged communication scheduling method and system, medium, terminal and application
CN114422447B (en) * 2021-12-25 2024-05-17 中国海洋大学 Multi-service multi-network converged communication scheduling method and system, medium, terminal and application
CN114036031A (en) * 2022-01-05 2022-02-11 阿里云计算有限公司 Scheduling system and method for resource service application in enterprise digital middleboxes
CN114615073A (en) * 2022-03-22 2022-06-10 广州方硅信息技术有限公司 Access flow control method, device, equipment and medium
CN114844835B (en) * 2022-07-04 2022-09-20 眉山环天智慧科技有限公司 Self-adaptive dynamic current limiting method and device
CN114844835A (en) * 2022-07-04 2022-08-02 眉山环天智慧科技有限公司 Self-adaptive dynamic current limiting method and device
CN115002211B (en) * 2022-07-28 2022-12-06 成都乐超人科技有限公司 Method, device, equipment and medium for realizing after-sale micro-service based on cloud protogenesis
CN115002211A (en) * 2022-07-28 2022-09-02 成都乐超人科技有限公司 Cloud-native-based after-sale micro-service implementation method, device, equipment and medium
CN115189973A (en) * 2022-09-13 2022-10-14 以见科技(苏州)有限公司 Method and system for software security and encryption
CN115189973B (en) * 2022-09-13 2022-11-25 以见科技(苏州)有限公司 Method and system for software security and encryption
CN115988072A (en) * 2022-12-15 2023-04-18 中国电信股份有限公司 Network element traffic management method, device and system based on layered architecture
CN115988072B (en) * 2022-12-15 2025-02-18 中国电信股份有限公司 Network element traffic management method, device and system based on layered architecture
CN115987902A (en) * 2022-12-20 2023-04-18 平安银行股份有限公司 Service current limiting method and device, computer equipment and storage medium
CN116582497A (en) * 2023-04-21 2023-08-11 中国测绘科学研究院 Method for shaping self-adaptive traffic of high-efficiency GIS service under single server condition
CN116582497B (en) * 2023-04-21 2024-01-23 中国测绘科学研究院 Method for shaping self-adaptive traffic of high-efficiency GIS service under single server condition
CN116743833A (en) * 2023-08-16 2023-09-12 雄安国创中心科技有限公司 Method and device for enhancing communication capability and network control capability of terminal and service
CN116743833B (en) * 2023-08-16 2023-11-03 雄安国创中心科技有限公司 Method and device for enhancing communication capability and network control capability of terminal and service

Also Published As

Publication number Publication date
CN111614570B (en) 2022-07-01

Similar Documents

Publication Publication Date Title
CN111614570B (en) Flow control system and method for service grid
US20230283681A1 (en) System and method for throttling service requests having non-uniform workloads
US9419904B2 (en) System and method for throttling service requests using work-based tokens
CN109672627A (en) Method for processing business, platform, equipment and storage medium based on cluster server
US11537304B2 (en) Data verification method and apparatus, and storage medium
US8191068B2 (en) Resource management system, resource information providing method and program
US20150199281A1 (en) Apparatus and method for meeting performance metrics for users in file systems
CN114050983B (en) Flow self-adaptive acquisition method and device, storage medium and electronic equipment
CN116089213A (en) Cloud platform resource monitoring method, device, electronic device and readable storage medium
WO2023057231A1 (en) Managing workload in a service mesh
WO2021068568A1 (en) Data collection optimization method, apparatus and device, and readable storage medium
CN105528283A (en) Method for detecting calculated load value in load balancing algorithm by mobile application
CN108804351B (en) Cache replacement method and device
CN106775942B (en) A cloud application-oriented solid-state disk cache management system and method
CN117032977A (en) Mixed part application resource allocation method and device, computer equipment and storage medium
CN111193760B (en) Information sending method, device and storage medium
WO2023207424A1 (en) Service capacity load parameter reporting method, and apparatus
CN115469966A (en) Elastic expansion method and device for container cloud service
TWI684347B (en) System for automatically adjusting serverless function and method thereof
CN111813621A (en) Data processing method, device, equipment and medium based on Flume data middlebox
CN113626143B (en) Virtual machine tuning method based on user behavior monitoring
CN108243112A (en) Chat group method for controlling network flow and device, storage medium and computing device
CN117812007A (en) Method and system for limiting current
CN112363610B (en) Method and device for reducing power consumption of network on chip, CPU chip and server
CN115794925A (en) Method and device for determining computing node, storage medium and electronic device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant