Concurrency control-based current limiting management method, system and device, and storage medium
By analyzing the supplier and business identifiers of business requests, using atomic counters to track the concurrency status and dynamically adjusting the maximum concurrency threshold, the problem that traditional current limiting methods cannot be flexibly controlled, and improve the stability of the system and resource utilization efficiency.
Patent Information
- Application Number
- CN202510395415.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-31
- Publication Date
- 2025-08-26
AI Technical Summary
Traditional current limiting methods cannot flexibly concurrently control based on different suppliers and business identifiers, and lack real-time monitoring, which leads to exhaust system resources, long response time and even crashes, affecting service stability and availability.
By receiving service requests and analyzing suppliers and business identifiers, querying corresponding current limit configuration parameters, using atomic counters to achieve concurrent state tracking, dynamically adjusting the maximum concurrency threshold, and registering real-time monitoring into the system to achieve flexible concurrency control and management.
It realizes flexible concurrency control, accurate concurrent state tracking, real-time dynamic adjustment of strategies, improves system stability and resource utilization efficiency, and enhances system scalability and adaptability.
Smart Images

Figure CN120540927A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of current limiting management, and in particular to a current limiting management method, system, device and storage medium based on concurrency control. Background Art
[0002] In a global distribution system (GDS), the system must process a large number of business requests from various channels. With the continuous development of the business and the increase in the number of users, the system faces increasing pressure from concurrent requests. Without effective rate limiting control, system resources can be exhausted, response times can be prolonged, and even system crashes can occur, impacting service stability and availability. Traditional rate limiting methods often use fixed rules and lack flexible concurrency control based on different suppliers and booking business identifiers. Furthermore, the lack of real-time monitoring of concurrency makes it difficult to accurately grasp the system's operating status, hindering system optimization and adjustment.
[0003] Therefore, it is necessary to provide a current limiting management method, system, device and storage medium based on concurrency control. Summary of the Invention
[0004] The present application provides a current limiting management method, system and storage medium based on concurrency control to solve the problem that the fixed rules of traditional current limiting methods cannot meet changing needs.
[0005] In a first aspect, the present application provides a current limiting management method based on concurrency control, the method comprising:
[0006] Receive a service request and parse the supplier identifier and service identifier in the service request, and query corresponding current limiting configuration parameters according to the supplier identifier and the service identifier, wherein the current limiting configuration parameters include a maximum concurrent number threshold corresponding to the supplier identifier and the service identifier;
[0007] Obtaining a concurrency limiter instance associated with the supplier identifier and the service identifier, wherein the concurrency limiter instance uses an atomic counter to implement concurrency state tracking;
[0008] Obtaining a permission method for the concurrency limiter instance and allocating an execution permission when the current concurrency number does not exceed the maximum concurrency threshold;
[0009] Dynamically adjust the maximum concurrency threshold of the concurrency limiter instance and update the corresponding current limiting configuration parameters according to the real-time system load;
[0010] The current concurrency number of the concurrency limiter instance and the updated current limiting configuration parameters are registered to the monitoring system to achieve real-time monitoring of the concurrency situation.
[0011] In some embodiments, obtaining a concurrency limiter instance associated with the vendor identifier and the service identifier includes:
[0012] Establishing a corresponding concurrency limiter based on the supplier identifier and the business identifier;
[0013] A global flow limiting policy is implemented for disabled supplier IDs, rejecting all related service requests.
[0014] When a change in the current limiting configuration parameter is detected, a concurrency limiter corresponding to the service identifier is created or updated.
[0015] In some embodiments, the method for licensing a concurrency limiter instance includes:
[0016] Get the current concurrency count value;
[0017] When the current concurrent count value reaches the maximum concurrent count threshold, a signal indicating that the license acquisition has failed is returned; wherein the maximum concurrent count threshold is the maximum number of requests;
[0018] An atomic counter is used to attempt to increase the current concurrent count value by 1, and a permission acquisition success is returned if the operation is successful.
[0019] In some embodiments, dynamically adjusting the maximum concurrency threshold of the concurrency limiter instance includes:
[0020] Establish a monitoring channel for current limiting configuration parameter changes. When changes to the supplier ID and business ID are detected: create a concurrency limiter instance with an initial threshold for the newly added supplier ID and business ID; and clear the current concurrency count value for the deleted supplier ID and business ID.
[0021] Perform a hot update operation on the existing concurrency limiter instance based on the changed vendor ID and business ID, keep the current concurrency count value unchanged, and write the new maximum concurrency threshold.
[0022] In some embodiments, establishing a monitoring channel for current limiting configuration parameter changes includes:
[0023] Obtain the real-time concurrent count value corresponding to each supplier ID and business ID in real time;
[0024] When the real-time concurrent count value is continuously lower than a preset threshold, deleting the corresponding supplier identifier and service identifier in the current limiting configuration parameter;
[0025] When the newly added concurrent count value corresponding to the new supplier identifier and the new service identifier is obtained, the corresponding supplier identifier and service identifier are added to the current limiting configuration parameter.
[0026] In some embodiments, the maximum concurrency threshold is determined by the following formula:
[0027]
[0028] Among them, C max (t) is the calculated maximum concurrent number threshold, C0 is the basic concurrent capacity allowed by the system hardware, α(t) is the time decay factor, which is used to reduce the capacity allocation when the system runs for a long time, L(t) is the current system evaluation load rate, L m is the safety threshold of the system load, and t represents the current time.
[0029] In some embodiments, the method further comprises:
[0030] Based on historical load data, the time decay factor is calculated using the following formula:
[0031]
[0032] Where λ is the decay rate coefficient, t m The time of the most recent system load peak.
[0033] In a second aspect, the present application provides a current limiting management system based on concurrency control, the system comprising:
[0034] A receiving query module, configured to receive a service request, parse a supplier identifier and a service identifier in the service request, and query corresponding flow limiting configuration parameters according to the supplier identifier and the service identifier, wherein the flow limiting configuration parameters include a maximum concurrent number threshold corresponding to the supplier identifier and the service identifier;
[0035] An instance acquisition module, configured to acquire a concurrency limiter instance associated with the supplier identifier and the service identifier, wherein the concurrency limiter instance uses an atomic counter to implement concurrency state tracking;
[0036] a license method acquisition module, configured to acquire the license method of the concurrency limiter instance and allocate execution permission when the current concurrency number does not exceed the maximum concurrency number threshold;
[0037] A dynamic adjustment module, configured to dynamically adjust the maximum concurrency threshold of the concurrency limiter instance and update corresponding current limiting configuration parameters according to real-time system load;
[0038] The monitoring module is used to register the current concurrency number and updated current limiting configuration parameters of the concurrency limiter instance to the monitoring system to achieve real-time monitoring of the concurrency situation.
[0039] In a third aspect, an electronic device is provided, comprising a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus;
[0040] Memory for storing computer programs;
[0041] The processor is used to implement the steps of the current limiting management method based on concurrency control described in any embodiment of the first aspect when executing the program stored in the memory.
[0042] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the current limiting management method based on concurrency control as described in any embodiment of the first aspect are implemented.
[0043] The above technical solution provided by the embodiment of the present application has the following advantages compared with the existing technology: 1. Flexible concurrency control: By querying the corresponding current limiting configuration parameters according to different supplier identifiers and business identifiers, different concurrency control strategies can be set for different business scenarios and suppliers to achieve flexible current limiting management. Compared with the traditional fixed rule current limiting method, it can be dynamically adjusted according to actual needs and different business characteristics. 2. Accurate concurrency state tracking: The use of atomic counters to track the concurrency state can efficiently and accurately control the number of concurrencies. The atomic counter can ensure the thread safety of concurrency control operations, thereby avoiding data competition and concurrency errors in high concurrency situations, and improving system stability and performance. 3. Real-time dynamic adjustment of concurrency control strategy: This allows the concurrency control strategy to be dynamically adjusted according to the real-time system load during operation, and the maximum concurrency threshold is updated. This feature enables the system to automatically adapt to load fluctuations, avoid system crashes due to overload, or idle resources due to too low concurrency limits, and further improve resource utilization efficiency and response speed. 4. Efficient monitoring and management: The current concurrency number of the concurrent limiter instance and the updated current limiting configuration parameters are registered to the monitoring system, so that the system can monitor the concurrency situation in real time. It helps operation and maintenance personnel to promptly identify concurrency bottlenecks, traffic anomalies and other problems, and conduct effective intervention and optimization to ensure that the system can still operate stably under high-load environments. 5. Improve system scalability and adaptability: Since the current limiting configuration parameters are associated with the supplier ID and business ID, it can support the concurrency management of multiple businesses and suppliers, and the system can be easily expanded to more business scenarios. As the needs of different suppliers and businesses change, the system can quickly adapt and make corresponding adjustments, enhancing the scalability and adaptability of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0045] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0046] Figure 1 A flow chart of a current limiting management method based on concurrency control provided in an embodiment of the present application;
[0047] Figure 2 This is an exemplary flow chart of establishing a monitoring channel for changing current limiting configuration parameters provided by some embodiments of the present application;
[0048] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0049] To make the purpose, technical solutions, and advantages of the embodiments of this application more clear, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0050] Figure 1 A flow chart of a current limiting management method based on concurrency control provided in an embodiment of the present application. In some embodiments, Figure 1 The process shown can be executed by an electronic device, such as Figure 1 As shown, the process may include the following operations.
[0051] Step 101: Receive a service request, parse the supplier identifier and service identifier in the service request, and query corresponding current limiting configuration parameters according to the supplier identifier and service identifier.
[0052] The current limiting configuration parameters include a maximum concurrent number threshold corresponding to a supplier identifier and a service identifier.
[0053] A supplier ID is a unique identifier used to identify a supplier. This identifier can be used to distinguish between different suppliers or service providers. For example, on an e-commerce platform, a supplier ID can be a merchant ID or store name, such as "Vendor123" for a specific supplier.
[0054] A business identifier is a unique tag used to identify a business type or business scenario. It helps differentiate different business needs, such as different service or product types, from the same vendor. For example, in an online reservation system, the business identifier might be "hotel_booking" for hotel reservations or "flight_booking" for flight reservations.
[0055] Rate limiting configuration parameters are system settings used to control concurrent traffic, including the maximum concurrent request threshold for each provider or service type. For example, for the "hotel_booking" service of the "Vendor123" provider, the rate limiting configuration parameters might include "Maximum concurrent request threshold = 100," indicating that the service allows a maximum of 100 concurrent requests at any one time.
[0056] In some embodiments, when a service request is received, the supplier identifier and service identifier in the service request are first parsed, and then the relevant current limiting configuration parameters are searched in the system database through the supplier identifier and service identifier.
[0057] In some embodiments, the maximum concurrency threshold can be determined by the following formula (1):
[0058]
[0059] Among them, C max (t) is the calculated maximum concurrent number threshold, C0 is the basic concurrent capacity allowed by the system hardware, α(t) is the time decay factor, which is used to reduce the capacity allocation when the system runs for a long time, L(t) is the current system evaluation load rate, L m is the safety threshold of the system load, and t represents the current time.
[0060] In some embodiments, the time decay factor may be calculated based on historical load data using the following formula (2).
[0061]
[0062] Where λ is the decay rate coefficient, t m The time of the most recent system load peak.
[0063] Historical load data refers to system load information collected during past periods of time.
[0064] Step 102: Obtain a concurrency limiter instance associated with the supplier identifier and the service identifier. The concurrency limiter instance uses an atomic counter to implement concurrency state tracking.
[0065] A concurrency limiter instance is an object used to manage concurrent requests. It can control the number of concurrent requests based on the set maximum concurrency threshold. The concurrency limiter instance internally implements an atomic counter to track the current concurrency.
[0066] An atomic counter is a thread-safe counter that supports concurrent operations, ensuring that errors will not occur when multiple threads modify it simultaneously. Atomic counters can accurately record the current concurrent state and avoid data conflicts.
[0067] In some embodiments, based on the obtained supplier identifier and business identifier, a concurrency limiter instance associated with the identifier can be created. The concurrency limiter instance can track the concurrency situation in real time based on the current concurrency count to ensure that the maximum concurrency count threshold is not exceeded.
[0068] In some embodiments, obtaining the concurrency limiter instance associated with the vendor identifier and the service identifier may include the following operations.
[0069] S10: Establish a corresponding concurrency limiter based on the supplier identifier and the service identifier.
[0070] In some embodiments, a corresponding concurrency limiter can be generated for each pair of identifiers based on the vendor identifier and the business identifier. The generated concurrency limiter can set the initial configuration based on the maximum concurrency threshold specific to the vendor and business. For example, "Vendor123" and "hotel_booking" can create a concurrency limiter with an initial concurrency limit of 100, and the concurrency limiter can handle requests related to the business. For example, when the system receives a request, it can parse the vendor identifier "Vendor123" and the business identifier "hotel_booking", and create a concurrency limiter instance for the business based on these two identifiers, limiting the maximum number of concurrent requests allowed to 100.
[0071] S11: Execute the global flow limiting policy for the disabled supplier ID and reject all related business requests.
[0072] The disabled status means that the supplier ID is restricted or disabled in the system, which means that all business requests from this supplier will be rejected and no longer processed. For example, if "Vendor123" is disabled for some reason, the system will set its ID to disabled and reject all business requests from this supplier.
[0073] The global throttling policy is a unified restriction policy applied by the system to all requests. When a vendor is disabled, the system automatically applies this policy, rejecting all service requests from that vendor until the disablement is lifted. For example, if the vendor "Vendor123" is disabled, the system will apply the global throttling policy to all requests related to that vendor, rejecting all requests related to that vendor.
[0074] In some embodiments, upon detecting that a vendor ID is disabled, the system can apply a global rate limiting policy to directly deny all service requests associated with that vendor. This action will prevent these requests from continuing, regardless of the specific concurrency threshold for that service.
[0075] S12: When a change in the current limiting configuration parameter is detected, a concurrency limiter corresponding to the service identifier is created or updated.
[0076] Changing the current limiting configuration parameters refers to adjusting the concurrency control configuration parameters during system operation. Changes can be made based on real-time load, business needs, or other external conditions. For example, if the system detects an increase in the load of the "hotel_booking" service for "Vendor123," the maximum concurrency threshold might be adjusted from 100 to 200 to support more concurrent requests.
[0077] In some embodiments, when the system detects a change in the rate limiting configuration parameters, it can update the associated concurrency limiter. If a concurrency limiter instance already exists for the service, its rate limiting configuration parameters are updated; if a concurrency limiter has not yet been created for the service, a new concurrency limiter is created based on the new rate limiting configuration. For example, suppose the maximum concurrency threshold for the "hotel_booking" service of "Vendor123" was originally 100, but the system detects an increase in load and needs to update the maximum concurrency threshold to 150. The system will update the original concurrency limiter instance, or if there is no concurrency limiter instance for the service, it will create a new concurrency limiter and set its maximum concurrency threshold to 150.
[0078] In this embodiment, first, a concurrency limiter is created based on the vendor ID and the business ID to ensure accurate concurrency control for each business scenario; second, a global rate limiting policy is implemented for disabled vendor IDs to reject all business requests from that vendor; finally, when the rate limiting configuration parameters change, the concurrency limiter instance is updated in a timely manner to ensure that the system's concurrency control policy is always consistent with the actual load and business requirements.
[0079] Step 103: Obtain the permission method of the concurrency limiter instance, and allocate execution permission when the current concurrency number does not exceed the maximum concurrency threshold.
[0080] The grant method is a method in the concurrency limiter instance that determines whether the current request can obtain a permission to execute. Permission is granted based on whether the current concurrency threshold exceeds the maximum concurrency threshold. For example, the grant method could be "tryAcquire()," which checks whether the current concurrency threshold is less than the maximum concurrency threshold. If so, it grants a permission, allowing the request to proceed.
[0081] In some embodiments, the electronic device may call the permission method of the concurrency limiter instance to check whether the current concurrency count is below the maximum concurrency count threshold. If it is below the threshold, the request is allowed to proceed and the concurrency count is incremented. If it is above the threshold, the request is rejected or queued.
[0082] In some embodiments, the licensing method of the concurrency limiter instance includes: obtaining the current concurrency count value; returning a license acquisition failure when the current concurrency count value reaches the maximum concurrency threshold; wherein the maximum concurrency threshold is the maximum number of requests; using an atomic counter to attempt to increase the current concurrency count value by 1, and returning a license acquisition success when the operation is successful.
[0083] The current concurrency count is the number of concurrent requests currently being processed for a specific business or service in the system. This value is tracked using a counter. For example, if there are 50 requests currently being processed for the "hotel_booking" business of "Vendor123," the current concurrency count is 50.
[0084] In some embodiments, when obtaining a license, the current concurrency count value may be read from the concurrency limiter instance.
[0085] The maximum concurrency threshold is the maximum number of requests that the concurrency limiter allows. When the current concurrency count reaches or exceeds this value, no new requests will be accepted and a license acquisition failure response will be returned.
[0086] The current concurrency count increments by 1. Whenever a new request is granted, the atomic counter increments the current concurrency count by 1, indicating that a new request has been processed. For example, suppose the current concurrency count is 50 and the system receives a new request. When the system attempts to increment the current concurrency count by 1, the atomic counter increments the counter from 50 to 51, indicating that a new request has been processed.
[0087] When the system decides to allow a new request, it first attempts to increase the current concurrent count value through the atomic counter. If the operation is successful (that is, the current concurrent count value increases by 1 and does not reach the maximum threshold), it returns "Permission obtained successfully" and allows the request to continue processing. For example, suppose the current concurrent count value is 50, and the system attempts to increase the count value by 1 through the atomic counter. If the operation is successful and the count value is updated to 51 (less than the maximum concurrent count threshold of 100), the system returns "Permission obtained successfully" and allows the request to continue processing.
[0088] This embodiment can ensure that the system controls traffic when the number of concurrent requests is high, ensuring that the requests do not exceed the maximum carrying capacity of the system, and at the same time provides an efficient concurrency control mechanism.
[0089] Step 104: Dynamically adjust the maximum concurrency threshold of the concurrency limiter instance and update the corresponding current limiting configuration parameters according to the real-time system load.
[0090] System load refers to the current usage of system resources and can be expressed through indicators such as CPU usage and memory usage. For example, if the system CPU usage reaches 90%, the system load is high and the concurrency limit policy needs to be adjusted; if the CPU usage is 20%, the system load is low.
[0091] In some embodiments, the maximum concurrency threshold of a concurrency limiter instance can be dynamically adjusted based on the real-time system load. If the system load is low, the maximum concurrency threshold can be increased to allow more concurrent requests; if the load is too high, the maximum concurrency threshold can be decreased to prevent excessive concurrent requests from causing system crashes.
[0092] In some embodiments, dynamically adjusting the maximum concurrency threshold of the concurrency limiter instance may include the following operations.
[0093] S20, establish a monitoring channel for changes in current limiting configuration parameters. When changes to the supplier ID and business ID are monitored: create a concurrency limiter instance with an initial threshold for the newly added supplier ID and the newly added business ID; and clear the current concurrency count value for the deleted supplier ID and the deleted business ID.
[0094] The throttling configuration parameter change monitoring channel is a mechanism used to monitor system configuration changes. It can monitor and capture any changes related to the throttling configuration in real time, such as changes to the supplier ID and business ID. For example, if the system has a channel specifically monitoring changes to the "supplier ID" and "business ID," when a supplier's business ID is added or removed, this channel will capture these changes and notify the system to take appropriate action.
[0095] In some embodiments, a monitoring channel may be created during system initialization to monitor changes in current limiting configuration parameters. Once a change in a vendor identifier or a business identifier is detected, the system triggers a corresponding action.
[0096] A newly added supplier ID is a supplier ID that appears in the system for the first time. This can be a newly added supplier or a supplier ID that has not been previously registered. For example, on an e-commerce platform, "Vendor456" is a newly added supplier ID.
[0097] A newly added service identifier is the identifier for a specific service type or service scenario that appears for the first time in the system. This could be a new service module or a new service type for an existing vendor. For example, if "Vendor456" adds the "flight_booking" service, "flight_booking" would be the newly added service identifier.
[0098] The initial threshold value is the default maximum number of concurrent users set for the concurrent limiter instance created for the newly added supplier ID and business ID.
[0099] In some embodiments, when new vendor and service identifiers are detected, corresponding concurrency limiter instances can be created for these newly added identifiers, and an initial maximum concurrency threshold can be set. The concurrency limiter instance can track the number of concurrent requests for the service and limit the maximum concurrency. For example, assuming that the "flight_booking" service of "Vendor456" is newly added, the system will create a new concurrency limiter instance and set the initial maximum concurrency threshold to 100, starting to limit the concurrent requests for the corresponding service of "Vendor456".
[0100] A deleted supplier ID refers to a supplier ID that no longer exists in the system. This may be due to the supplier's withdrawal, deregistration, or other reasons that make the ID no longer valid.
[0101] A deleted service ID is the ID of a service type that is no longer available or has been deleted. This can occur when a service is discontinued or its type is changed. For example, if Vendor123's "hotel_booking" service is revoked for some reason, "hotel_booking" becomes the deleted service ID.
[0102] The current concurrency count reset operation clears the counter in the concurrency limiter for a service or provider, resetting its concurrent request count to zero. This reset operation can be performed when the service or provider ID is deleted to prevent redundant concurrent requests from continuing to occupy resources.
[0103] In some embodiments, when it is detected that a vendor identifier or a service identifier is deleted, the concurrency count value of the concurrency limiter instance associated with these identifiers may be cleared.
[0104] S21, performing a hot update operation on the existing concurrency limiter instance according to the changed supplier identifier and business identifier, keeping the current concurrency count value unchanged, and writing a new maximum concurrency threshold.
[0105] A hot update operation refers to updating certain configurations or instances while the system is running, without restarting or interrupting service. For concurrency limiters, a hot update operation means updating the concurrency limiter configuration without affecting current services.
[0106] Keeping the current concurrency counter unchanged means that when updating the concurrency limiter, the number of requests already in progress will not be changed. This ensures that the concurrency counter remains at its current state and avoids resetting the concurrency count.
[0107] In some embodiments, when the system detects a change in the vendor identifier or the business identifier, a hot update operation is performed on the existing concurrency limiter instance.
[0108] Step 105: register the current concurrency number of the concurrency limiter instance and the updated current limiting configuration parameters to the monitoring system to achieve real-time monitoring of the concurrency situation.
[0109] The monitoring system is a tool that tracks and records system operating status in real time, used to monitor key metrics such as concurrency status and resource utilization. For example, in the monitoring system, you can view information such as the current concurrency count, maximum concurrency threshold, and system load for the "hotel_booking" service of "Vendor123" in real time.
[0110] In some embodiments, the current concurrency count and updated maximum concurrency threshold of the concurrency limiter instance can be registered in a monitoring system. The monitoring system can update and display this information in real time, helping operations personnel to promptly understand system status and make adjustments. For example, if the current concurrency count of the "Vendor123" service is 10 and the maximum concurrency threshold is updated to 150, the system can update this information to the monitoring system, allowing operations personnel to view the current concurrency status and make further decisions.
[0111] In this embodiment, through precise concurrency control, flexible threshold adjustment and real-time monitoring, the concurrent processing capability of the system is improved, and resource utilization and system stability are optimized in different business scenarios.
[0112] Figure 2 This is an exemplary flow chart of establishing a monitoring channel for changing current limiting configuration parameters provided by some embodiments of the present application. In some embodiments, Figure 2 The process shown can be executed by an electronic device, such as Figure 2 As shown, the process may include the following operations.
[0113] Step 201: Obtain the real-time concurrent count value corresponding to each supplier ID and business ID in real time.
[0114] In some embodiments, the real-time concurrent count value of each supplier identifier and service identifier may be continuously monitored, thereby obtaining the real-time concurrent count value corresponding to each supplier identifier and service identifier in real time.
[0115] Step 202: When the real-time concurrent count value is continuously lower than a preset threshold, the corresponding supplier identifier and service identifier are deleted from the current limiting configuration parameters.
[0116] The preset threshold is an upper limit on the number of concurrent requests set in advance. When the real-time concurrent count value of a business or supplier falls below the threshold, it can be considered that the load of the business or supplier is insufficient to maintain the existence of the concurrency limiter, and therefore a deletion operation may be performed.
[0117] The delete operation removes the concurrency limiter instance for a service or provider when its real-time concurrency count remains low for a long period of time. This operation frees up system resources and prevents unnecessary configurations.
[0118] In some embodiments, when the system detects that the real-time concurrent count value of a certain business or supplier is continuously lower than a preset threshold, a deletion operation will be triggered.
[0119] Step 203: When the newly added concurrent count value corresponding to the new supplier ID and the new service ID is obtained, the corresponding supplier ID and service ID are added to the current limiting configuration parameters.
[0120] A new supplier ID refers to a supplier ID that appears newly in the system.
[0121] A new business logo refers to a completely new business or service logo, which can be a newly launched business module or a new business type added by an existing supplier.
[0122] The new concurrent count value is the number of concurrent requests associated with the new supplier ID and business ID. The system can set and monitor the concurrent count value for the newly added supplier and business.
[0123] In some embodiments, when the system detects a new vendor ID and business ID and obtains the corresponding newly added concurrency count value, a concurrency limiter instance can be added for the vendor ID and business ID in the current limiting configuration parameters, and its newly added concurrency count value can be recorded.
[0124] Some embodiments of the present application further provide a current limiting management system based on concurrency control, the system comprising:
[0125] A receiving query module, configured to receive a service request, parse a supplier identifier and a service identifier in the service request, and query corresponding flow limiting configuration parameters according to the supplier identifier and the service identifier, wherein the flow limiting configuration parameters include a maximum concurrent number threshold corresponding to the supplier identifier and the service identifier;
[0126] An instance acquisition module, configured to acquire a concurrency limiter instance associated with the supplier identifier and the service identifier, wherein the concurrency limiter instance uses an atomic counter to implement concurrency state tracking;
[0127] a license method acquisition module, configured to acquire the license method of the concurrency limiter instance and allocate execution permission when the current concurrency number does not exceed the maximum concurrency number threshold;
[0128] A dynamic adjustment module, configured to dynamically adjust the maximum concurrency threshold of the concurrency limiter instance and update corresponding current limiting configuration parameters according to real-time system load;
[0129] The monitoring module is used to register the current concurrency number and updated current limiting configuration parameters of the concurrency limiter instance to the monitoring system to achieve real-time monitoring of the concurrency situation.
[0130] like Figure 3 As shown, an embodiment of the present application provides an electronic device, including a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114.
[0131] Memory 113, for storing computer programs;
[0132] In one embodiment of the present application, the processor 111 is configured to implement the method for current limiting management based on concurrency control provided by any of the aforementioned method embodiments when executing a program stored in the memory 113, including:
[0133] Receive a service request and parse the supplier identifier and service identifier in the service request, and query corresponding current limiting configuration parameters according to the supplier identifier and the service identifier, wherein the current limiting configuration parameters include a maximum concurrent number threshold corresponding to the supplier identifier and the service identifier;
[0134] Obtaining a concurrency limiter instance associated with the supplier identifier and the service identifier, wherein the concurrency limiter instance uses an atomic counter to implement concurrency state tracking;
[0135] Obtaining a permission method for the concurrency limiter instance and allocating an execution permission when the current concurrency number does not exceed the maximum concurrency threshold;
[0136] Dynamically adjust the maximum concurrency threshold of the concurrency limiter instance and update the corresponding current limiting configuration parameters according to the real-time system load;
[0137] The current concurrency number of the concurrency limiter instance and the updated current limiting configuration parameters are registered to the monitoring system to achieve real-time monitoring of the concurrency situation.
[0138] An embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the current limiting management method based on concurrency control provided in any of the aforementioned method embodiments are implemented.
[0139] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.
[0140] The foregoing description is intended only to provide specific embodiments of the present invention, which will enable those skilled in the art to understand and implement the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention is not intended to be limited to the embodiments shown herein, but is intended to be accorded the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A current limiting management method based on concurrency control, characterized in that: The method comprises: Receive a service request and parse the supplier identifier and service identifier in the service request, and query corresponding current limiting configuration parameters according to the supplier identifier and the service identifier, wherein the current limiting configuration parameters include a maximum concurrent number threshold corresponding to the supplier identifier and the service identifier; Obtaining a concurrency limiter instance associated with the supplier identifier and the service identifier, wherein the concurrency limiter instance uses an atomic counter to implement concurrency state tracking; Obtaining a permission method for the concurrency limiter instance and allocating an execution permission when the current concurrency number does not exceed the maximum concurrency threshold; Dynamically adjust the maximum concurrency threshold of the concurrency limiter instance and update the corresponding current limiting configuration parameters according to the real-time system load; The current concurrency number of the concurrency limiter instance and the updated current limiting configuration parameters are registered to the monitoring system to achieve real-time monitoring of the concurrency situation.
2. The method according to claim 1, characterized in that The acquiring of a concurrency limiter instance associated with the supplier identifier and the service identifier includes: Establishing a corresponding concurrency limiter based on the supplier identifier and the business identifier; A global flow limiting policy is implemented for disabled supplier IDs, rejecting all related service requests. When a change in the current limiting configuration parameter is detected, a concurrency limiter corresponding to the service identifier is created or updated.
3. The method according to claim 1, characterized in that The permission method of the concurrency limiter instance includes: Get the current concurrency count value; When the current concurrent count value reaches the maximum concurrent count threshold, a signal indicating that the license acquisition has failed is returned; wherein the maximum concurrent count threshold is the maximum number of requests; An atomic counter is used to attempt to increase the current concurrent count value by 1, and a permission acquisition success is returned if the operation is successful.
4. The method according to claim 1, wherein The dynamically adjusting the maximum concurrency threshold of the concurrency limiter instance includes: Establish a monitoring channel for current limiting configuration parameter changes. When changes to the supplier ID and business ID are detected: create a concurrency limiter instance with an initial threshold for the newly added supplier ID and business ID; and clear the current concurrency count value for the deleted supplier ID and business ID. Perform a hot update operation on the existing concurrency limiter instance based on the changed vendor ID and business ID, keep the current concurrency count value unchanged, and write the new maximum concurrency threshold.
5. The method according to claim 4, characterized in that The step of establishing a monitoring channel for current limiting configuration parameter changes includes: Obtain the real-time concurrent count value corresponding to each supplier ID and business ID in real time; When the real-time concurrent count value is continuously lower than a preset threshold, deleting the corresponding supplier identifier and service identifier in the current limiting configuration parameter; When the newly added concurrent count value corresponding to the new supplier identifier and the new service identifier is obtained, the corresponding supplier identifier and service identifier are added to the current limiting configuration parameter.
6. The method according to claim 1, characterized in that The maximum concurrent number threshold is determined by the following formula: Among them, C max (t) is the calculated maximum concurrent number threshold, C0 is the basic concurrent capacity allowed by the system hardware, α(t) is the time decay factor, which is used to reduce the capacity allocation when the system runs for a long time, L(t) is the current system evaluation load rate, L m is the safety threshold of the system load, and t represents the current time.
7. The method according to claim 6, characterized in that The method further comprises: Based on historical load data, the time decay factor is calculated using the following formula: Where λ is the decay rate coefficient, t m The time of the most recent system load peak.
8. A current limiting management system based on concurrent control, characterized in that: The system comprises: A receiving query module, configured to receive a service request, parse a supplier identifier and a service identifier in the service request, and query corresponding flow limiting configuration parameters according to the supplier identifier and the service identifier, wherein the flow limiting configuration parameters include a maximum concurrent number threshold corresponding to the supplier identifier and the service identifier; An instance acquisition module, configured to acquire a concurrency limiter instance associated with the supplier identifier and the service identifier, wherein the concurrency limiter instance uses an atomic counter to implement concurrency state tracking; a license method acquisition module, configured to acquire the license method of the concurrency limiter instance and allocate execution permission when the current concurrency number does not exceed the maximum concurrency number threshold; A dynamic adjustment module, configured to dynamically adjust the maximum concurrency threshold of the concurrency limiter instance and update corresponding current limiting configuration parameters according to real-time system load; The monitoring module is used to register the current concurrency number and updated current limiting configuration parameters of the concurrency limiter instance to the monitoring system to achieve real-time monitoring of the concurrency situation.
9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; Memory for storing computer programs; The processor is configured to implement the steps of the current limiting management method based on concurrency control according to any one of claims 1 to 7 when executing a program stored in the memory.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the current limiting management method based on concurrency control are implemented.