A concurrent request processing method, processing device, computer equipment and medium
By using dictionary deduplication and request management, the problem of low efficiency in concurrent request processing during the creation of large editable tables is solved, achieving efficient request control and page rendering optimization.
Patent Information
- Application Number
- CN202310511521.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-08
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2043-05-08
AI Technical Summary
During the creation of large, editable tables, multiple concurrent requests from the front end can lead to a backlog of network requests, slower response times, or even timeouts, causing page crashes. The efficiency of handling concurrent requests is low, and repeated requests increase the burden on the back end.
By receiving feedback data from the backend, deduplication of dictionary codes is performed to generate target dictionary codes. The concurrent number of second requests is controlled to be less than or equal to a preset number. Request sending is managed using a task queue and concurrency pool, and the request process is optimized by combining local caching.
It effectively reduces duplicate requests, controls the number of concurrent requests, improves processing efficiency, reduces backend pressure, prevents response timeouts, and improves page rendering speed.
Smart Images

Figure CN116627968B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of Internet, in particular to a concurrent request processing method, a processing device, a computer device and a medium. BACKGROUND
[0002] The data dictionary refers to a maintenance management form of a data table structure used by a form, field information and field attributes. In the process of making a large editing type table, the front end will request a large number of dictionary codes corresponding to the form to the back end, and the dictionary code refers to the encoding of each component in the form corresponding to the data dictionary. After obtaining a large number of dictionary codes, when the front end requests the real information corresponding to the large number of dictionary codes, the front end multiple request concurrency occurs. When the front end multiple request concurrency occurs, a large number of network requests will be sent, and these network requests will be sent to the back end at the same time, and the back end will process these network requests at the same time and return the real information corresponding to the dictionary code. In this case, if the number of concurrent network requests is too large, it will cause request accumulation, slow response time or even timeout, and the front end page will also crash because the network request has not been responded. In addition, when multiple requests are concurrent, the dictionary codes in many network requests are repeated, which will cause the back end to process repeated network requests, further reducing the request processing efficiency. The current method for reducing repeated request processing of the back end is to control the back end to receive the same request only once within a certain time, but this method is contrary to the business logic of the front end.
[0003] Therefore, there is an urgent need for a method for processing multiple request concurrency and repeated request concurrency. SUMMARY
[0004] Therefore, the embodiments of the present application provide a concurrent request processing method, a processing device, a computer device and a medium to solve the problem of low concurrent request processing efficiency caused by multiple request concurrency and repeated request concurrency.
[0005] According to a first aspect, the embodiments of the present application provide a concurrent request processing method, which comprises:
[0006] receiving first feedback data sent by the back end in response to the first request; the first feedback data comprises a plurality of first dictionary codes corresponding to a form to be rendered;
[0007] de-duplicating the plurality of first dictionary codes to obtain a plurality of target dictionary codes;
[0008] generating a plurality of second requests based on the plurality of target dictionary codes; the second request is used to request real information corresponding to the target dictionary code to the back end;
[0009] controlling the second request to be sent to the back end in a preset manner, and the preset manner is that the number of concurrent second requests is less than or equal to a preset number.
[0010] In some embodiments, the sending the second request to the backend in a preset manner comprises:
[0011] writing the plurality of second requests into a task queue;
[0012] reading a preset number of second requests from the task queue, and adding the preset number of second requests into a concurrent pool;
[0013] after sending of any one of the second requests in the concurrent pool is completed, removing the second request whose sending is completed from the concurrent pool;
[0014] in a case where the number of second requests in the concurrent pool is less than a preset number, determining whether there is an unread second request in the task queue;
[0015] in a case where there is an unread second request in the task queue, reading a new second request from the task queue and adding the new second request into the concurrent pool to keep the number of second requests in the concurrent pool as the preset number.
[0016] In some embodiments, the reading a preset number of second requests from the task queue and adding the preset number of second requests into a concurrent pool comprises:
[0017] reading one second request from the task queue and adding the read second request into the concurrent pool;
[0018] determining whether the number of second requests in the concurrent pool is less than or equal to the preset number;
[0019] in a case where the number of second requests in the concurrent pool is less than the preset number, returning to the step of reading one second request from the task queue and adding the read second request into the concurrent pool;
[0020] in a case where the number of second requests in the concurrent pool is equal to the preset number, pausing reading of the second request from the task queue.
[0021] In some embodiments, the deduplication processing on the plurality of first dictionary codes comprises:
[0022] for each first dictionary code, determining an initial index and a current index corresponding to the first dictionary code based on a preset function;
[0023] removing the first dictionary code whose current index is inconsistent with the initial index, and keeping the first dictionary code whose current index is consistent with the initial index as a target dictionary code.
[0024] In some embodiments, after controlling the second request to be sent to the backend in the preset manner, the method further comprises:
[0025] receiving second feedback data returned by the backend in response to the second request; the second feedback data comprises real information corresponding to the target dictionary code;
[0026] storing the second feedback data in a local cache.
[0027] In some embodiments, after storing the second feedback data in the local cache, the method further comprises:
[0028] in a case of preparing to render a new form, obtaining a second dictionary code corresponding to the new form;
[0029] querying whether real information corresponding to the second dictionary code is stored in the local cache;
[0030] in a case where the real information corresponding to the second dictionary code is stored in the local cache, extracting the real information corresponding to the second dictionary code from the local cache for rendering the new form;
[0031] in a case where the real information corresponding to the second dictionary code is not stored in the local cache, generating a third request corresponding to the second dictionary code based on the second dictionary code; the third request is used to request the real information corresponding to the second dictionary code from the backend;
[0032] controlling the third request to be sent to the backend in the preset manner.
[0033] In some embodiments, after receiving the second feedback data returned by the backend in response to the second request, the method further comprises:
[0034] rendering the form to be rendered based on the second feedback data, so that initial values of components in the form to be rendered are updated to the real information.
[0035] According to a second aspect, an embodiment of the present application provides a concurrent request processing apparatus, which comprises:
[0036] a receiving module configured to receive first feedback data sent by a backend in response to a first request; the first feedback data comprises a plurality of first dictionary codes corresponding to a form to be rendered;
[0037] a deduplication module configured to perform deduplication processing on the plurality of first dictionary codes to obtain a plurality of target dictionary codes;
[0038] The request generation module is configured to generate a plurality of second requests based on the plurality of target dictionary codes, wherein the second requests are used to request real information corresponding to the target dictionary codes from the backend.
[0039] The sending control module is configured to control the second requests to be sent to the backend in a preset manner, wherein the preset manner is that the number of concurrent second requests is less than or equal to a preset number.
[0040] According to a third aspect, an embodiment of the present application provides a computer device, characterized in that comprising: at least one processor; and a memory connected with the at least one processor in communication; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the steps of the concurrent request processing method according to the first aspect.
[0041] According to a fourth aspect, an embodiment of the present application provides a computer readable storage medium, which stores a computer program, and is characterized by the computer program being executed by a processor to implement the steps of the concurrent request processing method according to the first aspect.
[0042] The technical scheme of the present application has the following advantages.
[0043] The present application provides a concurrent request processing method, processing device, computer device and medium. The method comprises the following steps: first, receiving first feedback data sent by a backend in response to a first request, wherein the first feedback data comprises a plurality of first dictionary codes corresponding to a form to be rendered; then, performing a deduplication processing on the plurality of first dictionary codes to obtain a plurality of target dictionary codes, and generating a plurality of second requests based on the plurality of target dictionary codes, which can effectively reduce the occurrence of repeated requests; wherein the second request is used to request real information corresponding to the target dictionary code from the backend; finally, controlling the second request to be sent to the backend in a preset manner, wherein the preset manner is that the number of concurrent second requests is less than or equal to a preset number, which can effectively control the concurrency of multiple requests and improve the processing efficiency of concurrent requests. BRIEF DESCRIPTION OF DRAWINGS
[0044] In order to more clearly illustrate the specific embodiments of the present application or the technical solutions in the prior art, the following will briefly introduce the drawings needed to be used in the specific embodiments or prior art description. Obviously, the drawings in the following description are some embodiments of the present application, and those skilled in the art can also obtain other drawings according to these drawings without creative labor.
[0045] Figure 1 A flowchart of a concurrent request processing method provided by an embodiment of the present application.
[0046] Figure 2 A flowchart of a method for deduplication processing of a plurality of first dictionary codes is provided for an embodiment of the present application.
[0047] Figure 3 A flowchart of a method for controlling sending of a second request is provided for an embodiment of the present application.
[0048] Figure 4 A flowchart of another concurrent request processing method is provided for an embodiment of the present application.
[0049] Figure 5 A flowchart of still another concurrent request processing method is provided for an embodiment of the present application.
[0050] Figure 6 A structural schematic diagram of a concurrent request processing apparatus is provided for an embodiment of the present application.
[0051] Figure 7 A structural schematic diagram of a computer device is provided for an embodiment of the present application. DETAILED DESCRIPTION
[0052] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are some but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the present application.
[0053] In the process of making a large editing type table, the front end requests a large number of dictionary codes corresponding to the form to the back end, and the dictionary codes refer to the codes corresponding to each component in the form in the data dictionary. After obtaining a large number of dictionary codes, the front end requests the real information corresponding to the large number of dictionary codes, and the front end multiple request concurrency occurs.
[0054] The front end multiple request concurrency can cause many problems. In some cases, the front end multiple request concurrency can send a large number of network requests, some of which are repeated, which can cause the front end page to enter a false death state because the concurrent requests are not responded, so that the page cannot be rendered and cannot be operated, causing a false appearance of a crash. In addition, the super network requests of the multiple request concurrency can also cause the interface timeout problem, that is, the previous request can be responded quickly, but the subsequent request is still in the request, and if it conflicts with the set interface timeout time, the interface timeout can occur, and the page directly crashes. In addition, the jitter of the front end operation, the rapid operation, the network communication, or the slow response of the back end can increase the probability of repeated processing of the network request by the back end.
[0055] In some other cases, although the interface of the query class is almost always idempotent, it is more difficult to achieve idempotency when containing operations such as data insertion, multi-module data update, especially the idempotency requirement in high concurrency. For example, the foreground callback and background callback of batch dictionary query, the display of foreground large table data, slow performance business logic or slow network environment, are high-frequency scenarios of repeated processing of network requests.
[0056] In the scenario of making large editing type tables, the above-mentioned situations occur from time to time. The current method for reducing repeated processing requests in the backend is to control the backend to receive the same request only once within a certain time, but this method is contrary to the business logic of the front end, so there is an urgent need for a method for processing multiple request concurrency and repeated request concurrency in the front end to improve the efficiency of concurrent request processing.
[0057] Figure 1 A flowchart of a concurrent request processing method provided by an embodiment of the application. In the embodiment of the application, the concurrent request processing method is executed by the front end. The front end refers to the running end of the front-end program of a website, such as a client end of a computer, a mobile end, etc., which realizes interaction with the user through the page displayed to the user for browsing on the browser of the computer end, the mobile end, etc. The backend refers to the running end of the background program, such as the server end, which can provide various business support for the front end.
[0058] As shown in Figure 1 , the concurrent request processing method comprises steps S1-S4.
[0059] Step S1, receiving first feedback data sent by the backend in response to a first request.
[0060] The first request is a request sent by the front end to the backend for requesting a plurality of first dictionary codes corresponding to a to-be-rendered form.
[0061] The to-be-rendered form refers to a page currently displayed to the user by the front end, which can be operated by the user. Rendering refers to the process of displaying corresponding content on the form page according to pre-edited code according to certain specifications.
[0062] The first dictionary code refers to the encoding of each component in the to-be-rendered form in the pre-constructed data dictionary, and the data dictionary refers to the data table structure used by the form, and the field information and field attribute maintenance management form.
[0063] The first feedback data includes a plurality of first dictionary codes corresponding to the to-be-rendered form.
[0064] In some embodiments, the first feedback data can be returned in the form of a list, containing the correspondence between each component in the to-be-rendered form and the first dictionary code.
[0065] Since the contents required by different components in the form to be rendered can be the same, for example, the gender of each customer, the first dictionary code corresponding to the different components can be the same, therefore, when each component requests the real information corresponding to the first dictionary code, the front end generates multiple network requests containing the same first dictionary code (repeated network requests). In order to avoid the front end generating repeated network requests, the following steps are performed.
[0066] Step S2, performing deduplication processing on the multiple first dictionary codes to obtain multiple target dictionary codes.
[0067] The deduplication processing refers to an operation of removing the repeatedly appearing first dictionary codes from the multiple first dictionary codes. The target dictionary codes retain the mutually different first dictionary codes.
[0068] Step S3, generating multiple second requests based on the multiple target dictionary codes.
[0069] The second request is a network request for requesting the real information corresponding to the target dictionary code from the back end. The second request contains at least one target dictionary code.
[0070] The dictionary code and the real information are stored in the form of key-value pairs in the back end database. The real information represented by the dictionary code can be queried through the dictionary code, for example, the dictionary code is 10, and the corresponding real information is gender female, and the dictionary code is 11, and the corresponding real information is gender male.
[0071] In the embodiment, the multiple second requests are generated based on the multiple target dictionary codes obtained after the deduplication processing, which can avoid generating repeated network requests and reduce the number of network requests required to be concurrent.
[0072] Step S4, controlling the second request to be sent to the back end in a preset manner.
[0073] The preset manner is that the number of concurrent second requests is less than or equal to a preset number. The preset number is the maximum number of concurrent second requests, and the preset number can be set according to the actual application, which is not limited in the embodiment.
[0074] It should be noted that even if the plurality of first dictionary codes are de-duplicated and then the second request is generated, the number of the second request can still be very large. Too many second requests are sent out, which can cause network congestion, and the second request in front can still be processing while the second request behind has timed out. Therefore, in the embodiment, the second request is controlled to be sent to the backend in a preset manner, so as to ensure that the number of concurrent second requests is less than or equal to a preset number, so as to realize that the second request is sent in order and in moderation, effectively improve the processing efficiency of the concurrent request, and also reduce the pressure on the backend, prevent the problem of response timeout caused by high occupation of memory resources and central processing unit resources in the backend, and the like.
[0075] The embodiment of the application provides a concurrent request processing method, which comprises the following steps: first, receiving first feedback data sent by a backend in response to a first request, wherein the first feedback data comprises a plurality of first dictionary codes corresponding to a form to be rendered; then, de-duplicating the plurality of first dictionary codes to obtain a plurality of target dictionary codes, and generating a plurality of second requests based on the plurality of target dictionary codes, which can effectively reduce the occurrence of repeated requests; wherein the second request is used to request real information corresponding to the target dictionary code from the backend; finally, controlling the second request to be sent to the backend in a preset manner, wherein the preset manner is that the number of concurrent second requests is less than or equal to a preset number, which can realize effective control of the concurrent multiple requests and improve the processing efficiency of the concurrent request.
[0076] Figure 2 A flowchart of a method for de-duplicating a plurality of first dictionary codes is provided for the embodiment of the application. As shown in the figure, the step of de-duplicating the plurality of first dictionary codes to obtain a plurality of target dictionary codes (step S2 described above) comprises steps S21-S22. Figure 2
[0077] Step S21, for each first dictionary code, determining an initial index and a current index corresponding to the first dictionary code based on a preset function.
[0078] The preset function is a preset function for finding the initial index and the current index corresponding to the first dictionary code. The preset function can be set according to actual application, for example, a findIndex function, a filter function, etc. The initial index is the index position corresponding to the first dictionary code when the first dictionary code is found for the first time in the plurality of first dictionary codes, and the current index refers to the index position currently corresponding to the first dictionary code.
[0079] Step S22, removing the first dictionary code with the current index inconsistent with the initial index, and retaining the first dictionary code with the current index consistent with the initial index as the target dictionary code.
[0080] If the current index of the first dictionary code is inconsistent with the initial index, it indicates that the first dictionary code is not the first occurrence, i.e., the first dictionary code is a repeated dictionary code, and thus the first dictionary code with the inconsistent current index and initial index is removed. If the current index of the first dictionary code is consistent with the initial index, it indicates that the first dictionary code is the first occurrence, and thus the first dictionary code with the consistent current index and initial index is retained as a target dictionary code.
[0081] In an embodiment, the plurality of first dictionary codes are processed for deduplication by a filter method. In this process, a callback function is passed as a parameter, and the callback function is used to write a condition for searching for a dictionary code. The callback function is called by the filter method to determine whether each element in the array should be removed. Specifically, if the current first dictionary code is the first occurrence, true is returned, and the filter method retains it in the target dictionary code. If the current element is not the first occurrence, false is returned, and the filter method filters it out. Finally, a new array containing all the target dictionary codes is returned.
[0082] In another embodiment, the plurality of first dictionary codes can be processed for deduplication by a findIndex method. The deduplication process of the findIndex method is similar to the filter method described above, and thus is not described again.
[0083] The embodiment of the present application provides a method for processing a plurality of first dictionary codes for deduplication. Through the deduplication of the first dictionary codes, the generation of a plurality of network requests containing the same first dictionary code (repeated network requests) at the front end can be effectively avoided, and the control of the repeated network requests is realized from the source.
[0084] Figure 3 A flowchart of a method for controlling the sending of a second request is provided in the embodiment of the present application. As shown in Figure 3 The step of controlling the sending of a second request to the backend in a preset manner (step S4 described above) includes steps S41-S44.
[0085] In step S41, a plurality of second requests are written into a task queue.
[0086] The task queue is a read task queue for storing the second request. The reading program at the front end can read the second request from the task queue.
[0087] In the embodiment, writing the plurality of second requests into the task queue can assist in realizing the ordered processing of the second requests.
[0088] Step S42, reading a preset number of second requests from the task queue and adding the preset number of second requests to the concurrency pool.
[0089] In which, the concurrency pool is used to control the number of concurrent second requests.
[0090] In one embodiment, the preset number of second requests can be read at one time and added to the concurrency pool.
[0091] In another embodiment, reading a preset number of second requests from the task queue and adding the preset number of second requests to the concurrency pool includes the following steps one to four.
[0092] Step one, reading a second request from the task queue and adding the read second request to the concurrency pool.
[0093] Step two, determining whether the number of second requests in the concurrency pool is less than or equal to the preset number.
[0094] In some embodiments, there will be a number judgment mechanism in the concurrency pool. When the maximum concurrency pool number (preset number) is not reached, the second request can be added to the concurrency pool.
[0095] Step three, in the case that the number of second requests in the concurrency pool is less than the preset number, return to the step of reading a second request from the task queue and adding the read second request to the concurrency pool (step one above).
[0096] Step four, in the case that the number of second requests in the concurrency pool is equal to the preset number, suspend reading second requests from the task queue.
[0097] In some embodiments, when the number of second requests in the concurrency pool reaches the maximum concurrency pool number (the above-mentioned preset number), adding second requests to the concurrency pool is stopped.
[0098] Step S43, after any second request in the concurrency pool is sent, removing the sent second request from the concurrency pool.
[0099] In order to avoid the sent second request continuously occupying the position in the concurrency pool, the sent second request needs to be removed from the concurrency pool after any second request in the concurrency pool is sent.
[0100] In some embodiments, the concurrent pool can be blocked by a Promise.race method (an algorithm) in ECMAScript 6.0 (a programming language standard) in combination with an await method (an algorithm), and the second requests can be truncated when the preset number is reached. In addition, the mechanism of the Promise.race method can be understood as a race, that is, when one of the second requests produces a result, the Promise.race method will also produce a result. When the Promise.race method produces a result, it can be understood that one of the second requests has been sent.
[0101] Step S44, in a case where the number of the second requests in the concurrent pool is less than the preset number, determining whether there is an unread second request in the task queue.
[0102] In a case where the number of the second requests in the concurrent pool is less than the preset number, it means that a new second request that has not been sent can be added to the concurrent pool at this time, and therefore, it is necessary to determine whether there is an unread second request in the task queue at present.
[0103] In an embodiment, the number determination mechanism in the concurrent pool can also be used to detect the number of the second requests in the concurrent pool in real time, and in a case where the number of the second requests in the concurrent pool is less than the preset number, determining whether there is an unread second request in the task queue.
[0104] In another embodiment, the step of determining whether there is an unread second request in the task queue can be triggered every time a second request is removed from the concurrent pool, that is, the step of removing a second request can be automatically associated with the step of adding a second request, without detecting the number of the second requests in the concurrent pool in real time, thereby reducing the consumption of system resources.
[0105] Step S45, in a case where there is an unread second request in the task queue, reading a new second request from the task queue and adding it to the concurrent pool, so as to maintain the number of the second requests in the concurrent pool as the preset number.
[0106] In a case where there is an unread second request in the task queue, it means that there is still a second request that has not been sent, and therefore, a new second request is read from the task queue and added to the concurrent pool, so as to send the second request.
[0107] In an embodiment, in a case where there is no unread second request in the task queue, it means that all the second requests in the task queue have been read, and only the second requests in the concurrent pool have not been sent at present, and therefore, only the second requests in the concurrent pool need to be sent at present, so as to realize the sending of all the second requests.
[0108] In the embodiment of the present application, the method for controlling the sending of the second request can keep the number of the second requests in the concurrent pool from exceeding the preset number, realize the sending of the second request in an orderly and controlled manner, effectively improve the processing efficiency of the concurrent request, and reduce the pressure on the backend, prevent the problem of response timeout caused by the high occupation of the memory resources and the central processing unit resources in the backend, and the like.
[0109] Figure 4 The flowchart of another concurrent request processing method provided by the embodiment of the present application is shown in FIG. 5. Figure 4 As shown in FIG. 5, after the step of controlling the sending of the second request to the backend in a preset manner (step S4), the method further includes steps S5-S6.
[0110] In step S5, the second feedback data returned by the backend in response to the second request is received.
[0111] The second feedback data contains the real information corresponding to the target dictionary code.
[0112] In one embodiment, after the front end receives the second feedback data returned by the backend in response to the second request, the method further includes rendering the to-be-rendered form based on the second feedback data, so that the initial values of the components in the to-be-rendered form are updated to the corresponding real information.
[0113] The initial value is the value corresponding to the component in the form when the component is not rendered, which can be a null value or a preset default value.
[0114] In this embodiment, due to the control of the front end on the concurrent multiple requests and the concurrent repeated requests, the pressure on the memory resources and the central processing unit resources of the backend is also reduced, so that the response speed of the second request can be effectively guaranteed, thereby improving the rendering speed of the to-be-rendered form. In some actual tests, the rendering speed can reach the state of second-level rendering.
[0115] In step S6, the second feedback data is stored in the local cache.
[0116] The local cache is a cache that can be directly read by the front end, such as a cache space of a browser or a cache space of a client.
[0117] In the embodiment of the present application, after the second feedback data returned by the backend in response to the second request is received, the second feedback data can be stored in the local cache, so that it can still be used in the subsequent process of requesting the real information corresponding to the dictionary code, thereby improving the request speed of the real information corresponding to the dictionary code.
[0118] Figure 5 The flowchart of another concurrent request processing method provided by the embodiment of the present application is shown in FIG. 5.Figure 5 After storing the second feedback data in the local cache (step S6), the method further includes steps S7-S11.
[0119] In step S7, a second dictionary code corresponding to the new form is obtained in preparation for rendering the new form.
[0120] The new form refers to a new page presented to the user by the front end and operable by the user.
[0121] The second dictionary code refers to the encoding of each component in the new form in a pre-constructed data dictionary, and the data dictionary refers to a maintenance management form of the data table structure, field information, and field attributes used by the form.
[0122] In an embodiment, the second dictionary code can be subjected to a deduplication process. Details of the deduplication process can be found in the aforementioned step of deduplicating the first dictionary code, which will not be described here.
[0123] In step S8, it is determined whether the local cache stores real information corresponding to the second dictionary code.
[0124] The local cache stores the second feedback data, which includes real information corresponding to the dictionary code. Therefore, before sending a network request based on the second dictionary code, it can be determined whether the local cache stores real information corresponding to the second dictionary code.
[0125] In an embodiment, the data stored in the local storage cache in the browser can be obtained by calling a local storage get item instruction (localstorage.getitem). The second dictionary code is used as a keyword to search the second feedback data in the local cache. If the local cache stores real information corresponding to the second dictionary code, it means that the cache is hit, and step S9 is performed. If the local cache does not store real information corresponding to the second dictionary code, it means that the cache is not hit, and step S10 is performed.
[0126] In step S9, the real information corresponding to the second dictionary code is extracted from the local cache for rendering the new form when the local cache stores real information corresponding to the second dictionary code.
[0127] In step S10, a third request corresponding to the second dictionary code is generated when the local cache does not store real information corresponding to the second dictionary code.
[0128] The third request is used to request real information corresponding to the second dictionary code from the back end.
[0129] In step S11, the third request is sent to the back end in a preset manner.
[0130] The preset manner is that the number of concurrent third requests is less than or equal to a preset number.
[0131] In the embodiment, the detailed description of the control of the third request to be sent to the backend in the preset manner can be referred to the aforementioned description of the control of the second request to be sent to the backend in the preset manner, and details are not described herein.
[0132] In another concurrent request processing method provided by the embodiment, in the case of preparing to render a new form, a second dictionary code corresponding to the new form is obtained, and before a third network request is generated based on the second dictionary code, it is queried whether the real information corresponding to the second dictionary code is stored in the local cache. In the case that the real information corresponding to the second dictionary code is stored in the local cache, the real information corresponding to the second dictionary code is extracted from the local cache for rendering the new form. Only in the case that the real information corresponding to the second dictionary code is not stored in the local cache, the corresponding third request is generated based on the second dictionary code, which can further reduce the number of concurrent requests and improve the processing efficiency of the concurrent requests.
[0133] Figure 6 A structure diagram of a concurrent request processing device provided by the embodiment is shown in FIG. 1. Figure 6 As shown in the figure, the device comprises a receiving module 61, a deduplication module 62, a request generation module 63 and a sending control module 64.
[0134] The receiving module 61 is configured to receive first feedback data sent by the backend in response to a first request.
[0135] The first feedback data comprises a plurality of first dictionary codes corresponding to a form to be rendered.
[0136] The deduplication module 62 is configured to perform deduplication processing on the plurality of first dictionary codes to obtain a plurality of target dictionary codes.
[0137] The request generation module 63 is configured to generate a plurality of second requests based on the plurality of target dictionary codes.
[0138] The second request is used to request real information corresponding to the target dictionary code from the backend.
[0139] The sending control module 64 is configured to control the second request to be sent to the backend in a preset manner.
[0140] The preset manner is that the number of concurrent second requests is less than or equal to a preset number.
[0141] In an embodiment, the concurrent request processing device further comprises a storage module and a rendering module.
[0142] The receiving module 61 is further configured to receive second feedback data returned by the backend in response to the second request. The second feedback data includes real information corresponding to the target dictionary code.
[0143] The storage module is configured to store the second feedback data in a local cache.
[0144] The local cache is a cache that can be directly read by the front end, for example, a cache space of a browser or a cache space of a client.
[0145] The rendering module is configured to render the to-be-rendered form based on the second feedback data, so that initial values of components in the to-be-rendered form are updated to corresponding real information.
[0146] In an embodiment, the concurrent request processing apparatus further includes a query module.
[0147] The receiving module 61 is further configured to obtain a second dictionary code corresponding to a new form in a case where the new form is to be rendered.
[0148] The query module is configured to query whether real information corresponding to the second dictionary code is stored in the local cache, and extract the real information corresponding to the second dictionary code from the local cache for rendering the new form in a case where the real information corresponding to the second dictionary code is stored in the local cache.
[0149] The request generation module 63 is further configured to generate a third request corresponding to the second dictionary code based on the second dictionary code in a case where the real information corresponding to the second dictionary code is not stored in the local cache, where the third request is used to request the real information corresponding to the second dictionary code from the backend.
[0150] The sending control module 64 is further configured to control the third request to be sent to the backend in a preset manner.
[0151] An embodiment of the present application provides a concurrent request processing apparatus, wherein a receiving module is configured to receive first feedback data sent by a backend in response to a first request, the first feedback data including a plurality of first dictionary codes corresponding to a to-be-rendered form; a deduplication module is configured to perform deduplication processing on the plurality of first dictionary codes to obtain a plurality of target dictionary codes; a request generation module is configured to generate a plurality of second requests based on the plurality of target dictionary codes, which can effectively reduce the occurrence of repeated requests; wherein the second request is used to request real information corresponding to the target dictionary code from the backend; and a sending control module is configured to control the second request to be sent to the backend in a preset manner, wherein the preset manner is that the number of concurrent second requests is less than or equal to a preset number, which can effectively control the concurrency of multiple requests and improve the processing efficiency of concurrent requests.
[0152] Figure 7 A structural schematic diagram of a computer device is provided for an embodiment of the present application. As shown inFigure 7 As shown in the figure, the computer device can include a processor 701 and a memory 702, wherein the processor 701 and the memory 702 can be connected through a bus or other means, Figure 7 For example, the connection through the bus is taken as an example in the figure.
[0153] The processor 701 can be a central processing unit (CPU). The processor 701 can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. chips, or a combination of the above-mentioned various types of chips.
[0154] The memory 702 as a non-transitory computer readable storage medium can be used to store non-transitory software programs, non-transitory computer executable programs and modules, such as the program instructions / modules corresponding to the concurrent request processing method in the embodiment of the application. The processor 701 executes various functions of the processor and data processing by running the non-transitory software programs, instructions and modules stored in the memory 702, that is, the concurrent request processing method in the above-mentioned method embodiment is realized.
[0155] The memory 702 can include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application required by a function; the data storage area can store data created by the processor 701 and the like. In addition, the memory 702 can include a high-speed random access memory, and can also include a non-transitory memory, such as at least one magnetic disk storage device, a flash memory device, or other non-transitory solid-state storage device. In some embodiments, the memory 702 can optionally include a memory remotely arranged with respect to the processor 701, and these remote memories can be connected to the processor 701 through a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network and a combination thereof.
[0156] One or more modules are stored in the memory 702, and when executed by the processor 701, the concurrent request processing method in the embodiment shown in the figure is executed. Figure 1
[0157] The above-mentioned computer device specific details can be understood by referring to the corresponding related description and effects of the embodiment shown in Figure 1 The figure is not repeated here.
[0158] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a computer readable storage medium. When the program is executed, it can include the processes of the above-mentioned embodiment methods. The storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD), etc. The storage medium can also include a combination of the above-mentioned types of memories.
[0159] Although the embodiments of the present application are described in conjunction with the drawings, various modifications and changes can be made by those skilled in the art without departing from the spirit and scope of the present application, and such modifications and changes fall within the scope defined by the appended claims.
Claims
1. A method of concurrent request processing, characterized by, The method comprises: receiving first feedback data sent by a backend in response to a first request; the first feedback data comprises a plurality of first dictionary codes corresponding to a form to be rendered; de-duplicating the plurality of first dictionary codes to obtain a plurality of target dictionary codes; generating a plurality of second requests based on the plurality of target dictionary codes; the second requests are used to request real information corresponding to the target dictionary codes from the backend; controlling the second requests to be sent to the backend in a preset manner; the preset manner is that the number of concurrent second requests is less than or equal to a preset number.
2. The method of claim 1, wherein, The control of the second requests to be sent to the backend in the preset manner comprises: writing the plurality of second requests into a task queue; reading a preset number of second requests from the task queue and adding the preset number of second requests to a concurrent pool; removing a second request that has been sent from the concurrent pool after the second request in the concurrent pool is completed; determining whether there is an unread second request in the task queue when the number of second requests in the concurrent pool is less than the preset number; reading a new second request from the task queue and adding the new second request to the concurrent pool to keep the number of second requests in the concurrent pool to be the preset number when there is an unread second request in the task queue.
3. The method of claim 2, wherein, The reading of the preset number of second requests from the task queue and the adding of the preset number of second requests to the concurrent pool comprises: reading one second request from the task queue and adding the read second request to the concurrent pool; determining whether the number of second requests in the concurrent pool is less than or equal to the preset number; returning to the reading of one second request from the task queue and the adding of the read second request to the concurrent pool when the number of second requests in the concurrent pool is less than the preset number; suspending the reading of the second request from the task queue when the number of second requests in the concurrent pool is equal to the preset number.
4. The method of claim 1, wherein, The de-duplicating of the plurality of first dictionary codes to obtain the plurality of target dictionary codes comprises: determining an initial index and a current index corresponding to each first dictionary code based on a preset function; removing a first dictionary code whose current index is inconsistent with the initial index and keeping a first dictionary code whose current index is consistent with the initial index as a target dictionary code.
5. The method of claim 1, wherein, After the control of the second requests to be sent to the backend in the preset manner, the method further comprises: receiving second feedback data returned by the backend in response to the second requests; the second feedback data comprises real information corresponding to the target dictionary codes; storing the second feedback data in a local cache.
6. The method of claim 5, wherein, After the storing of the second feedback data in the local cache, the method further comprises: when a new form is prepared to be rendered, obtaining second dictionary codes corresponding to the new form; querying whether real information corresponding to the second dictionary codes is stored in the local cache; and when the real information corresponding to the second dictionary codes is stored in the local cache, rendering the new form based on the real information corresponding to the second dictionary codes. In a case where the real information corresponding to the second dictionary code is stored in the local cache, extracting the real information corresponding to the second dictionary code from the local cache for rendering the new form; In a case where the real information corresponding to the second dictionary code is not stored in the local cache, generating a third request corresponding to the second dictionary code based on the second dictionary code; the third request is used to request the real information corresponding to the second dictionary code from the backend; Controlling the third request to be sent to the backend in the preset manner.
7. The method of claim 5, wherein, After receiving the second feedback data returned by the backend in response to the second request, the method further includes: Based on the second feedback data, rendering the form to be rendered, so that the initial values of each component in the form to be rendered are updated to the real information.
8. A concurrent request processing apparatus characterized by comprising: The apparatus includes: A receiving module configured to receive first feedback data sent by the backend in response to a first request; the first feedback data includes a plurality of first dictionary codes corresponding to a form to be rendered; A deduplication module configured to perform deduplication processing on the plurality of first dictionary codes to obtain a plurality of target dictionary codes; A request generation module configured to generate a plurality of second requests based on the plurality of target dictionary codes; the second request is used to request real information corresponding to the target dictionary code from the backend; A sending control module configured to control the second request to be sent to the backend in a preset manner, and the preset manner is that the number of concurrent second requests is less than or equal to a preset number.
9. A computer device, comprising: comprise: at least one processor; and a memory connected in communication with the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to cause the at least one processor to perform the steps of the concurrent request processing method according to any one of claims 1-7.
10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the concurrent request processing method according to any one of claims 1-7.
Citation Information
Patent Citations
Data sending method and device, electronic equipment and storage medium
CN115033604A
Request management method and device, equipment and storage medium
CN115225717A