Implementation method of APP concurrent request queue

By designing the implementation method of APP concurrent request queue and using the queue manager class to manage the request queue and control the number of concurrencies, the problem of server overload and timing disorder is solved, the order and effectiveness of requests are ensured, and the user experience is improved.

CN118796148APending Publication Date: 2024-10-18BEIJING BAILONG MAYUN TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410871250.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-01
Publication Date
2024-10-18

AI Technical Summary

Technical Problem

On a rapidly developing network platform, the increase in the number of users has caused server overload. APPs are faced with the problem of too many concurrent requests, leading to system performance degradation and crashes. Requests that exceed the number of concurrent requests cannot be effectively managed, causing timing disorder and user information expiration, affecting users. experience.

Method used

Design a method to implement the APP concurrent request queue. Manage the global request queue and control the number of concurrency through the queue manager class. Requests that exceed the number of concurrency are pushed into the queue in order, first-in-first-out storage requests, and automatically when user information expires. Refresh to ensure the order and validity of requests.

Benefits of technology

By clarifying attributes and methods, ensure that the functions and functions of the queue manager are clear, use the singleton mode to ensure global uniqueness, determine the request processing method based on the current number of concurrencies, reduce timing disorder issues, ensure the order and effectiveness of requests, and avoid resource Over-occupancy ensures stability and reliability in dynamic environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118796148A_ABST
    Figure CN118796148A_ABST
Patent Text Reader

Abstract

The invention relates to an implementation method of an APP concurrent request queue, in particular to the field of concurrency, and designs attributes and methods of a queue manager class to manage a global request queue and control a concurrency number, register a global queue manager instance when an APP is started, ensure the consistency and high efficiency of a scheme, avoid disorder and uncertainty of request processing, and improve the performance of the APP. The requests exceeding the current concurrency number are sequentially pushed into a queue manager to be managed according to the sequence, the requests in the queue manager are stored in a first-in first-out mode, whether available concurrent processing resources exist currently or not is checked and judged, a new round of arriving requests and the request releasing step are executed circularly, and the requests are sent to the queue manager. And the server receives the request sent by the user, responds, returns and finds that the user information is invalid, the request dequeue operation in the queue manager is suspended, the state of the request queue is kept unchanged, the requests in the request queue are dequeued in sequence again, and the data return failure caused by the invalid user information is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of concurrent design, and more specifically, to a method for implementing an APP concurrent request queue. Background Art

[0002] On a rapidly developing network platform, the number of users continues to increase, and user experience becomes crucial. As the number of users increases, the server faces more and more concurrent requests, which brings challenges to the APP. During peak hours, a large number of concurrent requests cause server overload, resulting in system performance degradation and crash.

[0003] Currently, when an APP issues multiple requests concurrently at the same time, the maximum concurrent number limit is exceeded and the requests that exceed the concurrent number cannot be effectively managed, resulting in timing disorder problems. When multiple requests are issued concurrently, user information may expire, and the requests sent out may face invalid requests and fail to obtain correct data, affecting the user experience. Summary of the invention

[0004] In view of the technical problems existing in the prior art, the present invention provides a method for implementing an APP concurrent request queue to solve the problems raised in the above background technology.

[0005] The technical solution of the present invention to solve the above technical problem is as follows: a method for implementing an APP concurrent request queue, comprising the following steps:

[0006] S101. Design the properties and methods of the queue manager class to manage the global request queue and control the number of concurrent requests. When the APP starts, register the global queue manager instance. When the attribute reaches the maximum number of concurrent requests, the requests exceeding the current number of concurrent requests are pushed into the queue manager in order for management.

[0007] S102. The requests in the queue manager are stored in a first-in-first-out manner, and a check is made to determine whether there are currently available concurrent processing resources, and the requests in the queue manager are released;

[0008] S103. During the queue manager release request process, a new round of requests arriving and release request steps are executed cyclically;

[0009] S104. The server receives a request from a user and responds to it and finds that the user information is invalid. It suspends the request dequeue operation in the queue manager and keeps the request queue state unchanged. It starts the queue manager to automatically refresh the user information mechanism and dequeue the requests in the request queue in sequence.

[0010] In a preferred embodiment, in S101, the properties and methods of the queue manager class are designed to manage the global request queue and control the concurrency. The properties include the maximum concurrency, the current concurrency and the request queue. The methods include add_request(request) and process_requests().

[0011] Furthermore, a new request queue manager is created, and the variable with the attribute of the current concurrency number is initialized to 0. The add_request(request) method is used to add the request to the request queue and lock the resources, and the threads waiting to be processed are notified. After processing the request, the parameter value with the attribute of the current concurrency number is reduced and recorded to indicate that the request has been completed.

