A concurrency control method and device
By determining the attribute information of the message request in the current limiting server and performing the current limiting process based on its configuration parameters and statistical parameters, the problem of inability to adaptively adjust the traffic threshold in the prior art is solved, and a higher traffic resource utilization rate is achieved and system stability.
Patent Information
- Application Number
- CN201910390740.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-05-10
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2039-05-10
AI Technical Summary
Existing software current limiting algorithms cannot adaptively adjust the traffic threshold allocation of different services when facing complex business needs, resulting in a decrease in traffic resource utilization and a decrease in system stability.
The current limiting server obtains the message request forwarded by the load balancing device, determines the attribute information of the message request, and obtains the corresponding configuration parameters and statistical parameters based on the attribute information. If the forwarding condition is met, the message request is forwarded to the processing server.
It realizes refined flow restriction based on the attribute information of message requests, improves the utilization rate of traffic resources, and improves the stability of the system and message processing performance.
Smart Images

Figure CN110191160B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of financial technology, and in particular, to a concurrency control method and device. Background Art
[0002] With the development of computer technology, computer-related technologies (big data, distributed architecture, etc.) are being used more and more widely in the financial field. The traditional financial industry is gradually transforming to financial technology (Fintech). In existing technologies, in order to ensure the smooth operation of the business, it is often necessary to limit the flow of transaction requests to prevent external systems from sending a large number of transaction requests without restriction, resulting in a large amount of core system resources being occupied or even downtime.
[0003] Common concurrency control methods include hardware current limiting and software current limiting. Hardware current limiting limits external access by purchasing professional current limiting tools, which is often expensive and can only be limited based on the fourth layer protocol (TCP / IP), which is not flexible enough. Software current limiting is the mainstream in the industry as a lower-cost and more flexible solution. The current software current limiting algorithm mainly uses a simple counter to limit the number of request services that can pass through per second.
[0004] However, although the above software flow limiting algorithm can limit access traffic based on business needs, the flow limiting function is relatively simple. When faced with complex business needs, it cannot adaptively adjust the traffic threshold allocation of different businesses, which reduces the utilization rate of traffic resources and thus reduces the stability of the system. Summary of the invention
[0005] The embodiments of the present invention provide a concurrency control method and device, which are used to allocate thresholds according to the attributes of different messages when facing complex business needs, and improve the utilization rate of traffic resources.
[0006] An embodiment of the present invention provides a concurrency control method, the method comprising:
[0007] The current limiting server obtains the message request forwarded by the load balancing device;
[0008] The current limiting server determines attribute information of the message request according to the message request;
[0009] The current limiting server obtains configuration parameters and statistical parameters corresponding to the attribute information according to the attribute information; the configuration parameters are configured according to the attribute information;
[0010] If it is determined that the message request meets the forwarding condition according to the configuration parameters and the statistical parameters, the message request is forwarded to a processing server to process the message request.
[0011] In a possible implementation manner, determining, according to the configuration parameters and the statistical parameters, that the message request meets the forwarding condition includes:
[0012] Based on the configuration parameters, determining whether the current statistical parameters meet the reset condition;
[0013] If it is determined that the reset condition is met, the statistical parameter is reset; after the reset, the statistical parameter is updated according to the message request and it is determined whether the updated statistical parameter meets the forwarding condition;
[0014] If it is determined that the reset condition is not met, the statistical parameter is updated according to the message request, and it is determined whether the updated statistical parameter meets the forwarding condition.
[0015] In a possible implementation, the statistical parameters include at least one or more of the following: reset time, number of statistical messages; the configuration parameters include at least one or more of the following: current limiting threshold, statistical period;
[0016] The determining whether the current statistical parameters meet the reset condition includes:
[0017] Determine the time difference between the reset time and the current time;
[0018] If it is determined that the time difference is greater than or equal to the statistical period, the reset time is set to the current time, and the number of statistical messages is reset and a preset increment is added;
[0019] If it is determined that the time difference is less than the statistical period, the number of statistical messages is increased by a preset increment;
[0020] The determining whether the updated statistical parameter time satisfies the forwarding condition includes:
[0021] If it is determined that the statistical message number is less than the current limiting threshold, it is determined that the message request meets the forwarding condition.
[0022] In a possible implementation, the configuration parameters are configured according to the attribute information, including:
[0023] The attribute information includes at least one or more of the following: merchant information of the message request, interface information of the message request, and service type of the message request;
[0024] For any attribute information, determine the total current limiting parameter corresponding to the attribute information; and determine the current limiting threshold of each current limiting server according to the number of currently available current limiting servers and the total current limiting parameter.
[0025] In a possible implementation, determining the current limiting threshold of each current limiting server according to the number of currently available current limiting servers and the total current limiting parameter includes:
[0026] If the number of available current limiting servers changes during the statistical period, the number of statistical messages of each current limiting server is obtained;
[0027] Determine the updated total current limiting parameter according to the total current limiting parameter and the number of statistical messages of each current limiting server;
[0028] According to the number of available current limiting servers and the updated total current limiting parameters, the current limiting threshold of each current limiting server is determined.
[0029] Another embodiment of the present invention provides a concurrency control device, the device comprising:
[0030] A transceiver unit, used to obtain a message request forwarded by a load balancing device;
[0031] A processing unit, used to determine the attribute information of the message request according to the message request; obtain configuration parameters and statistical parameters corresponding to the attribute information according to the attribute information; the configuration parameters are configured according to the attribute information; if it is determined according to the configuration parameters and statistical parameters that the message request meets the forwarding conditions, the message request is forwarded to a processing server to process the message request.
[0032] In a possible implementation manner, the processing unit is specifically configured to:
[0033] Based on the configuration parameters, determine whether the current statistical parameters meet the reset conditions; if it is determined that the reset conditions are met, reset the statistical parameters; after the reset, update the statistical parameters according to the message request and determine whether the updated statistical parameters meet the forwarding conditions; if it is determined that the reset conditions are not met, update the statistical parameters according to the message request and determine whether the updated statistical parameters meet the forwarding conditions.
[0034] In a possible implementation, the statistical parameters include at least one or more of the following: reset time, number of statistical messages; the configuration parameters include at least one or more of the following: current limiting threshold, statistical period;
[0035] The processing unit is specifically used for:
[0036] Determine the time difference between the reset time and the current time; if it is determined that the time difference is greater than or equal to the statistical period, set the reset time to the current time, reset the number of statistical messages and add a preset increment; if it is determined that the time difference is less than the statistical period, add a preset increment to the number of statistical messages; if it is determined that the number of statistical messages is less than the current limiting threshold, determine that the message request meets the forwarding condition.
[0037] Another embodiment of the present invention provides a computing device, which includes a memory and a processor, wherein the memory is used to store program instructions, and the processor is used to call the program instructions stored in the memory and execute any of the above methods according to the obtained program.
[0038] Another embodiment of the present invention provides a computer storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable the computer to execute any one of the above methods.
[0039] The above-mentioned embodiment provides a concurrency control method and device, including: obtaining a message request forwarded by a load balancing device; the current limiting server determines the attribute information of the message request according to the message request; the current limiting server obtains configuration parameters and statistical parameters corresponding to the attribute information according to the attribute information; the configuration parameters are configured according to the attribute information; if it is determined according to the configuration parameters and statistical parameters that the message request meets the forwarding conditions, the message request is forwarded to the processing server to process the message request. Therefore, the message request can be allocated on demand through the attribute information of the message request, thereby improving the message processing performance of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for describing the embodiments are briefly introduced below.
[0041] Figure 1 A schematic diagram of the architecture of a concurrent control system provided by an embodiment of the present invention;
[0042] Figure 2 A flowchart of a concurrency control method provided by an embodiment of the present invention;
[0043] Figure 3 A flowchart of a concurrency control method provided by an embodiment of the present invention;
[0044] Figure 4 A schematic diagram of the structure of a current limiting server provided in an embodiment of the present invention;
[0045] Figure 5 A schematic diagram of the structure of a concurrency control device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0046] In order to make the purpose, technical solution and beneficial effects of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0047] Fintech refers to a new innovative technology brought to the financial field after the integration of information technology into the financial field. By using advanced information technology to assist in financial operations, transaction execution and financial system improvement, it can improve the processing efficiency and business scale of the financial system and reduce costs and financial risks.
[0048] It should be understood that in the embodiments of the present application, "at least one" refers to one or more, and "plurality" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can represent: a, b, c, a and b, a and c, b and c, or a, b and c, where a, b, c can be single or multiple.
[0049] The following is an introduction to the technical terms involved in the embodiments of the present application:
[0050] Message requester: A merchant that connects to the message forwarding system to perform collection, payment, payment redirection, direct payment, refund, balance inquiry, authentication, etc. on message requests.
[0051] Interface: The terminal of the message requester requests the interface address and passes in the parameters defined by the interface. Through the logic processing of the interface itself, the data agreed upon by the interface and the corresponding data format are returned.
[0052] Current limiting: When the number of concurrent message requests reaches a certain level or rate, waiting, queuing, downgrading, or denial of service will be performed.
[0053] Business type: The message request type in the message request initiated by the merchant to the interface provided by the system, such as collection on behalf of others, payment on behalf of others, jump payment, direct payment, refund, balance inquiry, authentication, etc.
[0054] Figure 1 A schematic diagram of a concurrent control system architecture provided by an embodiment of the present invention, such as Figure 1 As shown, the system may include a message forwarding device 110, a load balancing device 120 and at least one current limiting server (hereinafter, two current limiting servers 130 and 140 are used as examples for explanation). Each current limiting server corresponds to at least one processing server. To improve the load balancing effect, the current limiting server forwards to the processing server and can be determined by a complex balancing strategy (here, the current limiting server 130 forwards to the processing server 131, and the current limiting server 140 forwards to the processing server 141 are used as examples for explanation). Current limiting configuration device 150. Taking the current limiting server 130 as an example, as Figure 1 As shown, the current limiting server 130 may have multiple processing servers, and the message processor 131 is taken as an example here.
[0055] In the embodiment of the present invention, the message forwarding device 110 may be connected to the load balancing device 120 in communication, and the load balancing device 120 may be connected to at least one current limiting server (such as the current limiting server 130) in communication. There may be many ways to achieve the communication connection, such as achieving the communication connection in a wired manner or in a wireless manner, which is not specifically limited.
[0056] After receiving the message request, the current limiting server can store the message request in a storage device set inside the server; further, the processing server can obtain the message request from the corresponding current limiting server to process the message request, for example, the message request can be submitted to an application so that the application performs subsequent operations on the message request.
[0057] In a specific implementation, the load balancing device 120 may receive a message request sent by the message forwarding device 110 to the load balancing device 120 , and may forward the message request to at least one current limiting server among the available current limiting servers according to the load balancing rule.
[0058] For example, the message forwarding device 110 needs to process a message to a processing server, then the message forwarding device 110 may send a first message request to the load balancing device 120, and the first message request may include an identifier and target data of the message request; accordingly, after receiving the first message request, the load balancing device 120 may determine, based on the identifier of the message request included in the first message request, a flow limiting server to which the message request is forwarded from the load balancing device 120 according to the load balancing policy; if it is determined that the message request needs to be forwarded to the flow limiting server 130, then the message request is sent to the flow limiting server 130 according to the pre-stored IP address of the flow limiting server 130, and the flow limiting server 130 determines, based on the load balancing policy, the processing server that needs to process the message request, for example, if it is determined to be the processing server 141, then the flow limiting server 130 forwards the message request to the processing server 141 for processing.
[0059] The existing flow control is for the entire system or interface level. It is a protection mechanism to prevent a sudden increase in the number of interface visits from causing server pressure or even service unavailability. It protects the system by limiting the rate of concurrent requests or requests within a time window. Once the rate limit is reached, the service can be denied, queued or waited, or downgraded. It is only to protect the system and enable the system to provide stable services. It cannot perform fine flow control on merchants.
[0060] Among the merchant message requests, some have very low request frequencies, while others have relatively high request frequencies. The peak request time periods of each merchant are also different. If we simply perform simple flow control based on the request volume, the failure rate of merchants with low request frequencies will be very high, that is, the merchant interface requests will affect each other.
[0061] based on Figure 1 The system architecture of the concurrent control system is shown in Figure 1. Figure 2 A flowchart corresponding to a concurrency control method provided in an embodiment of the present invention, the method comprising:
[0062] Step 101: Obtain the server status reported by the current limiting server;
[0063] The server status includes network status, load status, etc. All current limiting servers report their status to the configuration server, and the configuration server can know the number of available current limiting servers in real time. In this way, when configuring the configuration server management station, the current limiting threshold distributed to each current limiting server can be determined according to the number of current limiting servers.
[0064] Step 102: Determine the total flow limiting parameter of the message request of the merchant according to the attribute information of the merchant;
[0065] Among them, the attribute information includes at least one or more of the following: the merchant information of the message request, the interface information of the message request, the business type of the message request, etc.; specifically, the merchant information may include the merchant number, merchant logo, etc.; the interface information may include: request interface URL, etc.
[0066] Specifically, the manner of setting different total current limiting parameters according to different attributes is not limited here.
[0067] For any attribute information, determine the total current limiting parameter corresponding to the attribute information; and determine the current limiting threshold of each current limiting server according to the number of currently available current limiting servers and the total current limiting parameter.
[0068] For example, the total current limiting parameters for different merchant numbers can be set according to the merchant number of the merchant; for example, the merchant includes merchant number 1 and merchant number 2, and the total current limiting parameter 1 for merchant number 1 and the total current limiting parameter 2 for merchant number 2 can be set; the total current limiting parameters for message requests of different business types of different merchant numbers can also be set according to the merchant number and business type of the merchant; for example, the merchant number 1 of the merchant includes business type 1 and business type 2, and the total current limiting parameter 11 for merchant number 1 in business type 1 can be set, and the total current limiting parameter 2 for merchant number 2 can be set. The total flow limiting parameter of account number 1 in business type 2 is 12; the total flow limiting parameter of message requests obtained from different request interfaces for different business types of different merchant numbers can also be set according to the merchant number, business type, and request interface URL of the merchant; for example, business type 1 of merchant number 1 of the merchant includes interface 1 and interface 2, then the total flow limiting parameter of merchant number 1 sending business type 1 message request at interface 1 can be set to 111, and the total flow limiting parameter of merchant number 1 sending business type 1 message request at interface 2 can be set to 112.
[0069] Current limiting control is based on the number of requests processed within a specified time period. Operation and maintenance or business management personnel can configure current limiting based on the characteristics of the merchant's attributes when configuring the server, or they can modify the current limiting parameters in real time based on the actual request volume of each merchant.
[0070] In a specific embodiment, the total current limiting parameters may include a total current limiting threshold and a statistical period; the total current limiting threshold may be the maximum number of requests allowed within the statistical period, and the statistical period may be a time length; that is, it may be 5 requests within 1 second, or 100 requests within 1 minute, or 100 requests within 30 seconds, etc. Among them, the maximum number of requests and the time length can be configured for each current limiting server through the configuration server, and the configuration method can be pre-configured or real-time configured, which is not limited here. If it is determined that the configuration parameters are not configured, the system default configuration parameters can be used.
[0071] Step 103: Determine the current limiting parameters of each current limiting server according to the total current limiting parameters requested by the merchant's message and the status of the current limiting server.
[0072] One possible implementation is to evenly divide the total current limiting parameters according to the number of available current limiting servers.
[0073] Of course, weighted allocation can also be performed based on the request processing capacity of the current limiting server, which is not limited here.
[0074] It should be noted that, since the current limiting value is an integer, if the configured current limiting value cannot be divided by the number of current limiting servers, there may be a configuration difference of 1 in the current limiting thresholds between the current limiting servers.
[0075] For example, the merchant number 1 of the merchant sends a total flow limiting parameter 111 for a service type 1 message request at interface 2, and the currently available flow limiting servers are flow limiting servers 130 and 140; the flow limiting parameter 112_130 of the flow limiting server 130 for the service type 1 message request sent by the merchant number 1 at interface 2 can be set, and the flow limiting parameter 112_140 of the flow limiting server 140 for the service type 1 message request sent by the merchant number 1 at interface 2 can be set.
[0076] For example, for the message request configured for merchant 1 (business type is collection, corresponding interface is URL1), 402 requests are configured in 1 minute, and there are currently 5 available rate limiting servers, that is, the configuration of 402 requests in 1 minute will be divided into 3 configurations of 80 requests in 1 minute and 2 configurations of 81 requests in 1 minute. The allocation method can be random allocation.
[0077] Step 104: The determined current limiting parameters of each current limiting server are stored and submitted to each current limiting server synchronously.
[0078] Among them, the storage method may include storing it in a cache server, which is conducive to each current limiting server to quickly call the corresponding current limiting parameters, without the need for each current limiting server to store the current limiting parameters corresponding to each current limiting server corresponding to various message requests or the total current limiting parameters corresponding to various message requests. A database may also be included for backing up the current limiting parameters. In order to prevent the cache of the current limiting parameters of the current limiting server from being lost, the current limiting server will periodically synchronize the current limiting parameters from the database to the current limiting server. It is also possible to directly synchronize and update to all current limiting servers without the need for a cache system, after the current limiting parameters configured by the configuration server are updated in the database.
[0079] One possible implementation method is to configure the flow-limiting parameters of the configuration server. When configuring the server configuration, the configuration personnel need to calculate and configure according to the number of current flow-limiting servers, and pre-determine the flow-limiting parameters on each flow-limiting server. That is, if the configuration server is configured with 200 requests per minute for the message request for a certain attribute information of the merchant requester, that is, 200 requests per minute are sent to each flow-limiting server. For N flow-limiting servers, the total flow-limiting value of the message request corresponding to the attribute information is (N*200) requests.
[0080] In combination with the above embodiments, Figure 3 As shown, the embodiment of the present invention also provides a flow chart corresponding to a concurrency control method, the method comprising:
[0081] Step 201: The current limiting server obtains the message request forwarded by the load balancing device;
[0082] The message request is initiated by a customer of a cooperating merchant; the message forwarding server verifies the message request through anti-attack and other checks, and then forwards it to the current limiting server through a load balancing device.
[0083] Specifically, the message forwarding server can verify the message request through anti-attack and other specific methods, through a unified authentication public service platform, through the source ID to identify the business platform, and through the application ID to identify the specific application. For different interfaces, the source ID and application ID may exist in the header file or parameter (param) in the message request, or may be placed in the data field. The server can limit the flow of message requests with specified identifiers to filter out illegal message requests.
[0084] In addition, after receiving the message request, the message forwarding server can also place the message into the corresponding service queue according to the priority parameter value carried in the message request. After that, the load balancing device obtains the message from each service queue according to the preset forwarding strategy for message forwarding, wherein the forwarding strategy can correspond different access frequencies to service queues of different priorities, and the higher the priority, the higher the access frequency. In this way, by setting service queues of different priorities, it is possible to avoid the problem of other services preempting high-frequency services, thereby improving the stability of the system and service quality.
[0085] Step 202: The current limiting server determines attribute information of the message request according to the message request;
[0086] The flow limiting server obtains the merchant's merchant number, business type, request interface URL and other attribute information from the message request; specifically, the attribute information can be the identifier of the sender of the message request, for example, including any of the following: URL, IP address, source ID, application ID. The pre-set attribute can also be a preset field, which is used to represent the attribute label of the merchant.
[0087] Step 203: The current limiting server obtains configuration parameters and statistical parameters corresponding to the attribute information according to the attribute information; the configuration parameters are configured according to the attribute information;
[0088] Specifically, the current limiting server obtains the configuration parameters corresponding to the attribute information according to the attribute information, which can be the current limiting parameters pre-configured for the attribute information for the current limiting server; for example, if it is determined that the attribute information of the message request is that merchant number 1 sends service type 1 at interface 2, and the current limiting server is the current limiting server 130; then the current limiting parameters 112_130 of the message request for business type 1 sent by merchant number 1 at interface 2 can be determined. Among them, the statistical parameter is the currently counted message request statistical value of the same attribute information as the message request, for example, the counter value; the last statistical time.
[0089] In combination with the above embodiment, the current limiting server can obtain the current limiting parameters corresponding to the current limiting server corresponding to the attribute information from the cache server according to the attribute information. Of course, the current limiting parameters corresponding to the current limiting server corresponding to the attribute information pre-stored by the current limiting server can also be obtained.
[0090] Step 204: If it is determined that the message request meets the forwarding condition according to the configuration parameters and the statistical parameters, the message request is forwarded to a processing server to process the message request.
[0091] Specifically, if it is determined that the message request does not meet the forwarding condition, a response such as "please try again later" is returned; otherwise, the request is forwarded to the processing server for processing and then a response message of the message request is returned.
[0092] Specifically, the flow limiting server may also respond to the sender of the message request with a prompt message that the message request is rejected, for example, by returning "403" to the sender of the message request. If there is no such prompt message, it means that there is no need to limit the flow of the message request, and the message request may be processed.
[0093] In the embodiment of the present application, the flow can be limited precisely, and various attribute information of the message request can be used for precise control, so that the message requests of high-frequency merchants will not affect the message requests of low-frequency merchants, the influence between merchants can be isolated, and the effect of message forwarding can be improved.
[0094] In a possible implementation manner, determining, according to the configuration parameters and the statistical parameters, that the message request meets the forwarding condition includes:
[0095] Step 1: Based on the configuration parameters, determine whether the current statistical parameters meet the reset condition;
[0096] The reset condition is determined by comparing the last statistical time in the current statistical parameters with the statistical period in the configuration parameters.
[0097] Step 2: If it is determined that the reset condition is met, the statistical parameter is reset; after the reset, the statistical parameter is updated according to the message request and it is determined whether the updated statistical parameter meets the forwarding condition;
[0098] Step three: If it is determined that the reset condition is not met, update the statistical parameters according to the message request, and determine whether the updated statistical parameters meet the forwarding condition.
[0099] In a possible implementation, the statistical parameters include at least one or more of the following: reset time, number of statistical messages; the configuration parameters include at least one or more of the following: current limiting threshold, statistical period;
[0100] In step 2, determining whether the current statistical parameters meet the reset condition may include the following steps:
[0101] Step 1: Determine the time difference between the reset time and the current time;
[0102] The reset time is the time when the statistical message count was reset last time, and the statistical method for calculating the statistical message count may be a counter.
[0103] Step 2: If it is determined that the time difference is greater than or equal to the statistical period, the reset time is set to the current time, and the number of statistical messages is reset and a preset increment is added;
[0104] Specifically, if the statistical period is 2 seconds, the current time is 12:00:03, and the reset time is 12:00:00, the time difference is determined to be 3 seconds, which is greater than the statistical period of 2 seconds. The reset condition is met, and the reset time is set to the current time, the counter is cleared, and then the counter is increased by a preset increment, which can be selected as one.
[0105] If the statistical parameter is obtained by the current limiting server from the cache server, then at this time, the current limiting server needs to update the statistical message number of the counter after incrementing by one to the cache server.
[0106] Step 3: If it is determined that the time difference is less than the statistical period, the number of statistical messages is increased by a preset increment;
[0107] Specifically, if the statistical cycle is 2 seconds, the current time is 12:00:03, and the reset time is 12:00:02, the time difference is determined to be 1 second, which is less than the statistical cycle of 2 seconds. The reset condition is not met, and the counter is directly increased by one to determine the number of statistical messages.
[0108] Step 4: If it is determined that the statistical message number is less than the current limiting threshold, it is determined that the message request meets the forwarding condition.
[0109] Embodiment 2
[0110] In a possible implementation, the reset condition is: if it is determined that the current time reaches the statistical period length, the number of statistical messages is reset;
[0111] The forwarding condition is: if it is determined that the statistical message number is less than the current limiting threshold, it is determined that the message request meets the forwarding condition.
[0112] For example, if the statistical period is 2 seconds, and the statistical start time is 11:00:00, the current time is 12:00:03, and the most recent reset time is 12:00:02, it can be determined that the reset condition has not been reached, and there is no need to reset the counter corresponding to the number of statistical messages. The counter corresponding to the number of statistical messages is incremented by a preset increment. If it is determined that the counter after adding the preset increment is less than the current limiting threshold, it is determined that the message request meets the forwarding condition.
[0113] Since the number of available current limiting servers and message requests may change over time, when the available configuration server detects a change in the number of current limiting servers or the merchant submits a configuration modification on the front-end page, the allocation, database update and push process in the above embodiment must be repeated. Of course, each current limiting server will also periodically pull configuration parameters from the configuration server to prevent push failure or loss. After the configuration server modifies the configuration parameters, the current limiting server will take effect in real time.
[0114] In a possible implementation, determining the current limiting threshold of each current limiting server according to the number of currently available current limiting servers and the total current limiting parameter includes:
[0115] If the number of available current limiting servers changes during the statistical period, the number of statistical messages of each current limiting server is obtained;
[0116] Determine the updated total current limiting parameter according to the total current limiting parameter and the number of statistical messages of each current limiting server;
[0117] According to the number of available current limiting servers and the updated total current limiting parameters, the current limiting threshold of each current limiting server is determined.
[0118] For example, taking equal distribution as an example, before the update, the number of current limiting servers is 10, and after the update, the number of current limiting servers is 5; then the configuration parameter of each current limiting server before the update is updated from 100 requests per second to 50 requests per second.
[0119] For example, the configuration parameters of the message request for URL1 of business type 1 assigned to merchant X are configured as 100 requests per second;
[0120] For example, if it is determined that the counter has reached 100 before the update, the next request within this second will be throttled and a response such as "Please try again later" will be directly returned until the counter is reset after this 1 second.
[0121] In the configuration server, the configuration parameters were updated at 1:40:00, so that the current limiting configuration of the current limiting server became 50 requests per second:
[0122] In one possible scenario, after the update, if it is determined that the counter of the limiting server has exceeded 50, all message requests within the current statistical period of this counter will be limited, and a response such as "Please try again later" will be returned.
[0123] In one possible scenario, the configuration parameters are updated at 1:40:00, so that the current limit configuration of the current limit server becomes 150 requests per second:
[0124] In one possible scenario, after the update, the current limiting threshold of the counter takes effect. When the number of message requests in the current statistical period of this counter exceeds 100 but does not exceed 150, the current will not be limited.
[0125] Since the allocation of flow limiting thresholds for different services can be adjusted adaptively, the utilization rate of traffic can be improved through on-demand allocation, thereby ensuring the stability of the system. Multi-dimensional traffic filtering through multiple attribute features can provide more accurate and flexible traffic control strategies.
[0126] Based on the same technical concept, the embodiment of the present invention also provides a concurrency control device, such as Figure 4 As shown, the device may include:
[0127] The transceiver unit 401 is used to obtain the message request forwarded by the load balancing device;
[0128] The processing unit 402 is used to determine the attribute information of the message request according to the message request; obtain the configuration parameters and statistical parameters corresponding to the attribute information according to the attribute information; the configuration parameters are configured according to the attribute information; if it is determined according to the configuration parameters and statistical parameters that the message request meets the forwarding conditions, the message request is forwarded to the processing server to process the message request.
[0129] In a possible implementation manner, the processing unit 402 is specifically configured to:
[0130] Based on the configuration parameters, determine whether the current statistical parameters meet the reset conditions; if it is determined that the reset conditions are met, reset the statistical parameters; after the reset, update the statistical parameters according to the message request and determine whether the updated statistical parameters meet the forwarding conditions; if it is determined that the reset conditions are not met, update the statistical parameters according to the message request and determine whether the updated statistical parameters meet the forwarding conditions.
[0131] In a possible implementation manner, the processing unit 402 is specifically configured to:
[0132] The statistical parameters include at least one or more of the following: reset time, number of statistical messages; the configuration parameters include at least one or more of the following: current limiting threshold, statistical period;
[0133] The processing unit 402 is specifically configured to:
[0134] Determine the time difference between the reset time and the current time; if it is determined that the time difference is greater than or equal to the statistical period, set the reset time to the current time, reset the number of statistical messages and add a preset increment; if it is determined that the time difference is less than the statistical period, add a preset increment to the number of statistical messages; if it is determined that the number of statistical messages is less than the current limiting threshold, determine that the message request meets the forwarding condition.
[0135] A possible implementation method is that the processing unit 402 is specifically used to: the attribute information includes at least one or more of the following: the merchant information of the message request, the interface information of the message request, and the service type of the message request; for any attribute information, determine the total current limiting parameter corresponding to the attribute information; determine the current limiting threshold of each current limiting server according to the number of currently available current limiting servers and the total current limiting parameter.
[0136] In a possible implementation manner, the processing unit 402 is specifically configured to:
[0137] If the number of available current limiting servers changes within the statistical period, the number of statistical messages of each current limiting server is obtained; the updated total current limiting parameter is determined based on the total current limiting parameter and the number of statistical messages of each current limiting server; the current limiting threshold of each current limiting server is determined based on the number of available current limiting servers and the updated total current limiting parameter.
[0138] Based on the same technical concept, an embodiment of the present invention provides a concurrency control device, such as Figure 5 As shown, it includes at least one processor 1101 and a memory 1102 connected to the at least one processor. The specific connection medium between the processor 1101 and the memory 1102 is not limited in the embodiment of the present invention. Figure 5For example, the processor 1101 and the memory 1102 are connected via a bus. The bus can be divided into an address bus, a data bus, a control bus, etc.
[0139] In an embodiment of the present invention, the memory 1102 stores instructions that can be executed by at least one processor 1101. By executing the instructions stored in the memory 1102, the at least one processor 1101 can execute the steps included in the aforementioned resource management method (ie, steps 101 to 103).
[0140] Among them, the processor 1101 is the control center of the terminal device, and can use various interfaces and lines to connect various parts of the terminal device, and realize data processing by running or executing instructions stored in the memory 1102 and calling data stored in the memory 1102. Optionally, the processor 1101 may include one or more processing units, and the processor 1101 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, merchant interface and application programs, etc., and the modem processor mainly processes instructions issued by operation and maintenance personnel. It is understandable that the above-mentioned modem processor may not be integrated into the processor 1101. In some embodiments, the processor 1101 and the memory 1102 may be implemented on the same chip, and in some embodiments, they may also be implemented separately on independent chips.
[0141] The processor 1101 may be a general-purpose processor, such as a central processing unit (CPU), a digital signal processor, an application-specific integrated circuit (ASIC), a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component, and may implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present invention. A general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the method disclosed in the embodiment of resource processing may be directly embodied as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.
[0142] The memory 1102 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The memory 1102 may include at least one type of storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory, a random access memory (Random Access Memory, RAM), a static random access memory (Static Random Access Memory, SRAM), a programmable read-only memory (Programmable Read Only Memory, PROM), a read-only memory (Read Only Memory, ROM), an electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), a magnetic memory, a disk, an optical disk, etc. The memory 1102 is any other medium that can be used to carry or store a desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto. The memory 1102 in the embodiment of the present invention can also be a circuit or any other device that can realize a storage function, for storing program instructions and / or data.
[0143] An embodiment of the present invention provides a computer storage medium for storing computer program instructions used by the above-mentioned computing device, which includes a program for executing the above-mentioned concurrency control method.
[0144] The computer storage medium can be any available medium or data storage device that can be accessed by a computer, including but not limited to magnetic storage (such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO)), optical storage (such as CDs, DVDs, BDs, HVDs, etc.), and semiconductor storage (such as ROM, EPROM, EEPROM, non-volatile memory (NAND FLASH), solid-state drives (SSDs)), etc.
[0145] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0146] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0147] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0148] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0149] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0150] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A concurrency control method, characterized in that: The method comprises: The current limiting server obtains a message request forwarded by the load balancing device; the message request is forwarded by the load balancing device by obtaining messages from service queues with different priorities according to a preset forwarding strategy; The current limiting server determines attribute information of the message request according to the message request; The current limiting server obtains configuration parameters and statistical parameters corresponding to the attribute information according to the attribute information; the configuration parameters are configured according to the attribute information; the configuration parameters can be modified in real time according to the actual request volume of each merchant; If it is determined according to the configuration parameters and the statistical parameters that the message request meets the forwarding condition, the message request is forwarded to a processing server to process the message request; The configuration parameters are configured according to the attribute information, including: The attribute information includes the merchant information of the message request, the interface information of the message request, and the service type of the message request; For any attribute information, determine the total current limiting parameter corresponding to the attribute information; determine the current limiting threshold of each current limiting server according to the number of currently available current limiting servers and the total current limiting parameter; if the total current limiting parameter cannot be divided by the number of currently available current limiting servers, there may be a configuration difference of 1 in the current limiting thresholds between the current limiting servers.
2. The method according to claim 1, characterized in that The determining, according to the configuration parameters and the statistical parameters, that the message request meets the forwarding condition includes: Based on the configuration parameters, determining whether the current statistical parameters meet the reset condition; If it is determined that the reset condition is met, the statistical parameter is reset; after the reset, the statistical parameter is updated according to the message request and it is determined whether the updated statistical parameter meets the forwarding condition; If it is determined that the reset condition is not met, the statistical parameter is updated according to the message request, and it is determined whether the updated statistical parameter meets the forwarding condition.
3. The method according to claim 2, characterized in that The statistical parameters include at least one or more of the following: reset time, number of statistical messages; the configuration parameters include at least one or more of the following: current limiting threshold, statistical period; The determining whether the current statistical parameters meet the reset condition includes: Determine the time difference between the reset time and the current time; If it is determined that the time difference is greater than or equal to the statistical period, the reset time is set to the current time, and the number of statistical messages is reset and a preset increment is added; If it is determined that the time difference is less than the statistical period, the number of statistical messages is increased by a preset increment; The determining whether the updated statistical parameter time satisfies the forwarding condition includes: If it is determined that the statistical message number is less than the current limiting threshold, it is determined that the message request meets the forwarding condition.
4. The method according to claim 1, characterized in that The determining the current limiting threshold of each current limiting server according to the number of currently available current limiting servers and the total current limiting parameter includes: If the number of available current limiting servers changes during the statistical period, the number of statistical messages of each current limiting server is obtained; Determine the updated total current limiting parameter according to the total current limiting parameter and the number of statistical messages of each current limiting server; According to the number of available current limiting servers and the updated total current limiting parameters, the current limiting threshold of each current limiting server is determined.
5. A concurrent control device, characterized in that: The device comprises: A transceiver unit, used for obtaining a message request forwarded by a load balancing device; the message request is forwarded by the load balancing device by obtaining a message from service queues with different priorities according to a preset forwarding strategy; A processing unit, used to determine the attribute information of the message request according to the message request; obtain configuration parameters and statistical parameters corresponding to the attribute information according to the attribute information; the configuration parameters are configured according to the attribute information; the configuration parameters can be modified in real time according to the actual request volume of each merchant; if it is determined according to the configuration parameters and statistical parameters that the message request meets the forwarding conditions, the message request is forwarded to the processing server to process the message request; the attribute information includes the merchant information of the message request, the interface information of the message request and the service type of the message request; for any attribute information, determine the total current limiting parameter corresponding to the attribute information; determine the current limiting threshold of each current limiting server according to the number of currently available current limiting servers and the total current limiting parameter; if the total current limiting parameter cannot be divided by the number of currently available current limiting servers, there may be a configuration difference of 1 in the current limiting thresholds between the current limiting servers.
6. The device according to claim 5, characterized in that The processing unit is specifically used for: Based on the configuration parameters, determining whether the current statistical parameters meet the reset condition; if it is determined that the reset condition is met, resetting the statistical parameters; After resetting, updating the statistical parameter according to the message request and determining whether the updated statistical parameter meets the forwarding condition; If it is determined that the reset condition is not met, the statistical parameter is updated according to the message request, and it is determined whether the updated statistical parameter meets the forwarding condition.
7. The device according to claim 6, characterized in that The statistical parameters include at least one or more of the following: reset time, number of statistical messages; the configuration parameters include at least one or more of the following: current limiting threshold, statistical period; The processing unit is specifically used for: Determine the time difference between the reset time and the current time; if it is determined that the time difference is greater than or equal to the statistical period, set the reset time to the current time, reset the number of statistical messages and add a preset increment; If it is determined that the time difference is less than the statistical period, the number of statistical messages is increased by a preset increment; If it is determined that the statistical message number is less than the current limiting threshold, it is determined that the message request meets the forwarding condition.
8. A computing device, characterized in that include: A memory for storing program instructions; A processor, configured to call the program instructions stored in the memory, and execute the method according to any one of claims 1 to 4 according to the obtained program.
9. A computer storage medium, characterized in that The computer storage medium stores computer executable instructions, and the computer executable instructions are used to enable the computer to execute the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Service distributing request method and device
CN104092650A
Server load shunting method and device
CN108173938A
Flow monitoring method and device, computer device and storage medium
CN109194584A