Traffic limiting method, apparatus, device, and storage medium
By identifying the type of accessing device and processing access requests accordingly, the problem of insufficient flexibility in traffic limiting in the token bucket algorithm is solved, enabling more flexible load management and service continuity.
Patent Information
- Application Number
- CN202411418230.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-11
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2044-10-11
AI Technical Summary
The existing token bucket algorithm is not very flexible in traffic limiting, which may result in users who are already in service being denied access, affecting the normal operation of the server.
By determining the device type of the accessing device, the access request is processed according to the device type, including determining the existence and validity of the access token and historical access information, and allocating the access request to different queues for processing.
It improves the flexibility of traffic limiting, ensures that devices that have already been accessed can continue to receive services, and optimizes server load management.
Smart Images

Figure CN119254702B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, device and storage medium for limiting traffic flow. Background Technology
[0002] With the rapid development of the Internet, the scale of users and their needs are also growing rapidly. In some scenarios, it is necessary to limit traffic to ensure that the server can operate normally. For example, when the number of users accessing the server is too high at a certain moment, it may cause the server to crash.
[0003] In related technologies, the token bucket algorithm is commonly used to limit the access of devices. The token bucket algorithm generates tokens in a preset token bucket (a logical container used to store tokens). The system will only issue a token to the accessing device when there is a token in the token bucket. The server will only allow the access request of the accessing device after confirming that the accessing device holds a token; otherwise, it will reject the request, thereby achieving the effect of traffic limiting.
[0004] However, in the above method, when there are no tokens in the token bucket, users who are already in the service state may be denied access, resulting in poor flexibility of traffic limiting. Summary of the Invention
[0005] This application provides a traffic limiting method, apparatus, device, and storage medium to solve the problem of poor accuracy in user type determination.
[0006] In a first aspect, this application provides a traffic limiting method applied to a first server, the method comprising:
[0007] Receive a first access request sent by a first device, the first access request being used to request access to the target system;
[0008] Based on the access request, determine the current access volume of the target system;
[0009] If the current access volume is greater than or equal to the first threshold, then the device type of the first device is determined according to the first access request. The device type is either a first type or a second type. The first type is used to indicate that the first device has accessed the target system within a preset time period before the current time, and the second type is used to indicate that the first device has not accessed the target system within a preset time period before the current time.
[0010] The first access request is processed according to the device type of the first device.
[0011] In one possible design, determining the device type of the first device based on the first access request includes:
[0012] Determine whether the first access request includes the first access token;
[0013] If so, the device type of the first device is determined based on the first access token and the token list corresponding to the first server;
[0014] If not, then the device type of the first device is determined to be the second type.
[0015] In one possible design, the device type of the first device is determined based on the first access token and the token list corresponding to the first server, including:
[0016] Determine whether the first access token is included in the token list;
[0017] If so, obtain the expiration time of the first access token, and determine the device type of the first device based on the expiration time and the current time;
[0018] If not, then obtain historical access information from the first access request, and determine the device type of the first device based on the historical access information.
[0019] In one possible design, the device type of the first device is determined based on the token expiration time and the current time, including:
[0020] If the token expires after the current time, then the device type of the first device is determined to be the first type;
[0021] If the token expires before the current time, then the device type of the first device is determined to be the second type.
[0022] In one possible design, determining the device type of the first device based on the historical access information includes:
[0023] Based on the historical access information, determine the time when the first device last accessed the target system;
[0024] If the time difference between the access time and the current time is greater than or equal to a preset duration, then the device type of the first device is determined to be the second type;
[0025] If the time difference between the access time and the current time is less than the preset duration, then the second server accessed by the first device when it last accessed the target system is determined from the historical access information, and a switching request is sent to the second server. The switching request is used to request the second server to process the first access request.
[0026] In one possible design, the first access request is processed according to the device type of the first device, including:
[0027] Obtain the remaining access count for the target system;
[0028] If the remaining access volume is greater than 0, then the first access request is processed to enable the first device to access the target system;
[0029] If the remaining access count is 0, then the first access request is cached according to the device type of the first device to restrict the first device from accessing the target system.
[0030] In one possible design, the first access request is cached based on the device type of the first device, including:
[0031] If the device type of the first device is the first type, then the first access request is added to the first queue, which is used to store access requests sent by the first type of device that are restricted from accessing the target system;
[0032] If the device type of the first device is the second type, then the first access request is added to the second queue, which is used to store access requests sent by devices of the second type that restrict access to the target system.
[0033] In one possible design, the method further includes:
[0034] When the remaining access count changes from 0 to N, a first number M of access requests existing in the first queue is determined, where N is a positive integer and M is an integer;
[0035] If M is greater than or equal to N, then control the terminal devices corresponding to the first N access requests to access the target system;
[0036] If M is less than N, then control the terminal devices corresponding to the M access requests in the first queue to access the target system, and control the terminal devices corresponding to the first NM access requests in the second queue to access the target system.
[0037] Secondly, this application provides a flow limiting device, comprising: a receiving module, a first determining module, a second determining module, and a processing module, wherein,
[0038] The receiving module is used to receive a first access request sent by the first device, the first access request being used to request access to the target system;
[0039] The first determining module is used to determine the current access volume of the target system based on the access request;
[0040] The second determining module is used to determine the device type of the first device based on the first access request if the current access volume is greater than or equal to the first threshold. The device type is either a first type or a second type. The first type is used to indicate that the first device has accessed the target system within a preset time period before the current time, and the second type is used to indicate that the first device has not accessed the target system within a preset time period before the current time.
[0041] The processing module is used to process the first access request according to the device type of the first device.
[0042] In one possible design, the second determining module is specifically used for:
[0043] Determine whether the first access request includes the first access token;
[0044] If so, the device type of the first device is determined based on the first access token and the token list corresponding to the first server;
[0045] If not, then the device type of the first device is determined to be the second type.
[0046] In one possible design, the second determining module is specifically used for:
[0047] Determine whether the first access token is included in the token list;
[0048] If so, obtain the expiration time of the first access token, and determine the device type of the first device based on the expiration time and the current time;
[0049] If not, then obtain historical access information from the first access request, and determine the device type of the first device based on the historical access information.
[0050] In one possible design, the second determining module is specifically used for:
[0051] If the token expires after the current time, then the device type of the first device is determined to be the first type;
[0052] If the token expires before the current time, then the device type of the first device is determined to be the second type.
[0053] In one possible design, the second determining module is specifically used for:
[0054] Based on the historical access information, determine the time when the first device last accessed the target system;
[0055] If the time difference between the access time and the current time is greater than or equal to a preset duration, then the device type of the first device is determined to be the second type;
[0056] If the time difference between the access time and the current time is less than the preset duration, then the second server accessed by the first device when it last accessed the target system is determined from the historical access information, and a switching request is sent to the second server. The switching request is used to request the second server to process the first access request.
[0057] In one possible design, the processing module is specifically used for:
[0058] Obtain the remaining access count for the target system;
[0059] If the remaining access volume is greater than 0, then the first access request is processed to enable the first device to access the target system;
[0060] If the remaining access count is 0, then the first access request is cached according to the device type of the first device to restrict the first device from accessing the target system.
[0061] In one possible design, the processing module is specifically used for:
[0062] If the device type of the first device is the first type, then the first access request is added to the first queue, which is used to store access requests sent by the first type of device that are restricted from accessing the target system;
[0063] If the device type of the first device is the second type, then the first access request is added to the second queue, which is used to store access requests sent by devices of the second type that restrict access to the target system.
[0064] In one possible design, the processing module further includes a third determining module, a first control module, and a second control module:
[0065] The third determining module is used to determine, when the remaining access quantity switches from 0 to N, the first number M of access requests existing in the first queue, where N is a positive integer and M is an integer;
[0066] The first control module is configured to, if M is greater than or equal to N, control the terminal devices corresponding to the first N access requests to access the target system;
[0067] The second control module is configured to, if M is less than N, control the terminal devices corresponding to the M access requests in the first queue to access the target system, and control the terminal devices corresponding to the first NM access requests in the second queue to access the target system.
[0068] Thirdly, embodiments of this application provide an electronic device, including: at least one processor and a memory; the memory stores computer-executable instructions; the at least one processor executes the computer-executable instructions stored in the memory, causing the at least one processor to perform the flow limiting method as described in the first aspect above and various possible designs of the first aspect.
[0069] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the flow limiting method described in the first aspect and various possible designs of the first aspect.
[0070] Fifthly, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the traffic limiting method described in the first aspect above and various possible designs of the first aspect.
[0071] The traffic limiting method, apparatus, device, and storage medium provided in this application determine whether traffic limiting is required based on the current access volume after the server receives an access request. If the current access volume is greater than or equal to a first threshold, it indicates that traffic limiting is required. The device type of the accessing device can be determined based on the access request, and the processing method of the access request can be determined based on the device type of the accessing device, thereby improving the flexibility of traffic limiting. Attached Figure Description
[0072] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0073] Figure 1 This is a schematic diagram of the system architecture provided for an embodiment of this application;
[0074] Figure 2 A flowchart illustrating a traffic limiting method provided in an embodiment of this application;
[0075] Figure 3 A schematic diagram of the visual operation window of the target system provided in the embodiments of this application;
[0076] Figure 4 A schematic diagram illustrating the process of determining the device type provided in the embodiments of this application;
[0077] Figure 5 A schematic diagram illustrating the process of processing access requests provided in an embodiment of this application;
[0078] Figure 6 This is a schematic diagram of the structure of a flow limiting device provided in an embodiment of this application;
[0079] Figure 7 A schematic diagram of another flow limiting device provided in the embodiments of this application;
[0080] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0081] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0082] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0083] The collection, storage, use, processing, transmission, provision, and disclosure of financial data or user data involved in the technical solution of this application all comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0084] It should be noted that in the embodiments of this application, certain software, components, models and other existing solutions in the industry may be mentioned. These should be regarded as exemplary and are only intended to illustrate the feasibility of implementing the technical solution of this application. However, it does not mean that the applicant has used or necessarily used the solution.
[0085] To facilitate understanding, the following will be combined with... Figure 1 The system architecture applicable to the embodiments of this application will be described.
[0086] Figure 1 This is a schematic diagram of the system architecture provided for an embodiment of this application. Please refer to [link / reference]. Figure 1 This includes a terminal device 101 and a server 102. The terminal device 101 can be a user's local device, through which the user can send access requests to the server. The server 102 can receive access requests sent by the terminal device 101 and provide services to the terminal device 101.
[0087] In related technologies, the token bucket algorithm is commonly used for rate limiting of accessing devices. The token bucket algorithm generates tokens in a pre-set token bucket. A token is only issued to an accessing device when it exists in the bucket. The server only allows access after recognizing the accessing device carrying a token; otherwise, it rejects the access request, thus achieving the effect of traffic limiting. However, in this method, when there are no tokens in the token bucket, users already in a service state may also be denied access, resulting in poor flexibility in traffic limiting.
[0088] To address the aforementioned technical issues, in this embodiment of the application, when the server receives an access request, it determines whether traffic limiting is required based on the current access volume. If the current access volume is greater than or equal to a first threshold, it indicates that traffic limiting is required. The device type of the accessing device can be determined based on the access request, and the processing method of the access request can be determined based on the device type of the accessing device, thereby improving the flexibility of traffic limiting.
[0089] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.
[0090] Figure 2 This is a flowchart illustrating a traffic limiting method provided in an embodiment of this application. Please refer to... Figure 2 As shown, the method may include the following steps:
[0091] S201, Receive the first access request sent by the first device.
[0092] The execution entity in this application embodiment can be a server or a traffic limiting device installed in the server. The traffic limiting device can be implemented by software or by a combination of software and hardware.
[0093] The first device can refer to the user's terminal device, such as the user's computer, mobile phone, tablet, etc.
[0094] The first device can contain a target system. The visual operation interface of the target system can have a "login" control. Users can generate a first access request by clicking the "login" control. The first access request is used to request access to the target system.
[0095] Below, in conjunction with Figure 3 The visual operation window of the target system is explained through specific examples.
[0096] Figure 3 For a schematic diagram of the visual operation window of the target system provided in the embodiments of this application, please refer to [link / reference]. Figure 3 It includes a username input module, a password input module, and a "login" control for the target system. Users can enter their username in the username input module and their password in the password input module. Users can generate the first access request by clicking the "login" control.
[0097] S202. Determine the current access volume of the target system based on the access request.
[0098] Retrieve all access requests within a preset time period and determine the total number of access requests within that time period as the current access count. The preset time period can be any preset time before the current time and the current time itself. Access requests can originate from other devices and are used to request access to the target system.
[0099] For example, assuming the preset time period is the period between the moment one second before the current moment and the current moment, and a total of 100 access requests are received from accessing devices within the preset time period, then the current access count is 100.
[0100] S203. If the current number of visits is greater than or equal to the first threshold, then determine the device type of the first device based on the first access request.
[0101] The device type can be either a first type or a second type. The first type indicates that the first device has accessed the target system within a preset time period before the current time, while the second type indicates that the first device has not accessed the target system within the preset time period before the current time.
[0102] The device type of the first device can be determined as follows: obtain the current time, which can refer to the time when the server receives the first access request; determine whether the first device has accessed the target system within a preset time period before the current time. If yes, the device type of the first device is determined to be the first type; if no, the device type of the first device is determined to be the second type.
[0103] For example, assuming the preset duration is 5 minutes, if the first device has accessed the target system within 5 minutes before the current time, then the device type of the first device is type 1; if the first device has not accessed the target system within 5 minutes before the current time, then the device type of the first device is type 2.
[0104] The first threshold can be a value pre-set in the server to determine whether traffic limiting is needed; for example, the first threshold can be 1000. The preset duration can also be a value pre-set in the server to determine the device type; for example, the preset duration can be 3 minutes.
[0105] S204. Process the first access request according to the device type of the first device.
[0106] The first access request can be processed as follows: obtain the remaining access volume corresponding to the target system; if the remaining access volume is greater than 0, perform business processing on the first access request to enable the first device to access the target system; if the remaining access volume is equal to 0, cache the first access request according to the device type of the first device to restrict the first device from accessing the target system.
[0107] The remaining access volume can be determined as follows: Based on the first threshold, the maximum rate limit can be determined, which can be the first threshold divided by the first preset ratio; Based on the maximum rate limit and the current access volume, the remaining access volume can be determined, which can be the difference between the maximum rate limit and the current access volume.
[0108] For example, assuming the first threshold is 80, the first preset ratio is 80%, and the current number of visits is 90, then the maximum rate limit can be determined to be 100. Based on the maximum rate limit and the current number of visits, the remaining number of visits can be determined to be 10.
[0109] The remaining access volume refers to the number of accesses that the first server can still handle. If the remaining access volume is greater than 0, it means that the first server can still support business processing for the first device. If the remaining access volume is equal to 0, it means that the first server cannot currently process business for the first device and needs to cache the first access request from the first device.
[0110] In this embodiment of the application, when a first access request is received from a first device, it can be determined whether traffic limiting is required based on the current access volume. If the current access volume is greater than or equal to a first threshold, traffic limiting is required. Based on the first access request, the device type of the first device can be determined, which can be a first type or a second type. Based on the device type of the first device, the first access request can be processed. Based on the device type of the first device that sent the first access request, the processing method of the access request is determined, thereby improving the flexibility of traffic limiting.
[0111] Based on any of the above embodiments, the following, in conjunction with Figure 4 The process of determining the type of equipment ( Figure 2 S203 in the embodiments will be described in detail.
[0112] Figure 4 This is a schematic diagram illustrating the process of determining the device type provided in an embodiment of this application. Please refer to... Figure 4 The method may include:
[0113] S401, Obtain the first access request.
[0114] It should be noted that the execution process of S401 above can be found in S201, and will not be repeated here.
[0115] S402. Determine whether the first access request includes the first access token.
[0116] The first access request may include a first access token, which may refer to a digital credential issued by the server to the first device when the first device previously accessed the target system. After recognizing the first access token, the server can provide services to the device.
[0117] The first access token can be used to indicate whether the first device has accessed the target system. That is, if the first access request includes the first access token, it means that the first device has accessed the target system.
[0118] If so, then execute S403.
[0119] If not, then execute S409.
[0120] S403. Obtain the token list corresponding to the first server and determine whether the token list includes the first access token.
[0121] A token list can refer to a collection containing multiple tokens. The first server can store the distributed access tokens in its token list. The first server's token list can be stored in the first server's storage space.
[0122] If so, then execute S404.
[0123] If not, then execute S405.
[0124] S404. Obtain the expiration time of the first access token and determine whether the expiration time is after the current time.
[0125] The token expiration time can be determined as follows: Obtain the validity period of the first access token. Based on the generation time and validity period of the first access token, the token expiration time can be determined. The validity period can be a pre-set value within the server, for example, 3 minutes.
[0126] The current time can refer to the moment when the first server receives the first access request. If the current time is after the expiration time, the first access token will be considered an invalid token.
[0127] If so, then execute S408.
[0128] If not, then execute S409.
[0129] S405. Obtain historical access information from the first access request, and determine the last time the first device accessed the target system based on the historical access information.
[0130] Historical access information refers to records of the first device's past accesses to the target system. This information may include server information and access timestamps from those times. Based on this historical access information, the last access time of the first device to the target system can be obtained.
[0131] S406. Determine whether the time difference between the access time and the current time is greater than or equal to the preset duration.
[0132] For example, assuming the access time is 16:25 on March 18, 2024, and the current time is the access time of 16:29 on March 18, 2024, with a preset duration of 3 minutes, then the time difference between the current access time and the current time is 4 minutes, which is greater than the preset duration.
[0133] If so, then execute S409.
[0134] If not, then execute S407.
[0135] S407. Determine the second server accessed by the first device when it last accessed the target system from the historical access information, and send a switch request to the second server.
[0136] The second server can be determined as follows: Based on historical access information, the server information when the first device last accessed the target system can be determined, and based on the server information, the second server accessed during the last access to the target system can be determined.
[0137] After the first server determines the second server accessed by the first device when it last accessed the target system, it can generate a switch request and send the switch request to the second server. The switch request can be used to request the second server to process the first access request. The switch request may include the first access request of the first device.
[0138] S408. Determine the equipment type of the first device as the first type.
[0139] The first type is used to indicate that the first device has accessed the target system within a preset time period prior to the current moment.
[0140] S409. Determine the equipment type of the first device as the second type.
[0141] The second type is used to indicate that the first device has not accessed the target system within a preset time period prior to the current moment.
[0142] In this embodiment, when traffic limiting is implemented, it is necessary to determine the device type of the first device. Based on the first access request of the first device, it can be determined whether a first access token is included. If the first access token is not included, the device type of the first device is determined to be the first type. If the first access token is included, it is determined whether the first access token belongs to the token list of the first server. If the first access token belongs to the token list of the first server and the expiration time of the first access token is after the current time, the device type of the first device is determined to be the first type. If the first access token belongs to the token list of the first server and the expiration time of the first access token is before the current time, the device type of the first device is determined to be the first type. If the first access token is not in the first server's token list, the last access time of the first device to the target system is determined based on historical access information. The time difference between the access time and the current time is determined to be greater than or equal to a preset duration. If so, the device type of the first device is determined to be the second type. If not, the second server accessed by the first device when it last accessed the target system is determined in the historical access information, and a switching request is sent to the second server to ensure that the accessing device that has accessed the target system within the preset duration can continue to receive services. Based on the device type of the first device that sent the first access request, the processing method of the access request is determined, which improves the flexibility of traffic limiting.
[0143] Based on any of the above embodiments, the following, in conjunction with Figure 5 The process of handling access requests ( Figure 2 The embodiment of S204 will be described in detail.
[0144] Figure 5 This is a schematic diagram illustrating the process of processing access requests according to an embodiment of this application. Please refer to... Figure 5 The method may include:
[0145] S501. Obtain the remaining access count for the target system.
[0146] It should be noted that the execution process of S501 above can be found in S204, and will not be repeated here.
[0147] S502. Determine if the remaining access count is equal to 0.
[0148] If so, then execute S503.
[0149] If not, then execute S506.
[0150] S503. Determine whether the device type of the first device is the first type.
[0151] If so, then execute S504.
[0152] If not, then execute S505.
[0153] S504. Add the first access request to the first queue.
[0154] The first queue can be used to store access requests sent by devices of the first type that restrict access to the target system, and the first queue can be located in the storage space of the first server.
[0155] If the device type of the first device is type 1, then the first access request is added to the first queue.
[0156] S505. Add the first access request to the second queue.
[0157] The second queue is used to store access requests sent by the second type of device that are restricted from accessing the target system. The second queue may be located within the storage space of the first server.
[0158] If the device type of the first device is the second type, then the first access request is added to the first queue.
[0159] S506. Obtain the remaining access count N and the first number M of access requests existing in the first queue.
[0160] S507. Determine whether M is greater than or equal to N.
[0161] If so, then execute S508.
[0162] If not, then execute S509.
[0163] S508: Control the terminal devices corresponding to the first N access requests to access the target system.
[0164] For example, assuming the remaining access volume N is 10 and the first number M of access requests in the first queue is 15, then the first 10 access requests in the first queue are determined, and the terminal devices corresponding to these 10 access requests are controlled to access the target system.
[0165] S509. Control the terminal devices corresponding to the M access requests in the first queue to access the target system, and control the terminal devices corresponding to the first NM access requests in the second queue to access the target system.
[0166] For example, assuming the remaining access volume N is 10 and the first number M of access requests in the first queue is 5, then control the terminal devices corresponding to the 5 access requests in the first queue to access the target system, and control the terminal devices corresponding to the first 5 access requests in the second queue to access the target system.
[0167] In this embodiment, when traffic limiting is required, the first access request can be processed according to the device type of the first device to obtain the remaining access volume corresponding to the target system. When the remaining access volume is equal to 0, the device type of the first device is determined. If the device type of the first device is a first type, the first access request is added to the first queue; if the device type of the first device is a second type, the first access request is added to the second queue. When the remaining access volume is greater than 0, the remaining access volume N and the first number M of access requests existing in the first queue are obtained. It is determined whether M is greater than or equal to N. If yes, the terminal devices corresponding to the first N access requests are controlled to access the target system; if not, the terminal devices corresponding to the M access requests in the first queue are controlled to access the target system, and the terminal devices corresponding to the first NM access requests in the second queue are controlled to access the target system. By determining the processing method of the access request based on the device type of the first device that sent the first access request, the flexibility of traffic limiting is improved.
[0168] Figure 6 This is a schematic diagram of a flow limiting device provided in an embodiment of this application. Please refer to... Figure 6 The flow limiting device 10 includes: a receiving module 11, a first determining module 12, a second determining module 13, and a processing module 14, wherein...
[0169] The receiving module 11 is used to receive a first access request sent by the first device, the first access request being used to request access to the target system;
[0170] The first determining module 12 is used to determine the current access volume of the target system based on the access request;
[0171] The second determining module 13 is used to determine the device type of the first device based on the first access request if the current access volume is greater than or equal to the first threshold. The device type is either a first type or a second type. The first type is used to indicate that the first device has accessed the target system within a preset time period before the current time, and the second type is used to indicate that the first device has not accessed the target system within a preset time period before the current time.
[0172] The processing module 14 is used to process the first access request according to the device type of the first device.
[0173] The flow limiting device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.
[0174] In one possible design, the second determining module 13 is specifically used for:
[0175] Determine whether the first access request includes the first access token;
[0176] If so, the device type of the first device is determined based on the first access token and the token list corresponding to the first server;
[0177] If not, then the device type of the first device is determined to be the second type.
[0178] In one possible design, the second determining module 13 is specifically used for:
[0179] Determine whether the first access token is included in the token list;
[0180] If so, obtain the expiration time of the first access token, and determine the device type of the first device based on the expiration time and the current time;
[0181] If not, then obtain historical access information from the first access request, and determine the device type of the first device based on the historical access information.
[0182] In one possible design, the second determining module 13 is specifically used for:
[0183] If the token expires after the current time, then the device type of the first device is determined to be the first type;
[0184] If the token expires before the current time, then the device type of the first device is determined to be the second type.
[0185] In one possible design, the second determining module 13 is specifically used for:
[0186] Based on the historical access information, determine the time when the first device last accessed the target system;
[0187] If the time difference between the access time and the current time is greater than or equal to a preset duration, then the device type of the first device is determined to be the second type;
[0188] If the time difference between the access time and the current time is less than the preset duration, then the second server accessed by the first device when it last accessed the target system is determined from the historical access information, and a switching request is sent to the second server. The switching request is used to request the second server to process the first access request.
[0189] In one possible design, processing module 14 is specifically used for:
[0190] Obtain the remaining access count for the target system;
[0191] If the remaining access volume is greater than 0, then the first access request is processed to enable the first device to access the target system;
[0192] If the remaining access count is 0, then the first access request is cached according to the device type of the first device to restrict the first device from accessing the target system.
[0193] In one possible design, processing module 14 is specifically used for:
[0194] If the device type of the first device is the first type, then the first access request is added to the first queue, which is used to store access requests sent by the first type of device that are restricted from accessing the target system;
[0195] If the device type of the first device is the second type, then the first access request is added to the second queue, which is used to store access requests sent by devices of the second type that restrict access to the target system.
[0196] Figure 7 This is a schematic diagram of another flow limiting device provided in an embodiment of this application. Figure 6 Based on the illustrated embodiments, please refer to Figure 7 The processing module 14 further includes: a third determining module 15, a first control module 16, and a second control module 17, wherein,
[0197] The third determining module 15 is used to determine the first number M of access requests existing in the first queue when the remaining access quantity switches from 0 to N, where N is a positive integer and M is an integer;
[0198] The first control module 16 is configured to control the terminal devices corresponding to the first N access requests to access the target system if M is greater than or equal to N.
[0199] The second control module 17 is configured to, if M is less than N, control the terminal devices corresponding to the M access requests in the first queue to access the target system, and control the terminal devices corresponding to the first NM access requests in the second queue to access the target system.
[0200] The flow limiting device provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be described again here.
[0201] Figure 8This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 8 As shown, the electronic device may include: a transceiver 111, a processor 112, and a memory 113.
[0202] Processor 112 executes computer execution instructions stored in memory, causing processor 112 to perform the scheme in the above embodiments. Processor 112 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0203] The memory 113 is connected to the processor 112 via the system bus and completes communication between them. The memory 113 is used to store computer program instructions.
[0204] Transceiver 111 can be used to obtain the task to be run and its configuration information.
[0205] The system bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The system bus can be divided into address bus, data bus, control bus, etc. For ease of representation, only one thick line is used in the diagram, but this does not indicate that there is only one bus or one type of bus. Transceivers are used to enable communication between database access devices and other computers (e.g., clients, read-write libraries, and read-only libraries). Memory may include random access memory (RAM) and may also include non-volatile memory.
[0206] The electronic device provided in this application embodiment can be the terminal device described in the above embodiments.
[0207] This application also provides a chip for executing instructions, which is used to execute the flow limiting method described in the above embodiments.
[0208] This application also provides a computer-readable storage medium storing computer instructions that, when executed on a computer, cause the computer to perform the traffic limiting method described in the above embodiments.
[0209] This application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. At least one processor can read the computer program from the computer-readable storage medium, and when the at least one processor executes the computer program, it can implement the technical solution of the traffic limiting method in the above embodiments.
[0210] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, devices, or modules, and may be electrical, mechanical, or other forms.
[0211] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to implement the solution of this embodiment according to actual needs.
[0212] Furthermore, the functional modules in the various embodiments of this application can be integrated into one processing unit, or each module can exist physically separately, or two or more modules can be integrated into one unit. The unit composed of the above modules can be implemented in hardware or in the form of hardware plus software functional units.
[0213] The integrated modules described above, implemented as software functional modules, can be stored in a computer-readable storage medium. These software functional modules, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute some steps of the methods of the various embodiments of this application.
[0214] It should be understood that the aforementioned processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. A general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly manifested as execution by a hardware processor, or execution by a combination of hardware and software modules within the processor.
[0215] The memory may include high-speed RAM, and may also include non-volatile storage (NVM), such as at least one disk storage device, and may also be a USB flash drive, external hard drive, read-only memory, disk or optical disc, etc.
[0216] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.
[0217] The aforementioned storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The storage medium can be any available medium that can be accessed by a general-purpose or special-purpose computer.
[0218] An exemplary storage medium is coupled to a processor, enabling the processor to read information from and write information to the storage medium. Alternatively, the storage medium can be an integral part of the processor. The processor and storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and storage medium can exist as discrete components in an electronic control unit or main control device.
[0219] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0220] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A flow limiting method, characterized in that, Applied to a first server, the method includes: Receive a first access request sent by a first device, the first access request being used to request access to the target system; Based on the access request, determine the current access volume of the target system; If the current access volume is greater than or equal to the first threshold, then the device type of the first device is determined according to the first access request. The device type is either a first type or a second type. The first type is used to indicate that the first device has accessed the target system within a preset time period before the current time, and the second type is used to indicate that the first device has not accessed the target system within a preset time period before the current time. The first access request is processed according to the device type of the first device; The step of determining the device type of the first device based on the first access request includes: determining whether the first access request includes a first access token; If so, the device type of the first device is determined based on the first access token and the token list corresponding to the first server; If not, then the device type of the first device is determined to be the second type; The step of determining the device type of the first device based on the first access token and the token list corresponding to the first server includes: Determine whether the first access token is included in the token list; If so, obtain the expiration time of the first access token, and determine the device type of the first device based on the expiration time and the current time; If not, then obtain historical access information from the first access request, and determine the device type of the first device based on the historical access information.
2. The method according to claim 1, characterized in that, Based on the token expiration time and the current time, the device type of the first device is determined, including: If the token expires after the current time, then the device type of the first device is determined to be the first type; If the token expires before the current time, then the device type of the first device is determined to be the second type.
3. The method according to claim 1, characterized in that, Based on the historical access information, the device type of the first device is determined, including: Based on the historical access information, determine the time when the first device last accessed the target system; If the time difference between the access time and the current time is greater than or equal to a preset duration, then the device type of the first device is determined to be the second type; If the time difference between the access time and the current time is less than the preset duration, then the second server accessed by the first device when it last accessed the target system is determined from the historical access information, and a switching request is sent to the second server. The switching request is used to request the second server to process the first access request.
4. The method according to any one of claims 1-3, characterized in that, Based on the device type of the first device, the first access request is processed, including: Obtain the remaining access count for the target system; If the remaining access volume is greater than 0, then the first access request is processed to enable the first device to access the target system; If the remaining access count is 0, then the first access request is cached according to the device type of the first device to restrict the first device from accessing the target system.
5. The method according to claim 4, characterized in that, Based on the device type of the first device, the first access request is cached, including: If the device type of the first device is the first type, then the first access request is added to the first queue, which is used to store access requests sent by the first type of device that are restricted from accessing the target system; If the device type of the first device is the second type, then the first access request is added to the second queue, which is used to store access requests sent by devices of the second type that restrict access to the target system.
6. The method according to claim 5, characterized in that, The method further includes: When the remaining access count changes from 0 to N, a first number M of access requests existing in the first queue is determined, where N is a positive integer and M is an integer; If M is greater than or equal to N, then control the terminal devices corresponding to the first N access requests to access the target system; If M is less than N, then control the terminal devices corresponding to the M access requests in the first queue to access the target system, and control the terminal devices corresponding to the first NM access requests in the second queue to access the target system.
7. A flow limiting device, characterized in that, include: The module comprises a receiving module, a first determining module, a second determining module, and a processing module, wherein... The receiving module is used to receive a first access request sent by the first device, the first access request being used to request access to the target system; The first determining module is used to determine the current access volume of the target system based on the access request; The second determining module is configured to: if the current access volume is greater than or equal to a first threshold, determine the device type of the first device based on the first access request, wherein the device type is a first type or a second type, the first type indicating that the first device has accessed the target system within a preset time period before the current time, and the second type indicating that the first device has not accessed the target system within a preset time period before the current time; determining the device type of the first device based on the first access request includes: determining whether the first access request includes a first access token; if yes, determining the device type of the first device based on the first access token and the token list corresponding to the first server; if no, determining the device type of the first device as the second type; determining the device type of the first device based on the first access token and the token list corresponding to the first server includes: determining whether the token list includes the first access token; if yes, obtaining the token expiration time of the first access token, and determining the device type of the first device based on the token expiration time and the current time; if no, obtaining historical access information in the first access request, and determining the device type of the first device based on the historical access information. The processing module is used to process the first access request according to the device type of the first device.
8. An electronic device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1 to 6.
10. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the method of any one of claims 1 to 6.
Citation Information
Patent Citations
Interface access method and device, equipment and medium
CN117574350A
Multi-step service authorization for indirect communication in a communication system
WO2021094349A1