Data processing methods, apparatus, equipment and media
By generating a locking request in the data processing system and sending data after successful locking, the problem of server crashes or freezes caused by high-frequency data transmission is solved, and the stability and efficiency of data transmission are improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-28
- Publication Date
- 2026-03-13
AI Technical Summary
When data transmission frequency is high, data processing systems are prone to server crashes or freezes, which are difficult to solve effectively with existing technologies.
By generating a lock request based on the lock identifier and the amount of data to be sent, data is only sent through the sending port after successful locking, and the lock is released in a timely manner when locking fails or data backlog occurs, thus avoiding frequent calls to the sending port.
This reduces or avoids server downtime or freezing during high-frequency data transmission, improving the smoothness and efficiency of data transmission.
Smart Images

Figure CN114296971B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and more particularly to the field of data processing, specifically to a data processing method, apparatus, electronic device, computer-readable storage medium, and computer program product. Background Technology
[0002] A data processing system includes servers and a database. In a distributed data processing system, multiple servers may be located in different places and share database resources. When the data traffic is high, the performance of the data processing system will be affected.
[0003] The methods described in this section are not necessarily methods that had been previously conceived or adopted. Unless otherwise specified, no method described in this section should be assumed to be prior art simply because it is included in this section. Similarly, unless otherwise specified, the issues mentioned in this section should not be considered to be accepted in any prior art. Summary of the Invention
[0004] This disclosure provides a method, apparatus, electronic device, computer-readable storage medium, and computer program product for data processing.
[0005] According to one aspect of this disclosure, a data processing method is provided. The method includes: acquiring at least one piece of data to be sent; acquiring a lock identifier corresponding to the at least one piece of data to be sent and an initial lock value, the initial lock value being the number of the at least one piece of data to be sent; generating a locking request based on the lock identifier and the initial lock value; sending the locking request to a cache server; and, in response to receiving a first feedback from the cache server, sending the at least one piece of data to be sent through a sending port, wherein the first feedback indicates successful locking.
[0006] According to another aspect of this disclosure, a data processing method is provided. The method includes: in response to receiving a locking request from an application server, determining whether there is an unreleased lock, wherein the locking request is generated based on a lock identifier and the quantity of at least one piece of data to be sent; in response to determining that there is no unreleased lock, performing locking based on the lock identifier; and sending a first feedback to the application server, wherein the first feedback indicates that locking was successful.
[0007] According to another aspect of this disclosure, a data processing apparatus is provided. The apparatus includes: a first acquisition unit configured to acquire at least one piece of data to be sent; a second acquisition unit configured to acquire a lock identifier corresponding to the at least one piece of data to be sent and an initial lock value, the initial lock value being the number of the at least one piece of data to be sent; a lock request generation unit configured to generate a lock request based on the lock identifier and the initial lock value; a lock request sending unit configured to send the lock request to a cache server; and a data sending unit configured to send the at least one piece of data to be sent through a sending port in response to receiving a first feedback from the cache server, wherein the first feedback indicates successful locking.
[0008] According to another aspect of this disclosure, a data processing apparatus is provided. The apparatus includes: a determining unit configured to determine, in response to receiving a locking request from an application server, whether there is an unreleased lock, wherein the locking request is generated based on a lock identifier and the quantity of at least one piece of data to be sent; a locking unit configured to perform locking based on the lock identifier in response to determining that there is no unreleased lock; and a locking feedback unit configured to send first feedback to the application server, wherein the first feedback indicates that locking was successful.
[0009] According to another aspect of this disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the data processing method described above.
[0010] According to another aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are used to cause the computer to perform the above-described data processing method.
[0011] According to another aspect of this disclosure, a computer program product is provided, comprising a computer program, wherein the computer program, when executed by a processor, implements the above-described data processing method.
[0012] According to one or more embodiments of this disclosure, server downtime or freezing can be reduced or avoided when data transmission frequency is high.
[0013] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0014] The accompanying drawings exemplify embodiments and form part of the specification, serving together with the textual description to explain exemplary implementations of the embodiments. The illustrated embodiments are for illustrative purposes only and do not limit the scope of the claims. Throughout the drawings, the same reference numerals refer to similar but not necessarily identical elements.
[0015] Figure 1 A flowchart of a data processing method according to an exemplary embodiment of the present disclosure is shown;
[0016] Figure 2 A flowchart of a data processing method according to an exemplary embodiment of the present disclosure is shown;
[0017] Figure 3 A flowchart of a data processing method according to an exemplary embodiment of the present disclosure is shown;
[0018] Figure 4 A flowchart of a data processing method according to an exemplary embodiment of the present disclosure is shown;
[0019] Figure 5 This is a schematic diagram illustrating an example process of sending data using the data processing method of this disclosure;
[0020] Figure 6 A structural block diagram of a data processing apparatus according to an exemplary embodiment of the present disclosure is shown;
[0021] Figure 7 A structural block diagram of a data processing apparatus according to an exemplary embodiment of the present disclosure is shown; and
[0022] Figure 8 A block diagram of an electronic device according to an embodiment of the present disclosure is shown. Detailed Implementation
[0023] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0024] In this disclosure, unless otherwise stated, the use of terms such as "first," "second," etc., to describe various elements is not intended to limit the positional, temporal, or importance relationships of these elements; such terms are merely used to distinguish one element from another. In some examples, the first element and the second element may refer to the same instance of that element, while in other cases, based on the context, they may refer to different instances.
[0025] The terminology used in the description of the various examples described in this disclosure is for the purpose of describing particular examples only and is not intended to be limiting. Unless the context explicitly indicates otherwise, an element may be one or more unless the number of elements is specifically limited. Furthermore, the term "and / or" as used in this disclosure covers any one of the listed items and all possible combinations thereof.
[0026] In related technologies, when too much data needs to be sent in a short period of time, the data processing system may crash or freeze, resulting in data transmission failure.
[0027] The applicant discovered that after the server reads data to be sent from the database or resource files, it performs simple processing on the data before calling the sending port to send the data to the data consumer. When the data sending frequency is low, this usually does not cause the system to freeze. However, when the data sending frequency is high, the server's frequent calls to the sending port cause the port to be unable to process large amounts of data in time, resulting in a large data backlog and ultimately leading to server crashes or freezes.
[0028] To address the aforementioned issues, this disclosure provides a data processing method. After acquiring the data to be sent, a locking request is generated based on the lock identifier and the quantity of data to be sent. Only after successful locking is the data to be sent through the port, thus ensuring that the locked data can be sent smoothly. For data that has not been successfully locked, the application server does not call the sending port, thereby avoiding frequent calls to the sending port by the application server, which could lead to the sending port being unable to process a large amount of data and causing a large backlog of data. This can reduce or prevent server crashes or freezes when the data transmission frequency is high.
[0029] The embodiments of this disclosure will now be described in detail with reference to the accompanying drawings.
[0030] First, refer to Figure 1 and Figure 2 The data processing method 100 executed at the application server is described.
[0031] Figure 1 A flowchart of a data processing method 100 according to an exemplary embodiment of the present disclosure is shown. Figure 1As shown, the data processing method 100 includes: step S110, acquiring at least one piece of data to be sent; step S120, acquiring a lock identifier and an initial lock value corresponding to the at least one piece of data to be sent, wherein the initial lock value is the number of at least one piece of data to be sent; step S130, generating a locking request based on the lock identifier and the initial lock value; step S140, sending the locking request to a cache server; and step S150, in response to receiving a first feedback from the cache server, sending at least one piece of data to be sent through a sending port, wherein the first feedback indicates that the locking was successful.
[0032] Therefore, after acquiring the data to be sent, the application server generates a locking request based on the lock identifier and the quantity of data to be sent, and sends the generated locking request to the cache server to request locking. After successful locking, the application server can send the data to be sent through the port, and the locking process is related to the quantity of data to be sent, thus ensuring that the data to be sent based on the lock can be sent smoothly. During this period, if other data to be sent is acquired by the application server, but locking cannot be successfully achieved based on the other data, the application server will not call the sending port to send the other data, thereby avoiding the application server frequently calling the sending port, which would cause the sending port to be unable to process a large amount of data and cause a large backlog of data. This can reduce or avoid server crashes or freezes when the data sending frequency is high.
[0033] In one example, at least one piece of data to be sent can be data from a database, such as text information of an event to be published; at least one piece of data to be sent can also be data from a resource file, such as an event image or video to be published; at least one piece of data to be sent can also be a real-time short message to be sent.
[0034] According to some embodiments, in step S120, obtaining the lock identifier corresponding to at least one piece of data to be sent may include: generating the lock identifier based on the batch number of at least one piece of data to be sent, and / or based on the user identifier included in at least one piece of data to be sent. Therefore, by generating the lock identifier using the batch number or user identifier associated with the data to be sent, complex calculations are unnecessary, and the lock identifier can be generated more simply. Furthermore, since the batch number or user identifier is unique, the generated lock identifier can uniquely correspond to the data to be sent, thereby making locking based on the lock identifier more accurate and avoiding erroneous locking.
[0035] For example, the data to be sent can be a batch of data (e.g., thousands of data entries). The batch number of this batch of data can be used as a lock identifier, or a lock identifier associated with the batch number can be generated based on the batch number. For example, when the data to be sent is a real-time short message, the short message includes the user identifier (e.g., phone number) of the message sender or recipient. The user identifier can be used as a lock identifier, or a lock identifier associated with the user identifier can be generated based on the user identifier. For example, the lock identifier can be generated based on both the batch number of the data to be sent and the user identifier included in the data to be sent.
[0036] In one example, in step S130, a locking request is generated based on the lock identifier and the quantity of at least one piece of data to be sent, wherein the locking request may include key-value pairs. For example, the lock identifier is used as the key and the quantity of data to be sent is used as the corresponding value.
[0037] According to some embodiments, in step S130, the lock request may include a valid time threshold for the lock. This valid time threshold instructs the cache server to release the lock when the lock duration reaches the threshold. Therefore, in cases such as system program malfunctions and the sending port is occupied for an extended period, the lock can be released promptly when the valid time threshold is reached, thus releasing the occupancy of the sending port and preventing the blocking of other pending messages, ensuring smooth data transmission. It is understood that the valid time threshold for the lock can also be set by the cache server.
[0038] As an example, in step S140, a lock request can be sent to the Redis cache server. For instance, the Redis SETNX or SET command can be used to send a lock request including the key-value pair {key, value}.
[0039] Understandably, the aforementioned lock validity time threshold can be written into a key-value pair as its value. For example, {lock identifier, number of data items to be sent, validity time threshold}. Furthermore, a lock request including this key-value pair can be sent to the cache server.
[0040] Figure 2 A flowchart of a data processing method according to an exemplary embodiment of the present disclosure is shown. Steps S210 to S250 are described above regarding… Figure 1 Steps S110 and S150 are the same as described, and will not be repeated here.
[0041] like Figure 2As shown, according to some embodiments, the data processing method may further include: step S260, sending a feedback message to the cache server according to a preset rule, the feedback message being used to instruct the cache server to update the initial lock value to obtain the updated lock value; and step S270, in response to receiving a second feedback from the cache server, stopping the transmission of data to be sent to the sending port, wherein the second feedback indicates that the lock has been released.
[0042] Specifically, the second feedback is generated by the cache server based on the updated lock value being less than or equal to the release threshold.
[0043] Therefore, the application server sends feedback messages to the cache server according to preset rules. Upon receiving a second feedback message from the cache server indicating that the lock has been released, it stops sending data to the sending port. This ensures that the application server only calls the sending port to send data if the lock is successfully acquired. Once the lock is released, the application server stops calling the sending port, further avoiding frequent calls to the sending port and preventing the port from being occupied for an extended period, thus preventing the transmission of other data. In one example, the initial lock value can be the value in the key-value pair included in the lock request, i.e., the number of data items to be sent.
[0044] According to some embodiments, in step S260 above, sending a feedback message to the cache server according to a preset rule may include: in response to each successful transmission of data to be sent through the sending port, sending a feedback message to the cache server, the feedback message instructing the cache server to decrement the initial lock value by 1 to obtain the updated lock value. The method used for counting at the application server instructs the cache server to decrement the initial lock value by 1 each time data is successfully sent through the port. Therefore, once all data to be sent has been successfully sent through the sending port, the lock can be released promptly, avoiding prolonged occupation of the sending port and reducing the transmission efficiency of other data.
[0045] Furthermore, according to some embodiments, the above steps, in response to each successful transmission of a piece of data to be transmitted through the sending port, sending a feedback message to the cache server may include: incrementing the accumulated value by 1 in response to each successful transmission of a piece of data to be transmitted through the sending port; and decrementing the accumulated value by 1 in response to each successful transmission of a piece of data to be transmitted through the sending port, and the feedback message being a message indicating that the accumulated value has been decremented by 1. Thus, by utilizing the counting function in the application server, after the application server is certain that the sending port has successfully transmitted a piece of data to be transmitted (for example, the application server receives a third feedback from the sending port indicating that the sending port has successfully transmitted a piece of data to be transmitted), the accumulated value is decremented by 1, and a message indicating that the accumulated value has been decremented by 1 is sent back to the cache server. This allows the lock value at the cache server to also be decremented by 1 accordingly, ensuring the successful counting of the number of successfully transmitted data, thereby accurately and promptly stopping the occupation of the sending port.
[0046] According to some embodiments, in step S260, sending a feedback message to the cache server according to a preset rule may include: in response to determining that the number of pending data that has been sent to the sending port but has not been successfully sent is greater than or equal to a preset threshold, sending a feedback message to the cache server, wherein the feedback message is used to instruct the cache server to update the initial lock value based on the preset threshold.
[0047] In some situations, such as due to the capacity limitations of the sending port, data sent from the application server to the sending port may not be sent in a timely manner, resulting in a backlog at the sending port. Therefore, the amount of backlogged data to be sent can be compared with a preset threshold (a user-defined threshold). If the amount of backlogged data to be sent exceeds the preset threshold, the application server can send a feedback message to the cache server, instructing the cache server to update the initial lock value of the lock in a timely manner. This prevents the application server from occupying the port for an extended period of time and causing the server to freeze in the event of data backlog.
[0048] Further, according to some embodiments, in step S260 above, sending a feedback message to the cache server according to a preset rule may include: incrementing the accumulated value by 1 in response to sending each piece of data to the sending port; and in the above steps, in response to determining that the number of data to be sent to the sending port but not successfully sent is greater than or equal to a preset threshold, sending a feedback message to the cache server may include: sending a feedback message to the cache server in response to determining that the accumulated value is greater than or equal to the preset threshold. Thus, by utilizing the counting function in the application server, the accumulated value is incremented by 1 after each piece of data is sent to the sending port. In the event of port congestion, this accumulated value will not receive a third feedback from the sending port, that is, the accumulated value will not decrease accordingly. As the application server continues to send data to the sending port, the accumulated value continues to increase. When the application server determines that the accumulated value is greater than or equal to the preset threshold, it sends a feedback message to the cache server, instructing the cache server to update the lock value accordingly based on the accumulated value (e.g., instructing the cache server to reduce the lock value by the amount of the accumulated value), thereby avoiding prolonged port occupation and server freeze in the event of data congestion at the sending port.
[0049] Furthermore, according to some embodiments, in step S260 above, sending a feedback message to the cache server according to a preset rule may further include: decrementing the accumulated value by 1 in response to receiving a third feedback from the sending port, wherein the third feedback indicates that the sending port has successfully sent a piece of data to be sent. Thus, utilizing the counting function in the application server, after the application server is certain that the third feedback from the sending port (i.e., indicating that the sending port has successfully sent a piece of data to be sent), it decrements the accumulated value by 1 and sends a message of decrementing the accumulated value to the cache server. This allows the lock value at the cache server to also be decremented by 1 accordingly, ensuring that even after congested data is successfully sent, the application server can promptly instruct the cache server to update the lock value, further preventing the server from freezing due to prolonged port occupation when data congestion occurs at the sending port. On the other hand, as data is sent one by one, the accumulated value continuously decreases by 1 until it falls below a preset threshold. If continuous congestion occurs at the sending port, the accumulated value will quickly reach the preset threshold again, and the application server will then send a feedback message to the cache server again, enabling the cache server to accelerate the release of the lock and prevent continuous data congestion from causing the server to freeze.
[0050] Furthermore, according to some embodiments, the data processing method may further include: stopping the transmission of data to be transmitted to the transmission port in response to determining that the number of data to be transmitted that has been sent to the transmission port but has not been successfully transmitted is greater than or equal to a preset threshold. Thus, when the number of data to be transmitted to the transmission port that has been sent but has not been successfully transmitted is greater than or equal to the preset threshold, it can be determined that the transmission port is congested, and the application server stops sending data to the transmission port to avoid the port from receiving more data to be transmitted and becoming stuck due to data congestion.
[0051] Furthermore, according to some embodiments, the data processing method may further include: in response to determining that the number of data to be sent to the sending port but not successfully transmitted is greater than or equal to a preset threshold, starting a timer for congestion duration; and in response to determining that the congestion duration has reached the preset duration, retransmitting the data to be sent to the sending port. Thus, when congestion is determined to occur at the sending port, the application server suspends sending data to the sending port and resumes sending data to the sending port after a certain period of time, giving the sending port sufficient time to process the congested data to be sent, thereby improving data transmission efficiency without causing a freeze or crash.
[0052] The following will refer to Figure 3 and Figure 4 The data processing method 300 executed at the cache server is described.
[0053] Figure 3 A flowchart of a data processing method 300 according to an exemplary embodiment of the present disclosure is shown.
[0054] like Figure 3 As shown, the data processing method 300 includes: step S310, in response to receiving a lock request from the application server, determining whether there is an unreleased lock, wherein the lock request is generated based on a lock identifier and the number of at least one piece of data to be sent; step S320, in response to determining that there is no unreleased lock, performing lock acquisition based on the lock identifier; and step S330, sending a first feedback to the application server, wherein the first feedback indicates that the lock acquisition was successful.
[0055] Therefore, on the one hand, the caching server only performs locking when there are no unreleased locks, ensuring that no two locks exist simultaneously. Only application servers that successfully acquire a lock can call the sending port to send data, while servers that have not successfully acquired a lock must wait for successful locking before calling the sending port to send data. This avoids application servers frequently calling the sending port, causing the sending port to be unable to process large amounts of data and resulting in a large data backlog. This reduces or avoids server crashes or freezes when data transmission frequency is high. On the other hand, since the locking process is related to the amount of data to be sent, the data locked based on this process can be sent successfully.
[0056] It is understood that the locking request mentioned in step S310 can be as described above regarding... Figure 1 , Figure 2 The locking request in method 100 is described.
[0057] As an example, in step S320, at the Redis cache server, based on the SETNX command, in response to the determination that no unlocked lock exists, locking is performed based on the lock identifier. Accordingly, the initial lock value can be the value in the key-value pair {key, value}, i.e., the number of data to be sent.
[0058] Figure 4 A flowchart of a data processing method according to an exemplary embodiment of the present disclosure is shown. Steps S410 to S430 are described above regarding… Figure 3 Steps S310 and S330 are the same as described, and will not be repeated here.
[0059] like Figure 4 As shown, according to some embodiments, the data processing method may further include: step S440, updating the initial lock value in response to receiving a feedback message from the application server to obtain an updated lock value, wherein the initial lock value is the number of at least one data to be sent; step S450, releasing the lock based on the lock identifier in response to the updated lock value being less than or equal to a release threshold; and step S460, sending a second feedback to the application server, wherein the second feedback indicates that the lock has been released.
[0060] Based on the feedback message sent by the application server, the cache server can update the initial lock value. When the updated lock value is less than or equal to the release threshold, the lock is released, thereby causing the application server to stop calling the sending port. This further avoids the application server frequently calling the sending port and also avoids the situation where the sending port is occupied for a long time due to the lock being held for a long time, preventing the sending of other data from being sent.
[0061] Continue to refer to Figure 4According to some embodiments, the locking request may include a valid time threshold for locking. Furthermore, the data processing method may also include: step S470, starting a lock duration timer in response to successful locking; and step S480, releasing the lock in response to the lock duration reaching the valid time threshold.
[0062] Therefore, in cases such as system program malfunctions and the sending port is occupied for an extended period, the lock can be released promptly when the effective time threshold is reached, thus releasing the application server from occupying the sending port and preventing the blocking of other pending messages from being sent.
[0063] The following will refer to Figure 5 The data processing method according to the embodiments of this disclosure will continue to be described in detail.
[0064] Figure 5 This is a schematic diagram illustrating an example process of sending data using the data processing method disclosed herein.
[0065] like Figure 5 As shown, data source 510 can be a database, resource file, or user device sending messages. 520 is the application server; there can be multiple application servers, but for simplicity, only one application server 520 is shown here. 530 is the cache server. 540 is the sending port.
[0066] In scenarios with high data transmission frequency, such as when batch data needs to be sent, data source 510 contains a large amount of data to be sent (e.g., 10,000 data entries). Application server 520 first obtains a batch of data from data source 510 (step S501). A batch of data can be 1,000 data entries. The number of data entries in a batch is determined by application server 520 or the physical characteristics of the data transmission link. Here, we only take 1,000 data entries as an example of a batch of data.
[0067] Further, in step S502, the application server 520 can obtain the lock identifier corresponding to the 1,000 data entries to be sent. For example, the server 520 can use the batch number of the 1,000 data entries to be sent as the lock identifier; or it can generate a corresponding lock identifier based on the batch number (for example, the lock identifier is 001).
[0068] Further, in step S503, the application server 520 can generate a locking request based on the lock identifier 001 and the number of data to be sent, 1000. The locking request may include key-value pairs {001, 1000}. The locking request may also include a lock validity time threshold (e.g., 2 seconds), in which case the locking request may include key-value pairs {001, 1000, 2}. The application server 520 then sends the locking request including the key-value pairs {001, 1000, 2} to the cache server 530.
[0069] Further, the cache server 530 receives a locking request from the application server 520 and determines whether there are any unreleased locks. Here, assuming the cache server 530 determines there are no unreleased locks, it performs locking based on lock identifier 001, thus successfully locking the batch of data with batch number 001. After successful locking, the cache server 530 sends a first feedback (step S504) to the application server 520, notifying the application server 520 of successful locking. At this time, if other application servers send locking requests to the cache server 530, or the same application server 520 sends locking requests to the cache server 530 based on other batches of data, the cache server 530 determines that there are already unreleased locks (i.e., the lock on the batch of data with batch number 001). In this case, it cannot continue locking and can only wait for the lock on the batch of data with batch number 001 to be released before performing a new locking.
[0070] Furthermore, upon receiving the first feedback from the cache server 530, and learning that a batch of data with batch number 001 has been successfully locked, in step S505, the application server 520 sends a batch of data to be sent with batch number 001 to the sending port 540, so as to send this batch of data to the outside world (e.g., a data consumer) through the sending port 540. In this way, the application server avoids intensive calls to the sending port, thereby reducing or avoiding server crashes or freezes when the data sending frequency is high.
[0071] After each data transmission from application server 520 to sending port 540, the internal counting unit of application server 520 increments the accumulated value by 1. When sending port 540 successfully transmits a data transmission, it sends a third feedback (step S506) to application server 520, informing application server 520 that the transmission of a data transmission has been successfully completed. Based on the third feedback, the internal counting unit of application server 520 decrements the accumulated value by 1 accordingly. Correspondingly, application server 520 sends a feedback message to cache server 530, instructing cache server 530 to update the initial lock value (step S507). Assuming that sending port 540 has successfully transmitted 500 data transmissions, based on the received third feedback, application server 520 will decrement the accumulated value 500 times, and cache server 530 will also decrement the initial lock value 500 times, changing the lock value from the initial value of 1000 to 500. As data continues to be successfully sent, the lock value continues to decrease until it decreases to the release threshold (e.g., 0). The cache server 530 releases the lock and sends a second feedback to the application server 520, informing it that the lock for a batch of data with batch number 001 has been released (step S508).
[0072] Furthermore, when there are no unlocked locks, the cache server 530 can execute other locking requests (such as locking requests from other application servers). On the other hand, once the application server 520 learns that the lock has been released, it stops sending data to the sending port 540. At this point, other data that has been successfully locked can be sent to the outside world through the sending port 540, thereby avoiding frequent calls to the sending port 540 by the application server 520.
[0073] In some cases, the sending port 540 may experience temporary congestion. In this situation, the application server 520 may increment the accumulated value to 200 (meaning the application server 520 has sent 200 data packets to the sending port 540), but the sending port 540 may have only successfully sent 50 data packets. Accordingly, the application server 520, based on third feedback, decrements the accumulated value to 150. Assuming that the number of pending data packets sent to the sending port but not successfully transmitted (150) is greater than a preset threshold (e.g., a user-defined threshold of 100), the application server 520 sends a feedback message to the cache server 530, informing the cache server 530 to update the lock value (step S507). The lock value, for example, is reduced by 100 from 1000 to 900. Simultaneously, the application server 520 can pause sending data to the sending port 540 and start timing the congestion duration. Data will only be sent to the sending port 540 again when the congestion duration reaches the preset duration. During the period before the congestion duration reaches the preset duration, the sending port 540 continuously sends the backlogged data to the outside world, allowing the accumulated value of the counting unit of the application server 520 to gradually decrease to less than the preset threshold of 100. During this process, as long as port 540 successfully sends a piece of data, the application server 520 decrements the accumulated value by 1, and correspondingly, the cache server 530 also decrements the lock value by 1 to update the lock value. Once the lock value is less than or equal to the release threshold (e.g., 0), the cache server 530 releases the lock and sends a second feedback to the application server 520, informing it that the lock for batch number 001 of the data has been released (step S508). If continuous congestion occurs at the sending port 540, the accumulated value will quickly reach the preset threshold of 100 again, and the application server 520 will then send a feedback message to the cache server 530 again (step S507) to allow the cache server 530 to update the lock value, thereby accelerating the release of the lock and preventing the server from freezing due to continuous data congestion.
[0074] In some cases, the sending port 540 may be corrupted, or a system program error may occur, preventing the lock from being released in a timely manner. Since the lock request includes a valid lock time threshold (e.g., 2 seconds), the cache server 530 will also release the lock if the lock time exceeds 2 seconds, thus preventing the interface from being occupied for an extended period and causing other data to be unable to be sent normally.
[0075] Figure 6 A structural block diagram of a data processing apparatus 600 according to an exemplary embodiment of the present disclosure is shown.
[0076] According to another aspect of this disclosure, a data processing apparatus 600 is also provided, such as... Figure 6As shown, the data processing apparatus 600 includes: a first acquisition unit 610 configured to acquire at least one piece of data to be sent; a second acquisition unit 620 configured to acquire a lock identifier corresponding to the at least one piece of data to be sent; a lock request generation unit 630 configured to generate a lock request based on the lock identifier and the number of at least one piece of data to be sent; a lock request sending unit 640 configured to send a lock request to a cache server; and a data sending unit 650 configured to send at least one piece of data to be sent through a sending port in response to receiving a first feedback from the cache server, wherein the first feedback indicates that the lock was successfully acquired.
[0077] According to some embodiments, the data processing apparatus 600 may further include: a message feedback unit (not shown in the figure), configured to send a feedback message to a cache server according to a preset rule, the feedback message being used to instruct the cache server to update the initial lock value to obtain an updated lock value; and the data sending unit 650 may be further configured to stop sending data to be sent to the sending port in response to receiving a second feedback from the cache server, wherein the second feedback is generated by the cache server based on the updated lock value being less than or equal to a release threshold, and is used to indicate that the lock is released.
[0078] According to some embodiments, a lock request may include a lock validity time threshold, which is used to instruct the cache server to release the lock when the lock duration reaches the validity time threshold.
[0079] Figure 7 A structural block diagram of a data processing apparatus 700 according to an exemplary embodiment of the present disclosure is shown.
[0080] According to another aspect of this disclosure, a data processing apparatus 700 is also provided, such as... Figure 7 As shown, the data processing apparatus 700 includes: a judgment unit 710 configured to, in response to receiving a locking request from an application server, determine whether there is an unreleased lock, wherein the locking request is generated based on a lock identifier and the number of at least one piece of data to be sent; a locking unit 720 configured to, in response to determining that there is no unreleased lock, perform locking based on the lock identifier; and a locking feedback unit 730 configured to send a first feedback to the application server, wherein the first feedback indicates that the locking was successful.
[0081] According to some embodiments, the data processing apparatus 700 may further include: an update unit (not shown in the figure) configured to update an initial lock value in response to receiving a feedback message from an application server to obtain an updated lock value; a release unit (not shown in the figure) configured to release the lock based on a lock identifier in response to the updated lock value being less than or equal to a release threshold; and a release feedback unit (not shown in the figure) configured to send a second feedback to the application server, wherein the second feedback indicates that the lock has been released.
[0082] According to some embodiments, the locking request may include a valid time threshold for locking, and the data processing device 700 may further include: a locking timing unit (not shown in the figure) configured to start timing the locking duration in response to successful locking; and a release unit may be further configured to release the lock in response to the locking duration reaching the valid time threshold.
[0083] According to another aspect of this disclosure, an electronic device is also provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the data processing method described above.
[0084] According to another aspect of this disclosure, a non-transitory computer-readable storage medium storing computer instructions is also provided, wherein the computer instructions are used to cause the computer to perform the data processing method described above.
[0085] According to another aspect of this disclosure, a computer program product is also provided, comprising a computer program, wherein the computer program, when executed by a processor, implements the above-described data processing method.
[0086] See Figure 8 The following description serves as a structural block diagram of the electronic device 800 disclosed herein, which is an example of a hardware device applicable to various aspects of this disclosure. The electronic device can be different types of computer devices, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the disclosure described and / or claimed herein.
[0087] Figure 8 A block diagram of an electronic device according to an embodiment of the present disclosure is shown. (As follows) Figure 8As shown, the electronic device 800 may include at least one processor 801, working memory 802, I / O device 804, display device 805, storage device 806 and communication interface 807 that are capable of communicating with each other via system bus 803.
[0088] Processor 801 may be a single processing unit or multiple processing units, and all processing units may include single or multiple computing units or multiple cores. Processor 801 may be implemented as one or more microprocessors, microcomputers, microcontrollers, digital signal processors, central processing units, state machines, logic circuits, and / or any device that manipulates signals based on operating instructions. Processor 801 may be configured to acquire and execute computer-readable instructions stored in working memory 802, storage device 806, or other computer-readable media, such as program code of operating system 802a, program code of application program 802b, etc.
[0089] Working memory 802 and storage device 806 are examples of computer-readable storage media for storing instructions that are executed by processor 801 to perform the various functions described above. Working memory 802 may include both volatile and non-volatile memory (e.g., RAM, ROM, etc.). Furthermore, storage device 806 may include hard disk drives, solid-state drives, removable media including external and removable drives, memory cards, flash memory, floppy disks, optical disks (e.g., CDs, DVDs), storage arrays, network-attached storage, storage area networks, etc. Working memory 802 and storage device 806 may be collectively referred to herein as memory or computer-readable storage media, and may be non-transitory media capable of storing computer-readable, processor-executable program instructions as computer program code that can be executed by processor 801 as a specific machine configured to perform the operations and functions described in the examples herein.
[0090] I / O device 804 may include input devices and / or output devices. Input devices may be any type of device capable of inputting information to electronic device 800, and may include, but are not limited to, a mouse, keyboard, touch screen, trackpad, trackball, joystick, microphone, and / or remote control. Output devices may be any type of device capable of presenting information, and may include, but are not limited to, video / audio output terminals, vibrators, and / or printers.
[0091] The communication interface 807 allows the electronic device 800 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks, and may include, but is not limited to, modems, network cards, infrared communication devices, wireless communication transceivers and / or chipsets, such as Bluetooth™ devices, 802.11 devices, WiFi devices, WiMax devices, cellular communication devices and / or the like.
[0092] The application program 802b in the working register 802 can be loaded to execute the various methods and processes described above. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 800 via the storage device 806 and / or the communication interface 807. When the computer program is loaded and executed by the processor 801, one or more steps of the data processing methods described above can be performed.
[0093] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0094] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0095] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0096] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0097] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with embodiments of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0098] A computing system may include clients and servers. Clients and servers are generally located far apart and typically interact through a communication network. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other.
[0099] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially, or in a different order, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.
[0100] While embodiments or examples of this disclosure have been described with reference to the accompanying drawings, it should be understood that the methods, systems, and devices described above are merely exemplary embodiments or examples, and the scope of the invention is not limited by these embodiments or examples, but only by the granted claims and their equivalents. Various elements in the embodiments or examples may be omitted or replaced by their equivalents. Furthermore, the steps may be performed in a different order than that described in this disclosure. Further, various elements in the embodiments or examples may be combined in various ways. Importantly, as the technology evolves, many elements described herein can be replaced by equivalents that appear after this disclosure.
Claims
1. A data processing method, comprising: Obtain at least one piece of data to be sent; Obtain the lock identifier and initial lock value corresponding to the at least one piece of data to be sent, wherein the initial lock value is the number of the at least one piece of data to be sent; Based on the lock identifier and the initial lock value, a lock request is generated; Send the lock request to the cache server; In response to receiving a first feedback from the cache server, the at least one piece of data to be sent is sent through the sending port, wherein the first feedback indicates that the locking was successful; The initial lock value is used to dynamically update during data transmission to reflect the amount of remaining data that was not successfully transmitted at the sending port, and to control data transmission behavior based on the updated lock value. A feedback message is sent to the cache server according to preset rules. This feedback message instructs the cache server to update the initial lock value to obtain the updated lock value. In response to receiving a second feedback from the cache server, the transmission of data to be sent to the sending port is stopped, wherein the second feedback is generated by the cache server based on the updated lock value being less than or equal to a release threshold, and is used to indicate that the lock has been released. Sending feedback messages to the cache server according to preset rules includes: In response to each successful transmission of data to be sent through the sending port, a feedback message is sent to the cache server. The feedback message is used to instruct the cache server to decrement the initial lock value by 1 to obtain the updated lock value. Only when the lock is successfully acquired will the application server call the sending port to send the data to be sent.
2. The method according to claim 1, wherein, In response to each successful transmission of data to be sent through the sending port, the feedback message sent to the caching server includes: In response to each piece of data to be sent to the sending port, the accumulated value is incremented by 1; and In response to each successful transmission of data to be transmitted through the sending port, the accumulated value is decremented by 1, wherein the feedback message is a message indicating that the accumulated value has been decremented by 1.
3. The method according to claim 1, wherein, Feedback messages are sent to the cache server according to preset rules, including: In response to determining that the number of pending data that has been sent to the sending port but has not been successfully sent is greater than or equal to a preset threshold, a feedback message is sent to the cache server, the feedback message being used to instruct the cache server to update the initial lock value based on the preset threshold.
4. The method according to claim 3, wherein, Feedback messages are sent to the cache server according to preset rules, including: In response to each piece of data to be sent to the sending port, the accumulated value is incremented by 1; and Specifically, in response to determining that the number of pending data that has been sent to the sending port but failed to be sent is greater than or equal to a preset threshold, sending the feedback message to the cache server includes: In response to determining that the accumulated value is greater than or equal to the preset threshold, the feedback message is sent to the cache server.
5. The method according to claim 4, wherein, Sending feedback messages to the cache server according to preset rules also includes: In response to receiving a third feedback from the transmitting port, the accumulated value is decremented by 1, wherein the third feedback indicates that the transmitting port has successfully transmitted a piece of data to be transmitted.
6. The method according to claim 1, further comprising: In response to determining that the number of pending data that has been sent to the sending port but has not been successfully sent is greater than or equal to a preset threshold, the sending of pending data to the sending port is stopped.
7. The method of claim 6, further comprising: In response to the determination that the number of pending data that has been sent to the sending port but has not been successfully sent is greater than or equal to the preset threshold, the congestion duration is started to be counted. as well as In response to the determination that the congestion duration has reached a preset duration, the data to be sent is sent to the sending port again.
8. The method according to any one of claims 1-7, wherein, The locking request includes a valid time threshold for locking, which is used to instruct the cache server to release the lock when the locking duration reaches the valid time threshold.
9. The method according to any one of claims 1-7, wherein, Obtaining the lock identifier corresponding to the at least one piece of data to be sent includes: The lock identifier is generated based on the batch number of the at least one data to be sent, and / or based on the user identifier included in the at least one data to be sent.
10. A data processing method, comprising: In response to receiving a lock request from the application server, it is determined whether there is an unreleased lock, wherein the lock request is generated based on a lock identifier and the number of at least one piece of data to be sent; In response to the determination that there are no unlocked locks, locking is performed based on the lock identifier; Send a first feedback to the application server, wherein the first feedback indicates that the lock was successfully acquired; In response to receiving a feedback message from the application server, the initial lock value is updated to obtain an updated lock value, wherein the initial lock value is the number of the at least one piece of data to be sent; In response to the updated lock value being less than or equal to the release threshold, the lock is released based on the lock identifier; and A second feedback is sent to the application server, wherein the second feedback indicates that the lock has been released. The initial lock value is dynamically updated during data transmission to reflect the amount of remaining data that was not successfully transmitted at the sending port, and the updated lock value is used to control data transmission behavior. The feedback message received from the application server is used to instruct the initial lock value to be decremented by 1 to obtain the updated lock value. Specifically, the application server will only call the sending port to send the data to be sent if the locking is successful.
11. The method of claim 10, wherein, The locking request includes a valid time threshold for locking, and the method further includes: In response to successful locking, the lock duration timer begins; and The lock is released in response to the lock duration reaching the effective time threshold.
12. A data processing apparatus, comprising: The first acquisition unit is configured to acquire at least one piece of data to be sent. The second acquisition unit is configured to acquire a lock identifier and an initial lock value corresponding to the at least one data to be sent, wherein the initial lock value is the number of the at least one data to be sent. The lock request generation unit is configured to generate a lock request based on the lock identifier and the initial lock value; The lock request sending unit is configured to send the lock request to the cache server; A data sending unit is configured to send the at least one piece of data to be sent through a sending port in response to receiving a first feedback from the cache server, wherein the first feedback indicates that the locking was successful; A message feedback unit is configured to send a feedback message to a cache server according to preset rules. The feedback message instructs the cache server to update the initial lock value to obtain an updated lock value. The data sending unit is further configured to stop sending data to be sent to the sending port in response to receiving a second feedback from the cache server, wherein the second feedback is generated by the cache server based on the updated lock value being less than or equal to a release threshold, and is used to indicate that the lock has been released. The initial lock value is used to dynamically update during data transmission to reflect the amount of remaining data that was not successfully transmitted at the sending port, and to control data transmission behavior based on the updated lock value. Sending feedback messages to the cache server according to preset rules includes: In response to each successful transmission of data to be sent through the sending port, a feedback message is sent to the cache server. The feedback message is used to instruct the cache server to decrement the initial lock value by 1 to obtain the updated lock value. Only when the lock is successfully acquired will the application server call the sending port to send the data to be sent.
13. The apparatus according to claim 12, wherein, The locking request includes a valid time threshold for locking, which is used to instruct the cache server to release the lock when the locking duration reaches the valid time threshold.
14. A data processing apparatus, comprising: The judgment unit is configured to, in response to receiving a lock request from the application server, determine whether there is an unreleased lock, wherein the lock request is generated based on a lock identifier and the number of at least one piece of data to be sent; The locking unit is configured to perform locking based on the lock identifier in response to determining that there is no unlocked lock; The locking feedback unit is configured to send a first feedback to the application server, wherein the first feedback indicates that the locking was successful; An update unit is configured to update an initial lock value in response to receiving a feedback message from the application server to obtain an updated lock value, wherein the initial lock value is the number of the at least one piece of data to be sent; The release unit is configured to release the lock based on the lock identifier in response to an updated lock value being less than or equal to a release threshold; and The release feedback unit is configured to send a second feedback to the application server, wherein the second feedback indicates that the lock has been released. The initial lock value is dynamically updated during data transmission to reflect the amount of remaining data that was not successfully transmitted at the sending port, and the updated lock value is used to control data transmission behavior. The feedback message received from the application server is used to instruct the initial lock value to be decremented by 1 to obtain the updated lock value. Specifically, the application server will only call the sending port to send the data to be sent if the locking is successful.
15. The apparatus according to claim 14, wherein, The locking request includes a valid time threshold for locking, and the device further includes: The locking timing unit is configured to start timing the locking duration in response to successful locking; and The release unit is further configured to release the lock in response to the lock duration reaching the effective time threshold.
16. An electronic device comprising: At least one processor; as well as A memory that is communicatively connected to the at least one processor; in The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-11.
17. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-11.
18. A computer program product comprising a computer program, wherein, When the computer program is executed by a processor, it implements the method of any one of claims 1-11.
Citation Information
Patent Citations
Method and device used for controlling distributed lock
CN107544850A
Data processing method and device, electronic equipment and storage medium
CN113342539A