[0012] Furthermore, when the APP starts, a global queue manager instance is registered, and the singleton mode is used to ensure that there is only one queue manager object in the world. The add_request(request) method of the queue manager is called to add the newly arrived request to the queue manager, and the request processing method is determined according to the current concurrency attribute. When the current concurrency attribute reaches the maximum, the queue manager will push the requests that exceed the current concurrency into the queue manager in order for management, and control the maximum concurrency.

[0013] In a preferred embodiment, in S102, the requests in the queue manager are stored in a first-in-first-out manner, and the request that arrives first is added to the tail of the queue manager through the add_request(request) method, and the requests that arrive subsequently are added and stored in sequence until the head of the queue manager is stored.

[0014] Furthermore, it is checked to determine whether there are currently available concurrent processing resources. If there are available concurrent processing resources, the requests in the queue manager will be processed immediately, and the requests will be taken out from the queue manager header for sending and processing. If there are no available concurrent processing resources, it will wait until concurrent processing resources are available, remove the requests that have been processed by the queue manager, and when no new requests arrive and all requests in the current queue manager have been processed, it will start to release the requests in the queue manager.

[0015] In a preferred embodiment, in S103, during the process of releasing requests by the queue manager, a new round of concurrent requests arriving are pushed into the queue manager, the queue manager continues to release the requests and pushes a new round of requests arriving with an attribute exceeding the current concurrency number into the header of the queue manager in sequence, and executes the new round of requests arriving and the request release steps in a loop.

[0016] In a preferred embodiment, in S104, the add_request(request) method of the queue manager is called to add the newly arrived request to the queue manager. The server receives the request sent by the user and responds to it and finds that the user information is invalid. The request returned in response cannot return data normally, and a notification of failure to return data normally is sent. The queue manager receives the notification of invalid user information, suspends the request dequeue operation in the queue manager and keeps the request queue state unchanged, re-adds the request returned in response to the request queue and waits for processing, starts the queue manager's automatic refresh mechanism for user information, tries to refresh the user information and waits for success notification, re-dequeues the requests in the request queue in sequence, and re-sends the request to the server to obtain the returned data.

[0017] The beneficial effects of the present invention are as follows: by clearly defining properties and methods, the functions and effects of the queue manager are clearly visible; initialization of the queue manager class and the use of the singleton mode ensure that there is only one queue manager object globally, thereby ensuring the consistency and efficiency of the solution; judging the processing method of requests according to the current concurrent number of situations, thereby ensuring the stability and efficiency of the queue manager under different situations; effectively managing requests that exceed the concurrent number of situations, thereby reducing the probability of timing disorder problems; ensuring the order of requests by storing requests in a first-in-first-out manner, thereby avoiding confusion and uncertainty in request processing; and ensuring the timeliness and effectiveness of request processing by checking whether there are currently available concurrent processing resources. When resources are available, it immediately starts processing requests in the queue manager and takes out requests from the queue manager header for processing, ensuring the sequential processing of requests and the efficiency of the solution. The processing of a new round of arriving requests ensures that new requests can be responded to and processed in a timely manner. By judging attributes and pushing requests into the queue manager, the number of concurrency is effectively controlled and excessive resource occupation is avoided. Through loop execution, stability and reliability in a dynamic environment are guaranteed. By describing the processing flow of user information failure, the server can respond and process user information failure in a timely manner. The request dequeue operation in the queue manager is suspended, which can maintain the original request order and status. The request is returned by rejoining the response to avoid data return failure due to user information failure. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 It is a flow chart of the scheme of the present invention;

[0019] Figure 2 It is an illustration diagram of the scheme of the present invention; DETAILED DESCRIPTION

[0020] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.

[0021] In the description of this application, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this application, "plurality" means two or more, unless otherwise clearly and specifically defined.

[0022] In the description of the present application, the term "for example" is used to mean "used as an example, illustration or description". Any embodiment described as "for example" in the present application is not necessarily to be construed as being more preferred or advantageous than other embodiments. The following description is given to enable any technician in the field to implement and use the present invention. In the following description, details are listed for the purpose of explanation. It should be understood that a person of ordinary skill in the art can recognize that the present invention can be implemented without using these specific details. In other examples, well-known structures and processes will not be elaborated in detail to avoid unnecessary details to obscure the description of the present invention. Therefore, the present invention is not intended to be limited to the embodiments shown, but is consistent with the widest scope consistent with the principles and features disclosed in the present application.

[0023] Example 1

[0024] This embodiment provides Figure 1 The method for implementing an APP concurrent request queue specifically includes the following steps:

