CN110535776A - Gateway current-limiting method, device, gateway, system and storage medium - Google Patents
Gateway current-limiting method, device, gateway, system and storage medium Download PDFInfo
- Publication number
- CN110535776A CN110535776A CN201910613993.2A CN201910613993A CN110535776A CN 110535776 A CN110535776 A CN 110535776A CN 201910613993 A CN201910613993 A CN 201910613993A CN 110535776 A CN110535776 A CN 110535776A
- Authority
- CN
- China
- Prior art keywords
- current
- limiting
- plug
- limiting plug
- database
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 58
- 230000004913 activation Effects 0.000 claims description 28
- 230000008569 process Effects 0.000 claims description 9
- 238000004590 computer program Methods 0.000 claims description 6
- 230000004044 response Effects 0.000 claims description 6
- 238000012423 maintenance Methods 0.000 claims description 5
- 230000008859 change Effects 0.000 claims description 4
- 238000005516 engineering process Methods 0.000 abstract description 2
- 238000010586 diagram Methods 0.000 description 16
- 238000013461 design Methods 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 230000002093 peripheral effect Effects 0.000 description 2
- 238000012360 testing method Methods 0.000 description 2
- 230000005540 biological transmission Effects 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 239000002131 composite material Substances 0.000 description 1
- 230000008094 contradictory effect Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
- 230000026676 system process Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44505—Configuring for program initiating, e.g. using registry, configuration files
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44521—Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
- G06F9/44526—Plug-ins; Add-ons
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L12/00—Data switching networks
- H04L12/66—Arrangements for connecting between networks having differing types of switching systems, e.g. gateways
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L47/00—Traffic control in data switching networks
- H04L47/10—Flow control; Congestion control
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
本发明实施例涉及信息技术领域,公开了一种网关限流方法、装置、网关、系统及存储介质,包括:以预设周期将本地设置的限流插件启动列表,同步更新为数据库中设置的限流插件启动列表;其中,所述限流插件启动列表用于指示需启动的各限流插件,各所述限流插件分别对应一限流策略;根据所述更新后的限流插件启动列表,运行所述需启动的各限流插件进行限流。本发明实施方式中提供的网关限流方法、装置、网关、系统及存储介质,可以提高网关限流策略更新的效率。
Embodiments of the present invention relate to the field of information technology, and disclose a gateway current limiting method, device, gateway, system and storage medium. Current-limiting plug-in startup list; wherein, the current-limiting plug-in startup list is used to indicate each current-limiting plug-in to be activated, and each of the current-limiting plug-ins corresponds to a current-limiting strategy; according to the updated current-limiting plug-in startup list , and run each current-limiting plug-in to be activated to limit the current. The gateway current limiting method, device, gateway, system and storage medium provided in the embodiments of the present invention can improve the efficiency of updating the gateway current limiting policy.
Description
技术领域technical field
本发明实施例涉及信息技术领域,特别涉及一种网关限流方法、装置、网关、系统及存储介质。Embodiments of the present invention relate to the field of information technology, and in particular, to a gateway current limiting method, device, gateway, system, and storage medium.
背景技术Background technique
为了保证网络的稳定和数据库的正常使用,需要在用户并发数较大时实施网络的限流。目前常用的限流方法有令牌桶、漏桶、计数器等方式。In order to ensure the stability of the network and the normal use of the database, it is necessary to implement network current limiting when the number of concurrent users is large. Currently, commonly used current limiting methods include token buckets, leaky buckets, and counters.
发明人发现现有技术中至少存在如下问题:当限流策略需要改变时,传统的方法需要先进行线下测试,线下测试成功后,在系统空闲时进行重启后进行限流策略的更改,限流策略的更新不够灵活,效率较低。The inventor found that there are at least the following problems in the prior art: when the current limiting strategy needs to be changed, the traditional method needs to perform an offline test first, and after the offline test is successful, the current limiting strategy is changed after restarting when the system is idle. The update of the flow policy is not flexible enough and the efficiency is low.
发明内容SUMMARY OF THE INVENTION
本发明实施方式的目的在于提供一种网关限流方法、装置、网关、系统及存储介质,使得限流策略的更新的效率提高。The purpose of the embodiments of the present invention is to provide a gateway current limiting method, device, gateway, system and storage medium, so as to improve the update efficiency of the current limiting policy.
为解决上述技术问题,本发明的实施方式提供了一种网关限流方法,包括:以预设周期将本地设置的限流插件启动列表,同步更新为数据库中设置的限流插件启动列表;其中,限流插件启动列表用于指示需启动的各限流插件,各限流插件分别对应一限流策略;根据更新后的限流插件启动列表,运行需启动的各限流插件进行限流。In order to solve the above-mentioned technical problems, embodiments of the present invention provide a gateway current limiting method, including: synchronously updating a locally set current limiting plug-in activation list to a current limiting plug-in activation list set in a database with a preset period; wherein , the current-limiting plugin startup list is used to indicate each current-limiting plugin to be activated, and each current-limiting plugin corresponds to a current-limiting strategy; according to the updated current-limiting plugin startup list, run each current-limiting plugin to be activated for current limiting.
本发明的实施方式还提供了一种网关限流装置,包括:启动列表维护模块,用于以预设周期将本地设置的限流插件启动列表,同步更新为数据库中设置的限流插件启动列表;其中,限流插件启动列表用于指示需启动的各限流插件,各限流插件分别对应一限流策略;限流模块,用于根据更新后的限流插件启动列表,运行需启动的各限流插件进行限流。Embodiments of the present invention also provide a gateway current limiting device, comprising: a startup list maintenance module, configured to synchronously update a locally set current limiting plug-in startup list to a current limiting plugin startup list set in a database at a preset period ; Among them, the current-limiting plug-in startup list is used to indicate each current-limiting plug-in that needs to be activated, and each current-limiting plug-in corresponds to a current-limiting strategy; the current-limiting module is used to run the Each current limiting plug-in performs current limiting.
本发明的实施方式还提供了一种网关,包括:至少一个处理器;以及,与至少一个处理器通信连接的存储器;其中,存储器存储有可被至少一个处理器执行的指令,指令被至少一个处理器执行,以使至少一个处理器能够执行上述的网关限流方法。Embodiments of the present invention also provide a gateway, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor. The processor executes, so that at least one processor can execute the above-mentioned gateway current limiting method.
本发明的实施方式还提供了一种网关限流系统,包括:数据库和与数据库通信连接的N个上述的网关,其中,N为大于零的自然数。Embodiments of the present invention further provide a gateway current limiting system, including: a database and N above-mentioned gateways communicatively connected to the database, where N is a natural number greater than zero.
本发明的实施方式还提供了一种计算机可读存储介质,存储有计算机程序,计算机程序被处理器执行时实现上述的网关限流方法。Embodiments of the present invention further provide a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the foregoing gateway current limiting method is implemented.
本发明实施方式相对于现有技术而言,提供了一种网关限流方法,通过以预设周期将本地设置的限流插件启动列表,同步更新为数据库中设置的限流插件启动列表;根据更新后的限流插件启动列表,运行需启动的各限流插件进行限流。由于各个网关节点都是以相同的启动插件的列表进行限流的,因此可使各个节点的启动限流插件始终保持一致,而且,以限流插件启动列表的方式指示需要启动的限流插件,灵活度高,无需重启即可实现限流策略的更新和同步,因此提高了限流策略的更新效率。Compared with the prior art, the embodiments of the present invention provide a gateway current limiting method, by synchronously updating the current limiting plug-in activation list set locally to the current limiting plug-in activation list set in the database at a preset period; The updated current-limiting plug-in startup list, run each current-limiting plug-in that needs to be started to limit the current. Since each gateway node uses the same list of startup plugins for current limiting, the startup current limiting plugins of each node can always be consistent, and the current limiting plugins that need to be started are indicated by the current limiting plugin startup list. With high flexibility, the update and synchronization of the current limiting policy can be realized without restarting, thus improving the update efficiency of the current limiting policy.
另外,所述根据所述更新后的限流插件启动列表,运行所述需启动的各限流插件进行限流,具体包括:若所述更新前的限流插件启动列表,相对所述更新后的限流插件启动列表,存在缺失的限流插件,则从所述数据库中获取并启动所述缺失的限流插件;若所述更新前的限流插件启动列表,相对所述更新后的限流插件启动列表,存在多余的限流插件,则停止所述多余的限流插件的运行。使网关服务器的限流插件与数据库中的限流插件启动列表保持一致,实现限流策略的更新。In addition, the running each current-limiting plug-in to be activated to perform current-limiting according to the updated current-limiting plug-in start-up list specifically includes: if the current-limiting plug-in start-up list before the update is compared with the post-update If there is a missing current-limiting plug-in, obtain and start the missing current-limiting plug-in from the database; Stream plugin startup list, if there are redundant current limiting plugins, stop the running of the redundant current limiting plugins. Keep the current-limiting plug-in of the gateway server consistent with the current-limiting plug-in startup list in the database to update the current-limiting policy.
另外,所述限流插件通过以下方式上传至所述数据库中:获取客户端上传的限流插件,所述上传的限流插件包括预先定义的插件启动方法;对所述上传的限流插件进行唯一标识;将经所述唯一标识后的所述限流插件,上传至所述数据库。通过对上传的限流插件进行唯一标识,即使用户在上传限流插件时用了相同的名称,网关服务器也可以进行区分;将唯一标识后的限流插件上传至数据库,数据库也可以根据唯一标识对各个限流插件进行区分,方便后续对限流插件的维护。In addition, the current-limiting plug-in is uploaded to the database in the following manner: obtaining the current-limiting plug-in uploaded by the client, and the uploaded current-limiting plug-in includes a pre-defined plug-in startup method; Unique identification; upload the current limiting plug-in after the unique identification to the database. By uniquely identifying the uploaded current-limiting plug-in, even if the user uploads the current-limiting plug-in with the same name, the gateway server can distinguish it; uploading the uniquely identified current-limiting plug-in to the database, the database can also use the unique identification Distinguish each current-limiting plug-in to facilitate subsequent maintenance of the current-limiting plug-in.
另外,网关限流方法还可以包括:响应于客户端发送的限流插件启动命令,获取所述限流插件启动命令指示的需启动的限流插件的名称;若所述限流插件启动命令指示的需启动的限流插件为所述数据库中存储的限流插件,则将所述限流插件启动命令指示的需启动的限流插件的名称,添加到所述数据库中设置的限流插件启动列表中;响应于客户端发送的限流插件停止命令,获取所述限流插件停止命令指示的需停止的限流插件的名称,并在所述数据库中设置的限流插件启动列表中,删除所述需停止的限流插件的名称。通过客户端发送限流插件的启动或停止命令,可以灵活实施相应的限流策略,提高了限流策略的更新效率。In addition, the gateway current limiting method may further include: in response to a current limiting plug-in start command sent by the client, obtaining the name of the current limiting plug-in to be started indicated by the current limiting plug-in start command; if the current limiting plug-in start command indicates The current-limiting plug-in that needs to be started is the current-limiting plug-in stored in the database, then the name of the current-limiting plug-in that needs to be started indicated by the current-limiting plug-in start command is added to the current-limiting plug-in set in the database to start In the list; in response to the current-limiting plug-in stop command sent by the client, obtain the name of the current-limiting plug-in to be stopped indicated by the current-limiting plug-in stop command, and in the current-limiting plug-in startup list set in the database, delete The name of the current limiting plug-in to be stopped. By sending the start or stop command of the current limiting plug-in from the client, the corresponding current limiting policy can be flexibly implemented, which improves the update efficiency of the current limiting policy.
附图说明Description of drawings
图1是本发明第一实施方式中网关限流方法的一流程示意图;1 is a schematic flowchart of a gateway current limiting method in a first embodiment of the present invention;
图2是本发明第一实施方式中将限流插件上传至数据库的一示例图;2 is an example diagram of uploading a current limiting plug-in to a database in the first embodiment of the present invention;
图3是本发明第二实施方式中网关限流方法的一流程示意图;3 is a schematic flowchart of a gateway current limiting method in a second embodiment of the present invention;
图4是本发明第二实施方式中将缺失的限流插件下载的一示例图;4 is an exemplary diagram of downloading the missing current limiting plug-in in the second embodiment of the present invention;
图5是本发明第二实施方式中将下载的限流插件加载的一示例图;5 is an exemplary diagram of loading the downloaded current limiting plug-in in the second embodiment of the present invention;
图6是本发明第二实施方式中将多余的限流插件停止运行的一示例图;6 is an exemplary diagram of stopping the operation of redundant current limiting plug-ins in the second embodiment of the present invention;
图7是本发明第二实施方式中将下载后的限流插件启动的一示例图;7 is an exemplary diagram of starting the downloaded current limiting plug-in in the second embodiment of the present invention;
图8是本发明第二实施方式中网关服务器的一具体示例图;Fig. 8 is a specific example diagram of the gateway server in the second embodiment of the present invention;
图9是本发明第二实施方式中网关服务器的一架构示意图;9 is a schematic diagram of a structure of a gateway server in a second embodiment of the present invention;
图10是本发明第三实施方式中网关限流方法的一流程示意图;10 is a schematic flowchart of a gateway current limiting method in a third embodiment of the present invention;
图11是本发明第四实施方式中网关限流装置的一原理框图;11 is a schematic block diagram of the gateway current limiting device in the fourth embodiment of the present invention;
图12是本发明第五实施方式中网关的一结构示意图。FIG. 12 is a schematic structural diagram of a gateway in a fifth embodiment of the present invention.
具体实施方式Detailed ways
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合附图对本发明的各实施方式进行详细的阐述。然而,本领域的普通技术人员可以理解,在本发明各实施方式中,为了使读者更好地理解本申请而提出了许多技术细节。但是,即使没有这些技术细节和基于以下各实施方式的种种变化和修改,也可以实现本申请所要求保护的技术方案。以下各个实施例的划分是为了描述方便,不应对本发明的具体实现方式构成任何限定,各个实施例在不矛盾的前提下可以相互结合相互引用。In order to make the objectives, technical solutions and advantages of the embodiments of the present invention clearer, the various embodiments of the present invention will be described in detail below with reference to the accompanying drawings. However, those of ordinary skill in the art can appreciate that, in the various embodiments of the present invention, many technical details are set forth in order for the reader to better understand the present application. However, even without these technical details and various changes and modifications based on the following embodiments, the technical solutions claimed in the present application can be realized. The following divisions of the various embodiments are for the convenience of description, and should not constitute any limitation on the specific implementation of the present invention, and the various embodiments may be combined with each other and referred to each other on the premise of not contradicting each other.
本发明的第一实施方式涉及一种网关限流方法。在本实施方式中,以预设周期将本地设置的限流插件启动列表,同步更新为数据库中设置的限流插件启动列表;其中,限流插件启动列表用于指示需启动的各限流插件,各限流插件分别对应一限流策略;根据更新后的限流插件启动列表,运行需启动的各限流插件进行限流。通过将本地网关节点的限流插件启动列表更新为数据库中的限流插件启动列表,根据更新后的本地的限流插件启动列表运行各限流插件,无需进行系统的重启即可完成限流策略的更新,提高限流策略的更新效率和对各个限流方式的包容性。The first embodiment of the present invention relates to a gateway current limiting method. In this embodiment, the locally set current-limiting plug-in startup list is synchronously updated to the current-limiting plug-in startup list set in the database at a preset period; wherein, the current-limiting plug-in startup list is used to indicate each current-limiting plug-in to be activated. , each current-limiting plug-in corresponds to a current-limiting strategy; according to the updated current-limiting plug-in startup list, run each current-limiting plug-in that needs to be activated to limit the current. By updating the current limiting plugin startup list of the local gateway node to the current limiting plugin startup list in the database, and running each current limiting plugin according to the updated local current limiting plugin startup list, the current limiting strategy can be completed without restarting the system. to improve the update efficiency of the current limiting strategy and the inclusiveness of various current limiting methods.
下面对本实施方式的网关限流方法的实现细节进行具体的说明,以下内容仅为方便理解提供的实现细节,并非实施本方案的必须。The implementation details of the gateway current limiting method in this embodiment will be specifically described below. The following content is only provided for the convenience of understanding, and is not necessary for implementing this solution.
需要说明的是,本发明部分实施方式中的数据库可以为分布式键值对存储数据库,例如Redis,也可以为其它数据库,本发明实施方式对此不做具体限制。It should be noted that the database in some embodiments of the present invention may be a distributed key-value pair storage database, such as Redis, or other databases, which are not specifically limited in the embodiments of the present invention.
本实施方式中的网关限流方法的流程示意图如图1所示,具体包括以下步骤:A schematic flowchart of the gateway current limiting method in this embodiment is shown in FIG. 1 , which specifically includes the following steps:
步骤101:判断是否达到预设时间间隔。Step 101: Determine whether a preset time interval is reached.
需要说明的是,本实施方式的执行主体可以为网关服务器,可选地,网关服务器具体可以为API网关服器,其中,网关服务器代表一个网关节点,各个网关节点与数据库相连接,用于实现对数据库的访问、服务器的访问或其它情况的限流,保证网络和数据库的稳定。It should be noted that the execution body of this embodiment may be a gateway server, and optionally, the gateway server may specifically be an API gateway server, wherein the gateway server represents a gateway node, and each gateway node is connected to a database for implementing Access to the database, server access or other current restrictions to ensure the stability of the network and database.
其中,预设时间间隔可以根据实际需要进行设置,本实施方式对此不做具体限制。The preset time interval may be set according to actual needs, which is not specifically limited in this embodiment.
具体地,网关服务器可以根据设置的计时器进行判断,若时间到达预设的时间间隔,则进入步骤102,否则继续执行步骤101,直到时间到达预设的时间间隔。Specifically, the gateway server can judge according to the set timer, if the time reaches the preset time interval, then go to step 102, otherwise, continue to execute step 101 until the time reaches the preset time interval.
步骤102:将本地设置的限流插件启动列表,同步更新为数据库中设置的限流插件启动列表。Step 102: Synchronously update the current limiting plug-in activation list set locally to the current limiting plug-in activation list set in the database.
其中,限流插件是指用于对数据库的访问、服务器的访问或其它情况进行限流的插件,本实施方式对此不做具体限制。一个限流插件对应一种限流策略,限流策略包括令牌桶、漏桶、计数器等方式;限流插件启动列表用于指示各网关节点需要启动的限流插件,本地设置的限流插件启动列表是指设置于各网关节点的限流插件启动列表。The current-limiting plug-in refers to a plug-in used to limit current for database access, server access, or other conditions, which is not specifically limited in this embodiment. A current-limiting plug-in corresponds to a current-limiting policy. The current-limiting policy includes token buckets, leaky buckets, counters, etc. The current-limiting plug-in startup list is used to indicate the current-limiting plug-ins that each gateway node needs to start, and the current-limiting plug-ins set locally. The startup list refers to the startup list of the current limiting plug-in set on each gateway node.
可选地,数据库中设置的限流插件启动列表由用户(例如网关管理员)根据限流策略进行定期维护。Optionally, the current limiting plug-in startup list set in the database is regularly maintained by a user (eg, a gateway administrator) according to a current limiting policy.
可选地,网关服务器将数据库中的限流插件启动列表下载后,将下载的限流插件启动列表对本地网关节点的限流插件启动列表进行替换,完成本地网关节点的限流插件启动列表的更新。Optionally, after the gateway server downloads the current-limiting plug-in startup list in the database, it replaces the downloaded current-limiting plug-in startup list with the current-limiting plug-in startup list of the local gateway node, and completes the current-limiting plug-in startup list of the local gateway node. renew.
步骤103:根据更新后的限流插件启动列表,运行需启动的各限流插件进行限流。Step 103: According to the updated current-limiting plug-in startup list, run each current-limiting plug-in to be activated to limit the current.
可选地,网关服务器根据更新后的限流插件启动列表获取每一个需要启动的限流插件的名称,再根据限流插件的名称一一运行各个限流插件,实施数据库的限流策略。其中,各个限流插件可以由网关服务器从一指定的位置下载得到,并存储于网关服务器中,网关服务器可根据限流插件的名称获取并运行限流插件。Optionally, the gateway server obtains the name of each current-limiting plug-in to be activated according to the updated current-limiting plug-in startup list, and then runs each current-limiting plug-in one by one according to the name of the current-limiting plug-in to implement the current-limiting policy of the database. Wherein, each current limiting plug-in can be downloaded from a designated location by the gateway server and stored in the gateway server, and the gateway server can obtain and run the current limiting plug-in according to the name of the current limiting plug-in.
当步骤103执行完之后,返回执行步骤101,即重新判断是否达到预设时间间隔,进入下一个循环。After the execution of step 103 is completed, the process returns to step 101, that is, it is re-determined whether the preset time interval is reached, and the next cycle is entered.
与现有技术相比,本实施方式通过判断是否达到预设时间间隔,若是则将本地设置的限流插件启动列表更新为数据库中设置的限流插件启动列表,根据更新后的限流插件启动列表运行需要启动的限制插件进行限流。本实施方式实现了可热插拔式的插件方式,由于各个网关节点都是以相同的启动插件的列表进行限流的,因此可使各个节点的启动限流插件始终保持一致,而且,以限流插件启动列表的方式指示需要启动的限流插件,灵活度高,无需重启即可实现限流策略的更新和同步,因此提高了限流策略的更新效率,同时也提高了对各个限流方式的包容性。Compared with the prior art, the present embodiment determines whether the preset time interval is reached, and if so, updates the locally set current-limiting plug-in startup list to the current-limiting plug-in startup list set in the database, and starts the current-limiting plug-in according to the updated current-limiting plug-in startup list. List the limit plug-ins that need to be started to limit the flow. This embodiment implements a hot-swappable plug-in mode. Since each gateway node uses the same list of startup plug-ins to limit the current, the startup current-limiting plug-ins of each node can always be consistent. The method of the flow plugin startup list indicates the current limiting plugins that need to be started, which is highly flexible and can update and synchronize the current limiting policy without restarting, thus improving the update efficiency of the current limiting policy and improving the efficiency of each current limiting method. inclusiveness.
在一个具体的例子中,限流插件可以通过以下步骤上传至数据库中:In a specific example, the current limiting plug-in can be uploaded to the database through the following steps:
步骤201:获取客户端上传的限流插件,上传的限流插件包括预先定义的插件启动方法。Step 201: Obtain the current limiting plug-in uploaded by the client, where the uploaded current limiting plug-in includes a predefined plug-in startup method.
步骤202:对上传的限流插件进行唯一标识。Step 202: Uniquely identify the uploaded current limiting plug-in.
步骤203:将经唯一标识后的限流插件,上传至数据库。Step 203: Upload the uniquely identified current limiting plug-in to the database.
请参考图2,其为将限流插件上传至数据库的示例图。Please refer to FIG. 2 , which is an example diagram of uploading the current limiting plug-in to the database.
其中,客户端是指与网关服务器连接的客户端,例如可以是浏览器、APP或其它应用程序;预先定义的插件启动方式可以根据实际需要进行设置,例如以stark方式启动插件,且预先定义的插件启动方式可以设置为相同的方式,也可以为不同的限流插件有不同的启动方式,本实施方式对此不做限制。Among them, the client refers to the client connected to the gateway server, such as a browser, APP or other applications; the pre-defined plugin startup mode can be set according to actual needs, for example, start the plugin in the stark mode, and the pre-defined plugin startup method The plug-in startup modes may be set to the same mode, or different current-limiting plug-ins may have different activation modes, which are not limited in this embodiment.
其中,唯一标识是指对各个限流插件进行不同的标识,使各个限流插件分别对应一个标识。可选地,可以为上传的限流插件设置时间戳,由于时间戳是随时间变化而不同,因此可以用时间戳对限流插件进行唯一标识。用时间戳对上传的限流插件进行唯一标识,即使用户在上传限流插件时使用了相同的名称,网关服务器也可以根据时间戳进行区分。可选地,也可以使用其它标识对限流插件进行唯一标识,例如,可以用流水号对限流插件进行标识,本实施方式对此不做具体限制。The unique identification refers to different identifications for each current limiting plug-in, so that each current limiting plug-in corresponds to an identification. Optionally, a timestamp can be set for the uploaded current limiting plug-in. Since the timestamp varies with time, the current limiting plug-in can be uniquely identified by the timestamp. The uploaded current-limiting plug-in is uniquely identified with a timestamp. Even if the user uploads the current-limiting plug-in with the same name, the gateway server can distinguish it according to the timestamp. Optionally, other identifiers may also be used to uniquely identify the current limiting plug-in, for example, the current limiting plug-in may be identified by a serial number, which is not specifically limited in this embodiment.
可选地,客户端将限流插件上传至网关服务器时,是通过post接口上传。Optionally, when the client uploads the current limiting plug-in to the gateway server, it is uploaded through the post interface.
将客户端上传的限流插件进行唯一标识后,网关服务器将唯一标识好的限流插件上传至数据库。After uniquely identifying the current limiting plug-in uploaded by the client, the gateway server uploads the uniquely identified current limiting plug-in to the database.
可以理解的是,由于用户在客户端是通过某一网关服务器的节点进行上传限流插件,因此其它网关节点并未存储上传的限流插件,其它网关节点还需要从数据库中下载上传的限流插件才能加载运行。It is understandable that, since the user uploads the current limiting plug-in on the client through a node of a gateway server, other gateway nodes do not store the uploaded current limiting plug-in, and other gateway nodes also need to download the uploaded current limiting plug-in from the database. The plugin can be loaded and run.
通过对上传的限流插件进行唯一标识,即使用户在上传限流插件时用了相同的名称,网关服务器也可以进行区分;将唯一标识后的限流插件上传至数据库,数据库也可以根据唯一标识对各个限流插件进行区分,方便后续对限流插件的维护。同时,通过将限流插件进行唯一化,可以让数据库中维护的限流插件启动列表可以在限流插件更新不同版本后,即使不更新限流插件名称的情况下进行有变动的更新,各个网关节点也就可以根据限流插件启动列表删除旧版本限流插件并加载新版本的限流插件。By uniquely identifying the uploaded current-limiting plug-in, even if the user uploads the current-limiting plug-in with the same name, the gateway server can distinguish it; uploading the uniquely identified current-limiting plug-in to the database, the database can also use the unique identification Distinguish each current-limiting plug-in to facilitate subsequent maintenance of the current-limiting plug-in. At the same time, by making the current-limiting plug-in unique, the current-limiting plug-in startup list maintained in the database can be updated after the current-limiting plug-in is updated to different versions, even if the name of the current-limiting plug-in is not updated. The node can also delete the old version of the current limit plug-in and load the new version of the current limit plug-in according to the current limit plug-in startup list.
本发明的第二实施方式涉及一种网关限流方法,如图3所示,第二实施方式与第一实施方式大致相同,主要区别之处在于在步骤103中,即根据更新后的限流插件启动列表,运行需启动的各限流插件进行限流,具体可以包括以下步骤:The second embodiment of the present invention relates to a gateway current limiting method. As shown in FIG. 3 , the second embodiment is roughly the same as the first embodiment, and the main difference is that in step 103, according to the updated current limiting method Plug-in startup list, run each current-limiting plug-in to be started to limit current, which can include the following steps:
步骤1031:判断更新前的限流插件启动列表是否相对更新后的限流插件启动列表,存在缺失的限流插件。若存在缺失的限流插件,则进入步骤1032;若不存在缺失的限流插件,则进入步骤1033。Step 1031: Determine whether the current-limiting plug-in activation list before the update is relative to the updated current-limiting plug-in activation list, and there is a missing current-limiting plug-in. If there is a missing current limiting plug-in, go to step 1032 ; if there is no missing current limiting plug-in, go to step 1033 .
步骤1032:从数据库中获取并启动缺失的限流插件。Step 1032: Acquire and start the missing current limiting plug-in from the database.
步骤1033:判断更新前的限流插件启动列表是否相对更新后的限流插件启动列表,存在多余的限流插件。若存在多余的限流插件,则进入步骤1034;若不存在多余的限流插件,则返回步骤101。Step 1033: Determine whether the current-limiting plug-in activation list before the update is compared with the updated current-limiting plug-in activation list, and there are redundant current-limiting plug-ins. If there are redundant current limiting plug-ins, go to step 1034; if there are no redundant current limiting plug-ins, go back to step 101.
步骤1034:停止多余的限流插件的运行。Step 1034: Stop the operation of redundant current limiting plug-ins.
可选地,网关服务器将自身的限流插件启动列表与数据库中的限流插件启动列表进行比较,若数据库中的限流插件启动列表中某个限流插件在网关服务器的限流插件启动列表中没有,则网关服务器判定存在该限流插件为缺失的限流插件,网关服务器从数据库中下载该缺失的限流插件并加载运行。可选地,在网关服务器中保存有更新前和更新后的限流插件启动列表,网关服务器将更新前后的限流插件启动列表进行比较后,可以得到缺失的限流插件。Optionally, the gateway server compares its own current-limiting plugin startup list with the current-limiting plugin startup list in the database. If a current-limiting plugin in the current-limiting plugin startup list in the database is in the gateway server's current-limiting plugin startup list If there is no current limiting plug-in, the gateway server determines that the current limiting plug-in is a missing current limiting plug-in, and the gateway server downloads the missing current limiting plug-in from the database and loads and runs it. Optionally, the gateway server stores the current limiting plug-in startup lists before and after the update, and the gateway server can obtain the missing current limiting plug-in after comparing the current limiting plug-in startup lists before and after the update.
请参考图4,其为将缺失的限流插件下载至网关服务器的示例图。具体地,网关服务器根据数据库中的限流插件启动列表获取缺失的限流插件的名称,再根据缺失的限流插件的名称在数据库中找到相应的限流插件,下载后存储至网关服务器指定的目录中,例如src/Plugins/otherPlugins/目录中。Please refer to FIG. 4 , which is an example diagram of downloading the missing current limiting plug-in to the gateway server. Specifically, the gateway server obtains the name of the missing current-limiting plug-in according to the current-limiting plug-in startup list in the database, and then finds the corresponding current-limiting plug-in in the database according to the name of the missing current-limiting plug-in, and stores it in the database specified by the gateway server after downloading. directory, such as the src/Plugins/otherPlugins/ directory.
请参考图5,其为将下载的限流插件加载的示例图。具体地,网关服务器获取待加载的限流插件名称(下载好的缺失的限流插件),根据待加载的限流插件名称的指定的路径(下载时指定的目录)加载限流插件。Please refer to FIG. 5 , which is an example diagram of loading the downloaded current limiting plug-in. Specifically, the gateway server obtains the name of the current limiting plug-in to be loaded (the downloaded missing current limiting plug-in), and loads the current limiting plug-in according to the path specified by the name of the current limiting plug-in to be loaded (the directory specified when downloading).
在步骤1031中,若更新前的限流插件启动列表相对于更新后的限流插件启动列表没有变化,则网关服务器判定没有缺少的限流插件,进入步骤1033,判断更新前的限流插件启动列表是否相对更新后的限流插件启动列表存在多余的限流插件。In step 1031, if the current-limiting plug-in activation list before the update is unchanged from the updated current-limiting plug-in activation list, the gateway server determines that there is no missing current-limiting plug-in, and proceeds to step 1033 to determine that the current-limiting plug-in before the update is activated Whether there are redundant current-limiting plug-ins in the list relative to the updated current-limiting plug-in startup list.
具体地,网关服务器将自身的限流插件启动列表与数据库中的限流插件启动列表进行比较,若自身的限流插件启动列表中存在某个限流插件在数据库中的限流插件启动列表中没有,则网关服务器判定该限流插件为多余的限流插件,网关服务器将该多余的限流插件停止运行。Specifically, the gateway server compares its own current-limiting plugin startup list with the current-limiting plugin startup list in the database. If there is a current-limiting plugin in its own current-limiting plugin startup list, it is in the current-limiting plugin startup list in the database. If not, the gateway server determines that the current limiting plug-in is a redundant current limiting plug-in, and the gateway server stops running the redundant current limiting plug-in.
请参考图6,其为将多余的限流插件停止运行的示例图。具体地,网关服务器根据自身的限流插件启动列表获取多余的限流插件的名称,再根据该多余的限流插件的名称遍历网关服务器的路由栈表,若路由栈表中存在与该多余的限流插件的名称匹配的项,则将该匹配的项进行删除。Please refer to FIG. 6 , which is an example diagram of stopping the operation of redundant current limiting plug-ins. Specifically, the gateway server obtains the names of redundant current-limiting plug-ins according to its own current-limiting plug-in startup list, and then traverses the routing stack table of the gateway server according to the names of the redundant current-limiting plug-ins. If the name of the current limiting plug-in matches, the matching item will be deleted.
在步骤1033中,若更新前的限流启动列表相对于更新后的限流插件启动列表没有多余的限流插件,则返回步骤101,进入下一次循环。在步骤1034执行完之后,也返回步骤101。In step 1033, if the current-limiting activation list before the update has no redundant current-limiting plug-ins relative to the updated current-limiting plug-in activation list, the process returns to step 101, and the next cycle is entered. After the execution of step 1034 is completed, step 101 is also returned.
与现有技术相比,本实施方式通过比较网关服务器更新前后的限流插件启动列表,若存在缺失的限流插件,则从数据库中下载并运行;若存在多余的限流插件,则停止运行多余的限流插件,使网关服务器的限流插件与数据库中的限流插件启动列表保持一致,实现限流策略的更新。Compared with the prior art, this embodiment compares the current-limiting plug-in startup list before and after the gateway server is updated. If there is a missing current-limiting plug-in, download and run it from the database; if there are redundant current-limiting plug-ins, stop running. The redundant current-limiting plug-ins keep the current-limiting plug-ins of the gateway server consistent with the current-limiting plug-in startup list in the database, so as to update the current-limiting policy.
在一个例子中,步骤1032,即从数据库中获取并启动缺失的限流插件,具体可以包括以下步骤:In one example, step 1032, that is, acquiring and starting the missing current limiting plug-in from the database, may specifically include the following steps:
步骤301:从数据库中下载缺失的限流插件。Step 301: Download the missing current limiting plug-in from the database.
步骤302:对缺失的限流插件进行名称变化,得到缺失的限流插件的启动名称。Step 302: Change the name of the missing current limiting plug-in to obtain the startup name of the missing current limiting plug-in.
步骤303:以缺失的限流插件的插件启动方法进行启动。Step 303: Start with the plug-in start-up method of the missing current-limiting plug-in.
步骤304:调整缺失的限流插件的启动进程在路由栈中的位置。Step 304: Adjust the position of the missing current limiting plug-in's startup process in the routing stack.
请参考图7,其为将下载后的限流插件启动的示例图。具体地,网关服务器根据缺失的限流插件的名称进行名称变化后得到缺失的限流插件的启动名称,再根据缺失的限流插件的插件启动方法进行启动,例如,通过app.use调用该插件的start方法以启动限流插件,并将该缺失的限流插件的启动进程在路由栈中的位置调整至可执行处。可以理解的是,由于系统进程执行过程中执由路由栈的顺序性,通过将缺失的限流插件的启动进程调整至可执行的位置,可以保证限流策略得到及时的实施,从而保证了网络和数据库的稳定。Please refer to FIG. 7 , which is an example diagram of starting the downloaded current limiting plug-in. Specifically, the gateway server obtains the start-up name of the missing current-limiting plug-in after changing the name according to the name of the missing current-limiting plug-in, and then starts according to the plug-in startup method of the missing current-limiting plug-in, for example, calling the plug-in through app.use The start method is used to start the current-limiting plug-in, and adjust the position of the missing current-limiting plug-in's startup process in the routing stack to the executable position. It can be understood that due to the sequential nature of the routing stack during the execution of the system process, by adjusting the startup process of the missing current limiting plug-in to an executable position, the current limiting policy can be implemented in time, thereby ensuring the network and database stability.
在一个例子中,请参考图8,其为网关服务器的一具体示例图。In an example, please refer to FIG. 8 , which is a specific example diagram of the gateway server.
其中,上传下载模块中的上传子模块,用于上传自定义的限流插件至网关服务器,网关服务器再将其上传至数据库;Among them, the upload sub-module in the upload and download module is used to upload the customized current limiting plug-in to the gateway server, and the gateway server uploads it to the database;
下载子模块,用于从数据库中下载限流插件;The download submodule is used to download the current limiting plug-in from the database;
限流插件启动模块中的启动子模块的触发单元,用于触发启动执行单元;The trigger unit of the promoter sub-module in the current-limiting plug-in startup module is used to trigger the startup execution unit;
启动执行单元,用于将加载的限流插件运行;Start the execution unit to run the loaded current limiting plug-in;
限流插件启动模块中的停止子模块的触发单元,用于触发停止执行单元;The trigger unit of the stop sub-module in the current-limiting plug-in startup module is used to trigger the stop execution unit;
停止执行单元,用于根据待停止的限流插件名称进行停止限流插件的操作;The stop execution unit is used to stop the current-limiting plug-in according to the name of the current-limiting plug-in to be stopped;
同步模块中的计时子模块,用于通过配置的预设周期定时执行同步操作;The timing sub-module in the synchronization module is used to perform the synchronization operation regularly through the configured preset period;
同步子模块,用于同步各个网关节点上运行的限流插件启动列表。The synchronization submodule is used to synchronize the startup list of current limiting plug-ins running on each gateway node.
请参考图9,其为网关服务器的一架构示意图,具体地,图中以Redis数据库为例,ApiGateway代表各网关节点,Client代表客户端;客户端通过网关服务器上传自定义的限流插件至Redis数据库,并根据限流策略更新数据库中的限流插件启动列表,各网关服务器根据预设周期检查本地的限流插件启动列表是否与Redis数据库中的限流插件启动列表是否一致,根据Redis数据库中的限流插件启动列表启动或停止某个限流插件。Please refer to FIG. 9 , which is a schematic diagram of the architecture of the gateway server. Specifically, the Redis database is taken as an example in the figure. ApiGateway represents each gateway node, and Client represents the client; the client uploads a customized current limiting plug-in to Redis through the gateway server. database, and update the current-limiting plugin startup list in the database according to the current-limiting policy. Each gateway server checks whether the local current-limiting plugin startup list is consistent with the current-limiting plugin startup list in the Redis database according to the preset period. The throttling plugin startup list starts or stops a throttling plugin.
本发明的第三实施方式涉及一种网关限流方法,本实施方式的流程图如图10所示,具体包括以下步骤:The third embodiment of the present invention relates to a gateway current limiting method. The flowchart of this embodiment is shown in FIG. 10 , and specifically includes the following steps:
步骤401:判断是否接收到客户端发送的限流插件启动命令,若接收到限流插件启动命令,则进入步骤402;若未接收到限流插件启动命令,则进入步骤405。Step 401: Determine whether a current limiting plug-in activation command sent by the client is received, if the current limiting plug-in activation command is received, proceed to step 402; if the current limiting plug-in activation command is not received, proceed to step 405.
步骤402:获取限流插件启动命令指示的需启动的限流插件的名称。Step 402: Obtain the name of the current-limiting plug-in to be started indicated by the current-limiting plug-in start command.
步骤403:判断限流插件启动命令指示的需启动的限流插件是否为数据库中存储的限流插件,若需启动的限流插件为数据库中存储的限流插件,则进入步骤404,若需启动的限流插件不是数据库存储的限流插件,则返回错误信息。Step 403: Determine whether the current-limiting plug-in to be activated indicated by the current-limiting plug-in activation command is a current-limiting plug-in stored in the database, if the current-limiting plug-in to be activated is a current-limiting plug-in stored in the database, then enter step 404, if necessary If the activated current limiting plug-in is not the current limiting plug-in stored in the database, an error message is returned.
步骤404:将限流插件启动命令指示的需启动的限流插件的名称,添加到数据库中设置的限流插件启动列表中。Step 404: Add the name of the current-limiting plug-in to be activated indicated by the current-limiting plug-in activation command to the current-limiting plug-in activation list set in the database.
步骤405:判断是否接收到客户端发送的限流插件停止命令,若接收到限流插件停止命令,则进入步骤406;若未接收到限流插件停止命令,则结束步骤流程。Step 405: Determine whether the current limiting plug-in stop command sent by the client is received. If the current limiting plug-in stop command is received, go to step 406; if the current limiting plug-in stop command is not received, the step flow ends.
步骤406:获取限流插件停止命令指示的需停止的限流插件的名称,并在数据库中设置的限流插件启动列表中,删除需停止的限流插件的名称。Step 406: Obtain the name of the current limiting plug-in to be stopped indicated by the current limiting plug-in stop command, and delete the name of the current limiting plug-in to be stopped in the current limiting plug-in startup list set in the database.
具体地,网关服务器可以接收客户端发过来的限流插件的相关命令,例如,网关管理员根据限流策略的改变通过客户端向网关服务器发送限流插件启动命令。在步骤401中,若判定没有接收到客户端发送的限流插件启动命令,则进入步骤405。Specifically, the gateway server may receive commands related to the current limiting plug-in sent by the client. For example, the gateway administrator sends a current limiting plug-in activation command to the gateway server through the client according to the change of the current limiting policy. In step 401 , if it is determined that the current limiting plug-in start command sent by the client is not received, step 405 is entered.
当网关服务器接收到客户端发送的限流插件启动命令时,根据限流插件启动命令获取需启动的限流插件的名称;网关服务器与数据库进行通信,判断限流插件启动命令需要启动的限流插件是否为数据库存储的限流插件,若是,则将该需启动的限流插件的名称添加到数据库中设置的限流插件启动列表中,使数据库中的限流插件启动列表进行了更新,以使后续网关节点将本地设置的限流插件启动列表与数据库中更新了的限流插件启动列表进行比较,从而在网关节点上添加限流插件启动命令指示的需启动的限流插件;若否,则返回错误信息,使用户通过客户端上传限流插件启动命令对应的限流插件后再进行后续的操作。When the gateway server receives the current-limiting plug-in start command sent by the client, it obtains the name of the current-limiting plug-in to be started according to the current-limiting plug-in start command; the gateway server communicates with the database to determine the current-limiting plug-in that needs to be started by the current-limiting plug-in start command. Whether the plug-in is a current-limiting plug-in stored in the database, if so, add the name of the current-limiting plug-in to be started to the current-limiting plug-in startup list set in the database, so that the current-limiting plug-in startup list in the database is updated to Make subsequent gateway nodes compare the locally set current-limiting plugin startup list with the updated current-limiting plugin startup list in the database, so as to add the current-limiting plugin to be started indicated by the current-limiting plugin startup command on the gateway node; if not, Then an error message is returned, so that the user can upload the current limiting plug-in corresponding to the current limiting plug-in start command through the client and then perform subsequent operations.
当接收到客户端发送的限流插件停止命令时,网关服务器根据限流插件停止命令获取需要停止的限流插件的名称,并在数据库中设置的限流插件启动列表中,删除需要停止的限流插件的名称,使数据库中的限流插件启动列表更新,以使网关节点根据数据库中的限流插件启动列表停止与限流插件停止命令对应的限流插件。When receiving the current-limiting plug-in stop command sent by the client, the gateway server obtains the name of the current-limiting plug-in that needs to be stopped according to the current-limiting plug-in stop command, and deletes the current-limiting plug-in start list set in the database. The name of the flow plug-in, so that the current limit plug-in start list in the database is updated, so that the gateway node stops the flow limit plug-in corresponding to the flow limit plug-in stop command according to the flow limit plug-in start list in the database.
与现有技术相比,本实施方式通过网关服务器接收客户端发送的限流插件启动命令,将限流插件启动命令对应的限流插件名称添加到数据库中的限流插件启动列表中;通过接收客户端发送的限流插件停止命令,将限流插件停止命令对应的限流插件名称从数据库中的限流插件启动列表中删除,实现了数据库中的限流插件启动列表的更新。通过客户端发送限流插件的启动或停止命令,可以灵活实施相应的限流策略,提高了限流策略的更新效率。Compared with the prior art, this embodiment receives the current-limiting plug-in start command sent by the client through the gateway server, and adds the current-limiting plug-in name corresponding to the current-limiting plug-in start command to the current-limiting plug-in start list in the database; The current-limiting plug-in stop command sent by the client deletes the current-limiting plug-in name corresponding to the current-limiting plug-in stop command from the current-limiting plug-in startup list in the database, thereby realizing the update of the current-limiting plug-in startup list in the database. By sending the start or stop command of the current limiting plug-in from the client, the corresponding current limiting policy can be flexibly implemented, which improves the update efficiency of the current limiting policy.
上面各种方法的步骤划分,只是为了描述清楚,实现时可以合并为一个步骤或者对某些步骤进行拆分,分解为多个步骤,只要包括相同的逻辑关系,都在本专利的保护范围内;对算法中或者流程中添加无关紧要的修改或者引入无关紧要的设计,但不改变其算法和流程的核心设计都在该专利的保护范围内。The steps of the above various methods are divided only for the purpose of describing clearly. During implementation, they can be combined into one step or some steps can be split and decomposed into multiple steps. As long as the same logical relationship is included, they are all within the protection scope of this patent. ;Adding insignificant modifications to the algorithm or process or introducing insignificant designs, but not changing the core design of the algorithm and process are all within the scope of protection of this patent.
本发明第四实施方式涉及一种网关限流装置,如图11所示,包括:The fourth embodiment of the present invention relates to a gateway current limiting device, as shown in FIG. 11 , including:
启动列表维护模块501,用于以预设周期将本地设置的限流插件启动列表,同步更新为数据库中设置的限流插件启动列表;其中,限流插件启动列表用于指示需启动的各限流插件,各限流插件分别对应一限流策略;The startup list maintenance module 501 is configured to synchronously update the locally set current-limiting plug-in startup list with a preset cycle to the current-limiting plugin startup list set in the database; wherein, the current-limiting plugin startup list is used to indicate each limit to be activated. Streaming plug-ins, each current-limiting plug-in corresponds to a current-limiting policy;
限流模块502,用于根据更新后的限流插件启动列表,运行需启动的各限流插件进行限流。The current limiting module 502 is configured to run each current limiting plug-in to be activated to perform current limiting according to the updated current limiting plug-in activation list.
可选地,限流模块502还用于:Optionally, the current limiting module 502 is also used for:
若更新前的限流插件启动列表,相对更新后的限流插件启动列表,存在缺失的限流插件,则从数据库中获取并启动缺失的限流插件;If there is a missing current-limiting plug-in in the current-limiting plug-in startup list before the update relative to the updated current-limiting plug-in startup list, the missing current-limiting plug-in is obtained from the database and started;
若更新前的限流插件启动列表,相对更新后的限流插件启动列表,存在多余的限流插件,则停止多余的限流插件的运行。If there are redundant current-limiting plug-ins in the current-limiting plug-in startup list before the update relative to the updated current-limiting plug-in start-up list, the operation of the redundant current-limiting plug-ins is stopped.
可选地,限流插件可通过以下方式上传至数据库中:Optionally, the current limiting plug-in can be uploaded to the database in the following ways:
获取客户端上传的限流插件,上传的限流插件包括预先定义的插件启动方法;Obtain the current limiting plug-in uploaded by the client, and the uploaded current limiting plug-in includes the pre-defined plug-in startup method;
对上传的限流插件进行唯一标识;Uniquely identify the uploaded current limiting plug-in;
将经唯一标识后的限流插件,上传至数据库。Upload the uniquely identified current limiting plug-in to the database.
可选地,可以为上传的限流插件设置时间戳。Optionally, a timestamp can be set for the uploaded throttling plugin.
可选地,从数据库中获取并启动缺失的限流插件,具体包括:Optionally, obtain and start the missing current limiting plug-in from the database, including:
从数据库中下载缺失的限流插件;Download missing throttling plugins from the database;
对缺失的限流插件进行名称变化,得到缺失的限流插件的启动名称;Change the name of the missing current limiting plug-in to get the startup name of the missing current limiting plug-in;
以缺失的限流插件的插件启动方法进行启动;Start with the plugin startup method of the missing current limiting plugin;
调整缺失的限流插件的启动进程在路由栈中的位置。Adjust the position of the missing current limiting plugin's startup process in the routing stack.
可选地,本实施方式的网关限流装置还用于:Optionally, the gateway current limiting device in this embodiment is also used for:
响应于客户端发送的限流插件启动命令,获取限流插件启动命令指示的需启动的限流插件的名称;In response to the current-limiting plug-in start command sent by the client, obtain the name of the current-limiting plug-in to be started indicated by the current-limiting plug-in start command;
若限流插件启动命令指示的需启动的限流插件为数据库中存储的限流插件,则将限流插件启动命令指示的需启动的限流插件的名称,添加到数据库中设置的限流插件启动列表中;If the current-limiting plug-in to be started indicated by the current-limiting plug-in start command is the current-limiting plug-in stored in the database, the name of the current-limiting plug-in to be started indicated by the current-limiting plug-in start-up command is added to the current-limiting plug-in set in the database. start list;
响应于客户端发送的限流插件停止命令,获取限流插件停止命令指示的需停止的限流插件的名称,并在数据库中设置的限流插件启动列表中,删除需停止的限流插件的名称。In response to the current-limiting plug-in stop command sent by the client, obtain the name of the current-limiting plug-in to be stopped indicated by the current-limiting plug-in stop command, and delete the current-limiting plug-in to be stopped in the current-limiting plug-in startup list set in the database. name.
可选地,数据库具体为分布式键值对存储数据库。Optionally, the database is specifically a distributed key-value pair storage database.
不难发现,本实施方式为与第一实施方式相对应的系统实施例,本实施方式可与第一实施方式互相配合实施。第一实施方式中提到的相关技术细节在本实施方式中依然有效,为了减少重复,这里不再赘述。相应地,本实施方式中提到的相关技术细节也可应用在第一实施方式中。It is not difficult to find that this embodiment is a system example corresponding to the first embodiment, and this embodiment can be implemented in cooperation with the first embodiment. The relevant technical details mentioned in the first embodiment are still valid in this embodiment, and are not repeated here in order to reduce repetition. Correspondingly, the related technical details mentioned in this embodiment can also be applied to the first embodiment.
值得一提的是,本实施方式中所涉及到的各模块均为逻辑模块,在实际应用中,一个逻辑单元可以是一个物理单元,也可以是一个物理单元的一部分,还可以以多个物理单元的组合实现。此外,为了突出本发明的创新部分,本实施方式中并没有将与解决本发明所提出的技术问题关系不太密切的单元引入,但这并不表明本实施方式中不存在其它的单元。It is worth mentioning that each module involved in this embodiment is a logical module. In practical applications, a logical unit may be a physical unit, a part of a physical unit, or multiple physical units. A composite implementation of the unit. In addition, in order to highlight the innovative part of the present invention, this embodiment does not introduce units that are not closely related to solving the technical problem proposed by the present invention, but this does not mean that there are no other units in this embodiment.
本发明第五实施方式涉及一种网络设备,如图12所示,包括至少一个处理器601;以及,与至少一个处理器601通信连接的存储器602;其中,存储器602存储有可被至少一个处理器601执行的指令,指令被至少一个处理器601执行,以使至少一个处理器601能够执行上述的网关限流方法。The fifth embodiment of the present invention relates to a network device, as shown in FIG. 12 , comprising at least one processor 601; and a memory 602 communicatively connected with the at least one processor 601; wherein, the memory 602 stores data that can be processed by the at least one processor 601. The instructions are executed by the processor 601, and the instructions are executed by the at least one processor 601, so that the at least one processor 601 can execute the above-mentioned gateway current limiting method.
其中,存储器602和处理器601采用总线方式连接,总线可以包括任意数量的互联的总线和桥,总线将一个或多个处理器601和存储器602的各种电路连接在一起。总线还可以将诸如外围设备、稳压器和功率管理电路等之类的各种其他电路连接在一起,这些都是本领域所公知的,因此,本文不再对其进行进一步描述。总线接口在总线和收发机之间提供接口。收发机可以是一个元件,也可以是多个元件,比如多个接收器和发送器,提供用于在传输介质上与各种其他装置通信的单元。经处理器601处理的数据通过天线在无线介质上进行传输,进一步,天线还接收数据并将数据传送给处理器601。The memory 602 and the processor 601 are connected by a bus, and the bus may include any number of interconnected buses and bridges, and the bus connects one or more processors 601 and various circuits of the memory 602 together. The bus may also connect together various other circuits, such as peripherals, voltage regulators, and power management circuits, which are well known in the art and therefore will not be described further herein. The bus interface provides the interface between the bus and the transceiver. A transceiver may be a single element or multiple elements, such as multiple receivers and transmitters, providing a means for communicating with various other devices over a transmission medium. The data processed by the processor 601 is transmitted on the wireless medium through the antenna, and further, the antenna also receives the data and transmits the data to the processor 601 .
处理器601负责管理总线和通常的处理,还可以提供各种功能,包括定时,外围接口,电压调节、电源管理以及其他控制功能。而存储器602可以被用于存储处理器601在执行操作时所使用的数据。Processor 601 is responsible for managing the bus and general processing, and may also provide various functions, including timing, peripheral interface, voltage regulation, power management, and other control functions. The memory 602 may be used to store data used by the processor 601 when performing operations.
本发明第六实施方式涉及一种网关限流系统,包括数据库和与数据库通信连接的N个如第五实施方式中的网关,其中,N为大于零的自然数。The sixth embodiment of the present invention relates to a gateway current limiting system, including a database and N gateways in communication and connection with the database as in the fifth embodiment, wherein N is a natural number greater than zero.
本发明第七实施方式涉及一种计算机可读存储介质,存储有计算机程序。计算机程序被处理器执行时实现上述方法实施例。A seventh embodiment of the present invention relates to a computer-readable storage medium storing a computer program. The above method embodiments are implemented when the computer program is executed by the processor.
即,本领域技术人员可以理解,实现上述实施例方法中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,该程序存储在一个存储介质中,包括若干指令用以使得一个设备(可以是单片机,芯片等)或处理器(processor)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-OnlyMemory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。That is, those skilled in the art can understand that all or part of the steps in the method for implementing the above embodiments can be completed by instructing the relevant hardware through a program, and the program is stored in a storage medium and includes several instructions to make a device ( It may be a single chip microcomputer, a chip, etc.) or a processor (processor) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: U disk, removable 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.
本领域的普通技术人员可以理解,上述各实施方式是实现本发明的具体实施例,而在实际应用中,可以在形式上和细节上对其作各种改变,而不偏离本发明的精神和范围。Those skilled in the art can understand that the above-mentioned embodiments are specific examples for realizing the present invention, and in practical applications, various changes in form and details can be made without departing from the spirit and the spirit of the present invention. scope.
Claims (11)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910613993.2A CN110535776B (en) | 2019-07-09 | 2019-07-09 | Gateway current limiting method, device, gateway, system and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910613993.2A CN110535776B (en) | 2019-07-09 | 2019-07-09 | Gateway current limiting method, device, gateway, system and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110535776A true CN110535776A (en) | 2019-12-03 |
CN110535776B CN110535776B (en) | 2022-12-27 |
Family
ID=68659577
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910613993.2A Active CN110535776B (en) | 2019-07-09 | 2019-07-09 | Gateway current limiting method, device, gateway, system and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110535776B (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113347041A (en) * | 2021-06-21 | 2021-09-03 | 深圳壹账通智能科技有限公司 | Dynamic current-limiting fusing configuration method, device, equipment and storage medium |
CN113452553A (en) * | 2021-06-18 | 2021-09-28 | 上海艾拉比智能科技有限公司 | Content distribution network flow limiting method and system |
CN116192758A (en) * | 2023-02-07 | 2023-05-30 | 浙江九州云信息科技有限公司 | Multi-rule combined current-limiting controller based on gateway service Kong |
CN117596080A (en) * | 2024-01-18 | 2024-02-23 | 北京安博通科技股份有限公司 | Access control method, equipment, terminal and system for terminal user traffic |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050220034A1 (en) * | 2004-03-31 | 2005-10-06 | Siemens Information And Communication Networks Inc. | Traffic control in an internet protocol network |
CN107404421A (en) * | 2017-09-18 | 2017-11-28 | 赛尔网络有限公司 | Flow monitoring, monitoring and managing method and system |
CN108418764A (en) * | 2018-02-07 | 2018-08-17 | 深圳壹账通智能科技有限公司 | Current-limiting method, device, computer equipment and storage medium |
-
2019
- 2019-07-09 CN CN201910613993.2A patent/CN110535776B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050220034A1 (en) * | 2004-03-31 | 2005-10-06 | Siemens Information And Communication Networks Inc. | Traffic control in an internet protocol network |
CN107404421A (en) * | 2017-09-18 | 2017-11-28 | 赛尔网络有限公司 | Flow monitoring, monitoring and managing method and system |
CN108418764A (en) * | 2018-02-07 | 2018-08-17 | 深圳壹账通智能科技有限公司 | Current-limiting method, device, computer equipment and storage medium |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113452553A (en) * | 2021-06-18 | 2021-09-28 | 上海艾拉比智能科技有限公司 | Content distribution network flow limiting method and system |
CN113347041A (en) * | 2021-06-21 | 2021-09-03 | 深圳壹账通智能科技有限公司 | Dynamic current-limiting fusing configuration method, device, equipment and storage medium |
CN113347041B (en) * | 2021-06-21 | 2022-03-01 | 深圳壹账通智能科技有限公司 | Dynamic current limiting fuse configuration method, device, equipment and storage medium |
CN116192758A (en) * | 2023-02-07 | 2023-05-30 | 浙江九州云信息科技有限公司 | Multi-rule combined current-limiting controller based on gateway service Kong |
CN116192758B (en) * | 2023-02-07 | 2024-03-29 | 浙江九州未来信息科技有限公司 | Multi-rule combined current-limiting controller based on gateway service Kong |
CN117596080A (en) * | 2024-01-18 | 2024-02-23 | 北京安博通科技股份有限公司 | Access control method, equipment, terminal and system for terminal user traffic |
CN117596080B (en) * | 2024-01-18 | 2024-04-23 | 北京安博通科技股份有限公司 | Access control method, equipment, terminal and system for terminal user traffic |
Also Published As
Publication number | Publication date |
---|---|
CN110535776B (en) | 2022-12-27 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110535776B (en) | Gateway current limiting method, device, gateway, system and storage medium | |
US9485134B2 (en) | Managing configurations of system management agents in a distributed environment | |
RU2531572C2 (en) | Database replication method and table updating apparatus | |
CN101719073B (en) | Intelligent client-based on-demand downloading realization method | |
US6098098A (en) | System for managing the configuration of multiple computer devices | |
US11876676B2 (en) | Network node firmware update | |
US20170115977A1 (en) | Apparatus and method for automating the installation and configuration of infrastructure | |
CN104488248B (en) | A kind of file synchronisation method, server and terminal | |
CN114024951B (en) | Cloud edge collaboration-based power edge heterogeneous deployment method | |
CN111200657A (en) | Method for managing resource state information and resource downloading system | |
CN107704550B (en) | File migration method and device and computer readable storage medium | |
CN104954482A (en) | Configuration management system and method | |
CN112732292B (en) | Method, system, equipment and readable storage medium for upgrading software | |
CN114296771A (en) | Installation package increment upgrading method and device based on file comparison | |
CN103139281B (en) | Personal printing system and control method thereof | |
CN112069152A (en) | Database cluster upgrading method, device, equipment and storage medium | |
KR102208704B1 (en) | Blockchain software capable of operation corresponding sql query, blockchain system, and method of thereof | |
CN111736876A (en) | Client update control method, device, storage medium and server | |
CN104104701A (en) | Online service configuration updating method and system | |
CN113626054A (en) | Business service updating method and device | |
CN109617713A (en) | Implementation method and server for resource distribution | |
US7296084B2 (en) | Data management system and method | |
CN110955460A (en) | Service process starting method and device, electronic equipment and storage medium | |
CN106407320B (en) | File processing method, device and system | |
US20140156714A1 (en) | Distributed file system processing apparatus and method, and storage media storing the same |
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 |