[0025] S101. Design the properties and methods of the queue manager class to manage the global request queue and control the number of concurrent requests. When the APP starts, register the global queue manager instance. When the attribute reaches the maximum number of concurrent requests, the requests exceeding the current number of concurrent requests are pushed into the queue manager in order for management.

[0026] Furthermore, the properties and methods of the queue manager class are designed to manage the global request queue and control the concurrency. The properties include the maximum concurrency, the current concurrency, and the request queue. The maximum concurrency indicates the maximum number of requests processed at the same time, the current concurrency indicates the number of requests currently being processed, and the request queue indicates the storage of requests waiting to be processed. The methods include add_request(request) and process_requests(), where add_request(request) indicates adding a new request to the queue, and process_requests() indicates the method of processing requests, controlling the concurrency, taking requests out of the queue and processing them.

[0027] Furthermore, a new request queue manager is created, and the variable with the attribute of current concurrent number is initialized to 0, which is used to indicate that there are no requests being processed at present. The add_request(requ est) method is used to add the request to the request queue and lock the resources, and notify that there is a thread waiting to be processed, which is used to receive new requests and add them to the request queue. The process_requests() method is used to loop through the request queue and process the requests. During the loop, it is checked and judged whether the attribute of current concurrent number has reached the maximum value. When the attribute of current concurrent number has reached the maximum value, it will wait for 100ms before continuing to check and judge, which is used to avoid useless loops. When the attribute of current concurrent number has not reached the maximum value, a request is taken out of the request queue and added to the attribute of current concurrent number, and the processing of the taken request is started. After processing the request, the parameter value of the attribute of current concurrent number is reduced and recorded, which is used to indicate that the request has been completed.

[0028] Furthermore, when the APP is started, a global queue manager instance is registered, and the singleton mode is used to ensure that there is only one queue manager object in the world. The add_request(request) method of the queue manager is called to add the newly arrived request to the queue manager. The request processing method is determined according to the current concurrency attribute, including immediate processing of the request and adding the request to the queue manager for processing. When the current concurrency attribute reaches the maximum, the queue manager will push the requests that exceed the current concurrency into the queue manager for management in sequence and control the maximum concurrency.

[0029] S102. The requests in the queue manager are stored in a first-in-first-out manner, and a check is made to determine whether there are currently available concurrent processing resources, and the requests in the queue manager are released;

[0030] Furthermore, the requests in the queue manager are stored in a first-in-first-out manner. The first request that arrives is added to the tail of the queue manager through the add_request(request) method, and the requests that arrive subsequently are added and stored in sequence until the head of the queue manager is stored.

[0031] Furthermore, it is checked whether there are currently available concurrent processing resources. If there are available concurrent processing resources, the requests in the queue manager will be processed immediately, and the requests will be taken out from the head of the queue manager for sending and processing. If there are no available concurrent processing resources, it will wait until concurrent processing resources are available, remove the requests that have been processed by the queue manager, and when no new requests arrive and all requests in the current queue manager have been processed, start releasing the requests in the queue manager. The release order is to release them one by one from the tail of the queue until the queue manager is empty.

[0032] S103. During the queue manager release request process, a new round of requests arriving and release request steps are executed cyclically;

[0033] Furthermore, during the process of releasing requests, the queue manager pushes a new round of concurrent requests into the queue manager. The queue manager continues to release requests and pushes a new round of requests that have arrived and have exceeded the current concurrency number into the head of the queue manager in sequence, and executes the new round of requests that have arrived and the request release steps in a loop.

[0034] S104. The server receives a request from a user and responds to it and finds that the user information is invalid. It suspends the request dequeue operation in the queue manager and keeps the request queue state unchanged. It starts the queue manager to automatically refresh the user information mechanism and dequeue the requests in the request queue in sequence.

[0035] Furthermore, in the process of calling the queue manager's add_request(request) method to add the newly arrived request to the queue manager, the server receives the request sent by the user and responds to it and finds that the user information is invalid. The request returned in response cannot return data normally, and a notification of failure to return data normally is sent. The queue manager receives the notification of invalid user information, suspends the request dequeue operation in the queue manager and keeps the request queue status unchanged, re-adds the request returned in response to the request queue and waits for processing, starts the queue manager's automatic refresh mechanism for user information, tries to refresh the user information and waits for success notification, re-dequeues the requests in the request queue in sequence, and resends the request to the server to obtain returned data.

[0036] Example 2

[0037] This embodiment provides Figure 2The method for implementing an APP concurrent request queue specifically includes the following steps:

[0038] APP receives 9 HTTP requests that need to be sent within 5 seconds. Since the maximum concurrency is 5, the first 5 requests can be sent to the server immediately, while the remaining 4 requests cannot be sent immediately. When the 5th request is sent, the queue manager starts to process the waiting requests. The queue manager puts the 4 waiting requests into the queue for subsequent processing. While waiting, the server starts to respond to the sent requests. When a response is returned, APP will process the response. In the process of processing the response, if the user information is found to be expired, a specific processing flow is triggered. When receiving the response from the server, APP checks whether the user information in the response is expired. When the user information is found to be expired, APP puts the request back into the queue manager and starts the process of refreshing the user information. APP starts refreshing the user information. When the user information is successfully refreshed, APP checks the waiting requests in the queue manager and resends them to the server. Once the user information is successfully refreshed, APP will take out the waiting requests from the queue manager and resend them to the server. These resent requests will be sent in the order in the queue to ensure the order and correctness of the requests.

[0039] It should be noted that in the above embodiments, the description of each embodiment has its own emphasis, and for parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0040] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0041] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded computer, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1A device that provides the functions specified in a block or multiple blocks.

[0042] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0043] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0044] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.

[0045] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A method for implementing an APP concurrent request queue, characterized in that: The specific steps include: S101. Design the properties and methods of the queue manager class to manage the global request queue and control the number of concurrent requests. When the APP starts, register the global queue manager instance. When the attribute reaches the maximum number of concurrent requests, the requests exceeding the current number of concurrent requests are pushed into the queue manager in order for management. S102. The requests in the queue manager are stored in a first-in-first-out manner, and a check is made to determine whether there are currently available concurrent processing resources, and the requests in the queue manager are released; S103. During the queue manager release request process, a new round of requests arriving and release request steps are executed cyclically; S104. The server receives the request sent by the user and responds and returns and finds that the user information is invalid, suspends the request dequeue operation in the queue manager and keeps the request queue state unchanged, starts the queue manager's automatic refresh user information mechanism, and dequeues the requests in the request queue again in sequence.

2. The method for implementing an APP concurrent request queue according to claim 1, characterized in that: In S101, the properties and methods of the queue manager class are designed to manage the global request queue and control the concurrency. The properties include the maximum concurrency, the current concurrency and the request queue. The methods include add_request(request) and process_requests().

3. The method for implementing an APP concurrent request queue according to claim 2, characterized in that: Use the add_request(request) method to add the request to the request queue and lock resources, notify the existence of threads waiting to be processed, and after processing the request, reduce and record the parameter value of the current concurrency number to indicate that the request has been completed.

4. The method for implementing an APP concurrent request queue according to claim 2, characterized in that: When the APP starts, it registers a global queue manager instance, calls the add_request(request) method of the queue manager to add the newly arrived request to the queue manager, and determines the request processing method based on the current concurrency attribute. When the current concurrency attribute reaches the maximum, the queue manager pushes the requests that exceed the current concurrency into the queue manager in order for management, and controls the maximum concurrency.

5. The method for implementing an APP concurrent request queue according to claim 1, characterized in that: In S102, the requests in the queue manager are stored in a first-in-first-out manner. The request that arrives first is added to the tail of the queue manager through the add_request(request) method, and the requests that arrive subsequently are added and stored in sequence until the head of the queue manager is stored, and it is checked to determine whether there are currently available concurrent processing resources.

6. The method for implementing an APP concurrent request queue according to claim 5, characterized in that: The specific steps of the inspection and judgment are: when there are available concurrent processing resources, immediately start processing the requests in the queue manager, and take out the requests from the queue manager header for sending processing; when there are no available concurrent processing resources, wait until there are concurrent processing resources available, remove the requests that the queue manager has processed, and when no new requests arrive and all requests in the current queue manager are processed, start releasing the requests in the queue manager.

7. The method for implementing an APP concurrent request queue according to claim 1, characterized in that: In S103, during the process of releasing the request, the queue manager pushes a new round of concurrent requests into the queue manager, and the queue manager continues to release the request and pushes a new round of requests that have arrived and have exceeded the current concurrent number into the head of the queue manager in sequence, and executes the new round of requests that have arrived and the request release steps in a loop.

8. The method for implementing an APP concurrent request queue according to claim 1, characterized in that: In S104, in the process of calling the add_request(request) method of the queue manager to add the newly arrived request to the queue manager, the server receives the request sent by the user and responds to it and finds that the user information is invalid, and sends a notification that the data cannot be returned normally. The queue manager receives the notification of invalid user information, suspends the request dequeue operation in the queue manager and keeps the request queue state unchanged, re-adds the response returned request to the request queue and waits for processing, starts the queue manager's automatic refresh user information mechanism, re-dequeues the requests in the request queue in sequence, and sends a request to the server to obtain the returned data.

Citation Information

Cited By

  • Aging request processing method, device and system, network chip and network interface card

    CN120602438A