Data transmission method, device, electronic device and computer readable storage medium

By introducing data transmission methods and devices in the network environment to manage data transmission between the server and the client, the problem of service crash caused by excessive buffer space usage is solved, and the concurrency performance and user experience of data interaction are improved.

CN115967684BActive Publication Date: 2024-10-25HANGZHOU HIKSTORAGE TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211697098.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-28
Publication Date
2024-10-25
Estimated Expiration
2042-12-28

AI Technical Summary

Technical Problem

In a network environment, the data exchange speed of the server's cache area is fast but the release is slow, causing the memory usage to continue to grow. When the physical memory is exceeded, the service crashes. The existing technology protects the server by killing threads and discarding request data, but the user experience is not good. good.

Method used

By introducing a data transmission method and device between the first device and the client, the data to be transmitted is received and stored in the target cache area according to the corresponding relationship between the client and the interactive data. If the space occupied by the cache area exceeds the threshold, the data is paused or restored. transmission to ensure that the cache areas of different clients are used independently.

Benefits of technology

Effectively control the cache space occupancy corresponding to different clients, improve the concurrency performance of data interaction, avoid directly discarding data and deny service when the cache exceeds the load, and improve user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115967684B_ABST
    Figure CN115967684B_ABST
Patent Text Reader

Abstract

The embodiments of the present invention disclose a data transmission method, device, electronic device and computer-readable storage medium. The method stores the received interactive data to be transmitted to the target client sent by the first device to the target cache area allocated for the target client, and sends the stored data in the target cache area to the target client, and controls the first device to pause / continue sending the interactive data to be transmitted to the second device by comparing the first space occupancy of the stored data / the second space occupancy of the remaining data in the target cache area with the corresponding threshold. The present invention solves the technical problem of directly discarding data and refusing service when the cache area storing interactive data exceeds the load when the first device interacts with multiple clients in the related technology, and achieves the technical effect of effectively controlling the space occupancy of the cache areas corresponding to different clients and improving the concurrent performance of data interaction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data transmission of network equipment, and in particular to a data transmission method, device, electronic equipment and computer-readable storage medium. Background Art

[0002] In a typical network environment, the device is placed in the user's home, plugged into a network cable, and the network speed is fast and stable; the client is connected to 4G outdoors and often moves, so the network speed is relatively slow and unstable. Since the data in the server's cache area is often put in quickly and released slowly, the memory usage of the cache area continues to grow. When the sum of the memory occupied by the cache areas of all client connections exceeds the physical memory of the server, the service will crash. In the prior art, when the server CPU load and memory usage exceed the threshold, the thread is killed, the request data is discarded, and the service is denied to protect the server from crashing due to request overload. However, when the cache area storing interactive data exceeds the load, the data is directly discarded and the service is denied, which is relatively rough. Although the server is protected, the user request is interrupted, the client cannot receive the interactive data, and the user experience is not good.

[0003] To address the above-mentioned problems, no effective solutions have been proposed yet. Summary of the invention

[0004] Embodiments of the present invention provide a data transmission method, apparatus, electronic device, and computer-readable storage medium to at least solve the technical problem in the related art that when a first device interacts with multiple clients, a cache area storing interactive data exceeds the load, directly discarding data and refusing service.

[0005] According to one aspect of an embodiment of the present invention, a data transmission method is provided, which is applied to a second device, wherein the second device is used to forward data between a first device and a client, and the first device supports data interaction with multiple clients. The method includes: receiving interaction data to be transmitted to a target client sent by the first device, and storing the interaction data in a target cache area allocated to the target client according to the correspondence between the client and the interaction data, wherein the target client is any one of the multiple clients, the cache areas corresponding to different clients are not repeated, and the cache areas corresponding to different clients are used independently by each client; if the first space in the target cache area where data has been stored occupies If the usage is greater than a first threshold, a first notification message is sent to the first device, wherein the first notification message is used to instruct the first device to suspend sending the interactive data to be transmitted to the target client to the second device; and send the stored data in the target cache area to the target client; if the second space occupancy of the remaining data in the target cache area is less than a second threshold, a second notification message is sent to the first device, wherein the second notification message is used to instruct the first device to continue sending the interactive data to be transmitted to the target client to the second device, the second threshold is less than the first threshold, and the remaining data in the target cache area refers to the data in the stored data in the target cache area that has not been sent to the target client.

[0006] Optionally, the method also includes: in response to a connection establishment request of the target client, establishing a first connection with the target client for data transmission, wherein different clients respectively transmit data with the second device through the connections established with the second device; receiving a data request sent by the target client through the first connection established with the target client, and forwarding the data request to the first device through the second connection between the first device, so that the first device determines the interactive data to be transmitted to the target client in response to the data request; sending the stored data in the target cache area to the target client, including: sending the stored data in the target cache area to the target client through the first connection established with the target client; receiving the interactive data to be transmitted to the target client sent by the first device, including: receiving the interactive data to be transmitted to the target client sent by the first device through the second connection between the first device.

[0007] Optionally, for different clients, the second connection for data transmission between the first device and the second device is a common data transmission connection; or, for different clients, a second connection corresponding to each client is established between the first device and the second device for data transmission.

[0008] Optionally, when for different clients, a second connection corresponding to each client is established between the first device and the second device respectively, the method further includes: receiving an initialization request sent by the target client through the first connection established with the target client; forwarding the initialization request to the first device through a third connection with the first device, wherein the initialization request is used to instruct the first device to establish a second connection with the second device, wherein the third connection is a TCP long connection, and the second connection is a TCP short connection.

[0009] Optionally, the method also includes: assigning unique identification information to a second connection established between the first device and the second device, wherein the unique identification information corresponds to the target client; storing the interaction data in a target cache area assigned to the target client according to the correspondence between the client and the interaction data, including: distinguishing the interaction data according to the unique identification, and storing the interaction data in the target cache area assigned to the target client.

[0010] Optionally, if the data request sent by the target client is a signaling type request, the interactive data sent by the first device to the second device is response data in response to the signaling type request, and the second connection belonging to the common data transmission connection between the first device and the second device is a TCP long connection; or, if the data request sent by the target client is a file transfer type request, the interactive data sent by the first device to the second device is file data or file processing result data, and the second connection corresponding to the target client established between the first device and the second device is a TCP short connection.

[0011] Optionally, the method also includes: if the first space occupied by the stored data in the target cache area is greater than a third threshold, disconnecting the first connection established with the target client, clearing the stored data in the target cache area, and notifying the first device to discard unsent interaction data, wherein the third threshold is greater than the first threshold.

[0012] According to another aspect of an embodiment of the present invention, a data transmission method is also provided, which is applied to a first device, wherein the first device supports data interaction with multiple clients, and the method includes: determining the interaction data to be transmitted to the target client, and storing the determined interaction data in a target cache area allocated to the target client according to the correspondence between the client and the interaction data, wherein the target client is any one of the multiple clients, the cache areas corresponding to different clients are not repeated, and the cache areas corresponding to different clients are used independently by each client; if the first space occupancy of the stored data in the target cache area is greater than a first threshold, suspending the operation of storing the determined interaction data in the target cache area allocated to the target client; sending the stored data in the target cache area to the target client; if the second space occupancy of the remaining data in the target cache area is less than a second threshold, resuming the operation of storing the determined interaction data in the target cache area allocated to the target client, wherein the second threshold is less than the first threshold, and the remaining data in the target cache area refers to data in the stored data in the target cache area that has not been sent to the target client.

[0013] According to another aspect of an embodiment of the present invention, there is also provided a data transmission device, which is applied to a second device, wherein the second device is used to forward data between a first device and a client, and the first device supports data interaction with multiple clients, and the device includes: a receiving module, which is used to receive interaction data to be transmitted to a target client sent by the first device, and store the interaction data in a target cache area allocated to the target client according to the correspondence between the client and the interaction data, wherein the target client is any one of the multiple clients, the cache areas corresponding to different clients are not repeated, and the cache areas corresponding to different clients are used independently by each client; a first processing module, which is used to process the target cache area if the first space of the data stored in the target cache area occupies If the usage is greater than a first threshold, a first notification message is sent to the first device, wherein the first notification message is used to instruct the first device to suspend sending the interactive data to be transmitted to the target client to the second device; a first sending module is used to send the stored data in the target cache area to the target client; a second processing module is used to send a second notification message to the first device if the second space occupancy of the remaining data in the target cache area is less than a second threshold, wherein the second notification message is used to instruct the first device to continue sending the interactive data to be transmitted to the target client to the second device, the second threshold is less than the first threshold, and the remaining data in the target cache area refers to the data in the stored data in the target cache area that has not been sent to the target client.

[0014] According to another aspect of an embodiment of the present invention, there is also provided a data transmission device, which is applied to a first device, wherein the first device supports data interaction with multiple clients, and the device includes: a determination module, which is used to determine the interaction data to be transmitted to the target client, and store the determined interaction data in a target cache area allocated to the target client according to the correspondence between the client and the interaction data, wherein the target client is any one of the multiple clients, the cache areas corresponding to different clients are not repeated, and the cache areas corresponding to different clients are used independently by each client; a third processing module, which is used to suspend the operation of storing the determined interaction data in the target cache area allocated to the target client if the first space occupancy of the stored data in the target cache area is greater than a first threshold; a second sending module, which is used to send the stored data in the target cache area to the target client; and a fourth processing module, which is used to resume the operation of storing the determined interaction data in the target cache area allocated to the target client if the second space occupancy of the remaining data in the target cache area is less than a second threshold, wherein the second threshold is less than the first threshold, and the remaining data in the target cache area refers to the data in the stored data in the target cache area that has not been sent to the target client.

[0015] According to another aspect of an embodiment of the present invention, there is also provided an electronic device, comprising: a processor; and a memory storing instructions executable by the processor; wherein the processor is configured to execute the steps of any one of the methods described above.

[0016] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is also provided, wherein the computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the steps of any one of the above methods.

[0017] In an embodiment of the present invention, during a process in which a first device interacts with multiple clients, the interaction data to be transmitted to a target client and sent by the first device are stored in a target cache area allocated for the target client, and the stored data in the target cache area are sent to the target client. When the first space occupancy of the stored data in the target cache area is greater than a first threshold, the first device is controlled to suspend sending the interaction data to be transmitted to the target client to the second device; and when the second space occupancy of the remaining data in the target cache area is less than a second threshold, the first device is controlled to continue sending the interaction data to be transmitted to the target client to the second device. Data interaction services can be provided to multiple clients at the same time, thereby solving the technical problem in the related art that when the first device interacts with multiple clients, the cache area storing the interaction data exceeds the load and directly discards the data and refuses the service, thereby achieving the technical effect of effectively controlling the space occupancy of the cache areas corresponding to different clients and improving the concurrent performance of data interaction. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0019] Figure 1 A flowchart of a data transmission method provided by an embodiment of the present invention;

[0020] Figure 2 A schematic diagram of a first device performing data interaction with multiple clients provided in an embodiment of the present invention;

[0021] Figure 3 A schematic diagram of another first device performing data interaction with multiple clients provided in an embodiment of the present invention;

[0022] Figure 4 A flowchart of another data transmission method provided by an embodiment of the present invention;

[0023] Figure 5 A schematic diagram of a data transmission device provided by an embodiment of the present invention;

[0024] Figure 6 A schematic diagram of another data transmission device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0025] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0026] It should be noted that the terms "first", "second", etc. in the specification, claims and drawings of the present invention are used to distinguish different objects rather than to limit a specific order. The steps shown in the flowcharts of the drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0027] According to one aspect of an embodiment of the present invention, a data transmission method is provided, which is applied to a second device, where the second device is used to forward data between a first device and a client, and the first device supports data interaction with multiple clients. Figure 1 A flowchart of a data transmission method provided by an embodiment of the present invention is as follows Figure 1 As shown, the method comprises the following steps:

[0028] Step S102, receiving the interaction data to be transmitted to the target client sent by the first device, and storing the interaction data in a target buffer area allocated to the target client according to the correspondence between the client and the interaction data, wherein the target client is any one of the multiple clients, the buffer areas corresponding to different clients are not repeated, and the buffer areas corresponding to different clients are used independently by each client;

[0029] In other words, when the second device receives the interactive data to be transmitted to the target client sent by the first device, the interactive data is first added to the corresponding target buffer area, and then the stored data in the target buffer area is sent to the corresponding target client, and the data sent to the target client in the target buffer area is deleted to release the memory space of the target buffer area. Optionally, an asynchronous, event-driven Java network programming framework can be used to create an independent buffer area for each client in the second device and assign it to the corresponding client.

[0030] Step S104: if the first space occupied by the data stored in the target cache area is greater than the first threshold, sending a first notification message to the first device, wherein the first notification message is used to instruct the first device to suspend sending the interactive data to be transmitted to the target client to the second device;

[0031] In the process of writing the interactive data to be transmitted to the target client sent by the first device into the target buffer area allocated for the target client, if the first space occupied by the data stored in the target buffer area is greater than the first threshold, the second device will be triggered to send a first notification message to the first device, so that the first device will suspend sending the interactive data to be transmitted to the target client to the second device. In other words, if the first space occupied by the data stored in the target buffer area is greater than the first threshold, the first device will be controlled to suspend sending the interactive data to be transmitted to the target client to the second device.

[0032] Step S106, sending the stored data in the target buffer area to the target client;

[0033] Step S108, if the second space occupied by the remaining data in the target cache area is less than the second threshold, a second notification message is sent to the first device, and the second notification message is used to instruct the first device to continue sending the interactive data to be transmitted to the target client to the second device, and the second threshold is less than the first threshold. The remaining data in the target cache area refers to the data stored in the target cache area that has not been sent to the target client.

[0034] In the process of sending the stored data in the target cache area to the target client, if the second space occupied by the remaining data in the target cache area is less than the second threshold, the second device will be triggered to send the second notification information to the first device, so that the first device continues to send the interactive data to be transmitted to the target client to the second device. In other words, if the second space occupied by the remaining data in the target cache area is less than the second threshold, the first device is controlled to continue to send the interactive data to be transmitted to the target client to the second device.

[0035] It should be noted that the first threshold is the memory space alarm threshold of the target cache area; the second threshold is the memory space free threshold of the target cache area; both the first threshold and the second threshold can be flexibly set according to the needs of the target cache area in the application scenario. Optionally, the value of the first threshold includes but is not limited to 256Kb, 512Kb, etc.; the value of the second threshold includes but is not limited to 32Kb, 64Kb, etc.

[0036] In addition, the above-mentioned first device includes but is not limited to a network hard disk, etc.; the above-mentioned second device includes but is not limited to a cloud server with a public IP, etc.

[0037] In an embodiment of the present invention, during data interaction between a first device and multiple clients, the received interaction data to be transmitted to the target client sent by the first device is stored in the target cache area allocated for the target client, and the stored data in the target cache area is sent to the target client. When the first space occupancy of the stored data in the target cache area is greater than a first threshold, the first device is controlled to suspend sending the interaction data to be transmitted to the target client to the second device; and when the second space occupancy of the remaining data in the target cache area is less than a second threshold, the first device is controlled to continue sending the interaction data to be transmitted to the target client to the second device. Data interaction services can be provided to multiple clients at the same time, thereby solving the technical problem in the related art that when the first device interacts with multiple clients, the cache area storing the interaction data exceeds the load and directly discards the data and refuses the service, thereby achieving the technical effect of effectively controlling the space occupancy of the cache areas corresponding to different clients and improving the concurrent performance of data interaction.

[0038] In an exemplary embodiment, the above method also includes: in response to a connection establishment request of the target client, establishing a first connection with the target client for data transmission, wherein different clients respectively transmit data with the second device through the connections established with the second device; receiving a data request sent by the target client through the first connection established with the target client, and forwarding the data request to the first device through the second connection between the first device, so that the first device determines the interactive data to be transmitted to the target client in response to the data request; sending the stored data in the target cache area to the target client, including: sending the stored data in the target cache area to the target client through the first connection established with the target client; receiving the interactive data to be transmitted to the target client sent by the first device, including: receiving the interactive data to be transmitted to the target client sent by the first device through the second connection between the first device.

[0039] Figure 2 A schematic diagram of a first device performing data interaction with multiple clients provided in an embodiment of the present invention, such as Figure 2As shown, when the first device is turned on, a TCP long connection is established with the first device, and the TCP long connection is maintained through a heartbeat keep-alive mechanism; when the client needs to send a signaling request to the first device, the client establishes a TCP short connection with the second device, and sends the signaling request to the second device, each signaling request corresponds to a session, and the second device assigns an identification information (Session Id) to each client connection; the second device forwards the signaling forwarding messages of multiple sessions to the first device through the same TCP long connection, wherein the signaling forwarding message carries the identification information corresponding to the client; after the first device processes the request, the interactive data of the multiple requests (such as the response data in response to the signaling request) are returned to the second device through the same TCP long connection, wherein the interactive data carries the identification information corresponding to the client; the second device distinguishes according to the identification information in the interactive data, puts the interactive data into the buffer area corresponding to the client connection, and releases the buffer area after sending the interactive data in the buffer area to the client. After the data transmission is completed, the TCP long connection continues to be maintained, waiting for the subsequent request to be processed.

[0040] Figure 3 Another schematic diagram of a first device performing data interaction with multiple clients provided in an embodiment of the present invention is as follows: Figure 3 As shown, when the first device is turned on, it establishes a TCP long connection with the second device, and maintains the TCP long connection through the heartbeat keep-alive mechanism; when the client sends a file transfer request, the client establishes a TCP short connection with the second device, sends an initialization request to the second device, each request corresponds to a session (Session), and the second device assigns an identification information (Session Id) to each client connection, and then all initialization requests are forwarded to the first device through the TCP long connection; the first device establishes a file forwarding connection with the second device, the file forwarding connection is a TCP short connection, and the identification information and the file forwarding connection correspond one to one; then when the client sends a file transfer request to the first device through the second device, the second device forwards the request to the first device through the file forwarding connection corresponding to the identification information; after processing the request, the first device returns the result to the second device through the file forwarding connection corresponding to the identification information; the second device distinguishes according to the identification information, puts the interactive data (such as file data or file processing result data) into the cache area corresponding to the client connection, and releases the cache area after sending the interactive data in the cache area to the client; after the data transmission is completed, the file forwarding connection corresponding to the identification information is disconnected, and the resources are released.

[0041] In an exemplary embodiment, for different clients, the second connection for data transmission between the first device and the second device is a common data transmission connection; or, for different clients, second connections corresponding to each client are respectively established between the first device and the second device for data transmission.

[0042] Optionally, for different clients, if the data request sent by the target client is a signaling request, the second connection for data transmission between the first device and the second device is a shared data transmission connection, and the shared data transmission connection at this time is a TCP long connection; if the data request sent by the target client is a file transfer request, a second connection corresponding to each client is established between the first device and the second device for data transmission, and the second connection at this time is a TCP short connection.

[0043] Among them, under normal circumstances, the amount of transmission data corresponding to the signaling class request is smaller than the amount of transmission data corresponding to the file transfer class request. Therefore, the signaling class requests sent by multiple clients can be transferred to the first device through the same long connection, and all response data in response to the signaling class request are also returned through the same long connection. When a certain client receives slowly, there is no need to suspend the transmission of the entire long connection, and it can be distinguished and controlled according to the unique identification information. At the same time, the first device is in a ready state to ensure fast response and support concurrent access by multiple clients. The file transfer class requests sent by multiple clients are transferred to the first device through separate file forwarding connections (the first device and the second device respectively establish a second connection corresponding to each client), and the interaction data is returned through the corresponding file forwarding connection. The file transfer class request and interaction data corresponding to each client are transmitted independently without affecting each other. When a certain client receives slowly, it is only necessary to suspend the transmission of the corresponding file forwarding connection.

[0044] In an exemplary embodiment, when for different clients, a second connection corresponding to each client is established between the first device and the second device respectively, the above method also includes: receiving an initialization request sent by the target client through the first connection established with the target client; forwarding the initialization request to the first device through a third connection between the first device, wherein the initialization request is used to instruct the first device to establish a second connection with the second device, wherein the third connection is a TCP long connection, the second connection is a TCP short connection, and the first connection is a TCP short connection.

[0045] Although adding the initialization process will increase the response time, establishing an independent file forwarding connection to transmit data for each file transfer request ensures that there is no blocking effect on each other. It also supports the first device to limit the number of concurrent connections supported according to its own resource conditions, thereby limiting the number of concurrent requests.

[0046] It should be noted that TCP long connection means that multiple data packets can be sent continuously on a TCP connection. During the period when TCP long connection is maintained, if no data packet is sent, both parties need to send detection packets to maintain the connection, which generally needs to be maintained online. In addition, TCP long connection can save a lot of TCP establishment and closing operations, reduce resource waste, and save connection time. TCP short connection means that when the two communicating parties have data exchange, a TCP connection is established, and after the data is sent, the TCP connection is disconnected. In addition, TCP short connection management is relatively simple, and all existing connections are useful connections, and no additional control means are required.

[0047] In an exemplary embodiment, the above method also includes: assigning unique identification information to a second connection established between the first device and the second device, wherein the unique identification information corresponds to a target client; according to the correspondence between the client and the interaction data, storing the interaction data in a target cache area assigned to the target client, including: distinguishing the interaction data according to the unique identification, and storing the interaction data in the target cache area assigned to the target client.

[0048] Optionally, the unique identification information may be a session identifier of a session created for the target client. A session represents the entire process from a data request sent by a client to obtaining interactive data of the request message.

[0049] In the above-mentioned embodiment of the present invention, by assigning unique identification information to the second connection established between the first device and the second device, distinguishing the interaction data according to the unique identification, and storing the interaction data in the target cache area assigned to the target client, data interaction services can be provided to more clients at the same time, and the concurrency performance of data interaction can be improved.

[0050] In an exemplary embodiment, if the data request sent by the target client is a signaling type request, the interactive data sent by the first device to the second device is response data in response to the signaling type request, and the second connection belonging to the shared data transmission connection between the first device and the second device is a TCP long connection; or, if the data request sent by the target client is a file transfer type request, the interactive data sent by the first device to the second device is file data or file processing result data, and the second connection corresponding to the target client established between the first device and the second device is a TCP short connection.

[0051] Optionally, if the data request sent by the target client is a signaling request, and the first space occupancy of the data stored in the target cache area is greater than a first threshold, the second device notifies the first device via a TCP long connection so that the first device suspends sending the interactive data to be transmitted to the target client (for example, response data in response to the signaling request) to the second device; further, if the second space occupancy of the remaining data in the target cache area is less than a second threshold, the second device notifies the first device via a TCP long connection so that the first device resumes sending the interactive data to be transmitted to the target client (response data in response to the signaling request) to the second device.

[0052] It should be noted that since signaling requests and their response data are small, but large in number and time-sensitive, although the speed is slowed down through the above implementation method, the processing of the entire signaling request is not interrupted, and the client will receive complete response data to the signaling request, thereby improving the user experience.

[0053] Optionally, if the data request sent by the target client is a file transfer request, and the first space occupancy of the data stored in the target cache area is greater than a first threshold, the second device actively suspends receiving the interactive data (such as file data or file processing result data) to be transmitted to the target client from the second device through the TCP short connection, and notifies the first device based on the congestion control mechanism of the TCP short connection, so that the first device suspends sending the interactive data (file data or file processing result data) to be transmitted to the target client to the second device; further, if the second space occupancy of the remaining data in the target cache area is less than the second threshold, the interactive data (file data or file processing result data) to be transmitted to the target client from the second device through the TCP short connection is resumed, and the first device is notified based on the congestion control mechanism of the TCP short connection, so that the first device resumes sending the interactive data (file data or file processing result data) to be transmitted to the target client to the second device.

[0054] It should be noted that since file transfer requests are small, the response data is large, the number is relatively small, and it is not sensitive to time, the above implementation method can distinguish and control the first space occupancy of the stored data in the target cache area corresponding to each file forwarding connection. When the total memory of the server remains unchanged, it can provide data interaction services to more clients and improve the concurrency performance of data interaction.

[0055] In an exemplary embodiment, the above method also includes: if the first space occupied by the stored data in the target cache area is greater than a third threshold, disconnecting the first connection established with the target client, clearing the stored data in the target cache area, and notifying the first device to discard the unsent interaction data, wherein the third threshold is greater than the first threshold.

[0056] The third threshold is the target cache memory space red line, indicating the limit value of the first space occupied by the stored data in the target cache, and its value includes but is not limited to 5Mb. The third threshold can be flexibly set according to the needs of the target cache in the application scenario.

[0057] Optionally, if the data request sent by the target client is a signaling request, the second device sends a first notification message to the first device via a TCP long connection, so that the first device suspends sending the interactive data to be transmitted to the target client to the second device. However, considering that the application layer message may be lost and the first device is not notified, if the first device does not receive the notification message of suspending the sending of the response data to the second device in response to the signaling request, it will not suspend sending the interactive data to be transmitted to the target client to the second device, and the second device continues to store the interactive data in the target cache area allocated to the target client according to the correspondence between the client and the interactive data, and the situation will occur that the first space occupied by the stored data in the target cache area is greater than the third threshold. If the first space occupied by the stored data in the target cache area is greater than the third threshold, the second device will actively disconnect the first connection established with the target client, clear the stored data in the target cache area, and notify the first device to discard the unsent interactive data.

[0058] It should be noted that, since the second connection of the shared data transmission connection between the first device and the second device is a TCP long connection, if the TCP long connection is disconnected, other clients will not be able to obtain the interactive data. Therefore, the TCP long connection maintains the communication state, and the first connection established with the target client is disconnected. Then the target client can resend the connection establishment request and data request, and then the second device will re-establish the first connection with the target client, and directly receive the interactive data to be transmitted to the target client sent by the first device through the TCP long connection, effectively avoiding the impact on the data interaction of other clients. In other words, after the first connection established with the target client is forcibly disconnected, the TCP long connection between the first device and the second device is still maintained, and a new first connection is established with the target client through the second device. The client can still resend a new data request, and the second device will transfer it to the first device for further processing.

[0059] In addition, if the data request sent by the target client is a file transfer request, and the first space occupied by the data stored in the target buffer area is greater than the first threshold, the second device actively suspends receiving the interactive data sent by the first device to be transmitted to the target client through the TCP short connection, so the situation where the first space occupied by the data stored in the target buffer area is greater than the third threshold will not occur. In other words, the congestion control mechanism based on the TCP short connection is transmitted to the device, and no information loss will occur, and the third threshold does not need to be set.

[0060] According to another aspect of an embodiment of the present invention, a data transmission method is provided, which is applied to a first device, wherein the first device supports data interaction with multiple clients. Figure 4 A flowchart of another data transmission method provided by an embodiment of the present invention, such as Figure 4 As shown, the method comprises the following steps:

[0061] Step S402, determining the interaction data to be transmitted to the target client, and storing the determined interaction data in a target buffer area allocated to the target client according to the correspondence between the client and the interaction data, wherein the target client is any one of a plurality of clients, the buffer areas allocated to different clients are not repeated, and the buffer areas corresponding to different clients are used independently by each client;

[0062] Step S404: if the first space occupied by the data stored in the target buffer area is greater than the first threshold, suspending the operation of storing the determined interaction data in the target buffer area allocated to the target client;

[0063] Step S406, sending the stored data in the target buffer area to the target client;

[0064] Step S408, if the second space occupied by the remaining data in the target cache area is less than the second threshold, the operation of storing the determined interaction data in the target cache area allocated to the target client is resumed, wherein the second threshold is less than the first threshold, and the remaining data in the target cache area refers to the data in the stored data in the target cache area that has not been sent to the target client.

[0065] In an embodiment of the present invention, during data interaction between a first device and multiple clients, determined interaction data to be transmitted to a target client is stored in a target cache area allocated for the target client, and the stored data in the target cache area is sent to the target client. When a first space occupancy of the stored data in the target cache area is greater than a first threshold, the first device is controlled to suspend the operation of storing the determined interaction data in the target cache area allocated for the target client; and when a second space occupancy of the remaining data in the target cache area is less than a second threshold, the first device is controlled to resume the operation of storing the determined interaction data in the target cache area allocated for the target client. This allows data interaction services to be provided to multiple clients simultaneously, thereby solving the technical problem in the related art that when the first device interacts with multiple clients, the cache area storing interaction data exceeds the load and directly discards data and refuses service, thereby achieving the technical effect of effectively controlling the space occupancy of the cache areas corresponding to different clients and improving the concurrent performance of data interaction.

[0066] According to another aspect of an embodiment of the present invention, a data transmission device is further provided, which is applied to a second device, the second device is used to forward data between a first device and a client, and the first device supports data interaction with multiple clients. Figure 5 A schematic diagram of a data transmission device provided by an embodiment of the present invention is shown in FIG. Figure 5 As shown, the data transmission device includes: a receiving module 52, a first processing module 54, a first sending module 56 and a second processing module 58. The data transmission device is described in detail below.

[0067] The receiving module 52 is used to receive the interaction data to be transmitted to the target client sent by the first device, and store the interaction data in the target buffer area allocated to the target client according to the correspondence between the client and the interaction data, wherein the target client is any one of the multiple clients, the buffer areas corresponding to different clients are not repeated, and the buffer areas corresponding to different clients are used independently by each client;

[0068] A first processing module 54 is connected to the receiving module 52, and is used to send a first notification message to the first device if the first space occupied by the data stored in the target buffer area is greater than a first threshold, wherein the first notification message is used to instruct the first device to suspend sending the interactive data to be transmitted to the target client to the second device;

[0069] A first sending module 56, connected to the first processing module 54, for sending the stored data in the target buffer area to the target client;

[0070] The second processing module 58 is connected to the above-mentioned first sending module 56, and is used to send a second notification message to the first device if the second space occupancy of the remaining data in the target cache area is less than the second threshold value, and the second notification message is used to instruct the first device to continue sending the interactive data to be transmitted to the target client to the second device, and the second threshold value is less than the first threshold value. The remaining data in the target cache area refers to the data stored in the target cache area that has not been sent to the target client.

[0071] In an embodiment of the present invention, during data interaction between a first device and multiple clients, the data transmission device stores the received interaction data to be transmitted to the target client sent by the first device to the target cache area allocated for the target client, and sends the stored data in the target cache area to the target client. When the first space occupancy of the stored data in the target cache area is greater than the first threshold, the first device is controlled to suspend sending the interaction data to be transmitted to the target client to the second device; and when the second space occupancy of the remaining data in the target cache area is less than the second threshold, the first device is controlled to continue sending the interaction data to be transmitted to the target client to the second device. Data interaction services can be provided to multiple clients at the same time, thereby solving the technical problem in the related technology that when the first device interacts with multiple clients, the cache area storing the interaction data exceeds the load and directly discards the data and refuses the service, thereby achieving the technical effect of effectively controlling the space occupancy of the cache areas corresponding to different clients and improving the concurrent performance of data interaction.

[0072] It should be noted here that the above-mentioned receiving module 52, the first processing module 54, the first sending module 56 and the second processing module 58 correspond to steps S102 to S108 in the method embodiment, and the examples and application scenarios implemented by the above-mentioned modules are the same as the corresponding steps, but are not limited to the contents disclosed in the above-mentioned method embodiment.

[0073] According to another aspect of an embodiment of the present invention, a data transmission device is provided, which is applied to a first device, and the first device supports data interaction with multiple clients. Figure 6 A schematic diagram of another data transmission device provided by an embodiment of the present invention, such as Figure 6 As shown, the data transmission device includes: a determination module 62, a third processing module 64, a second sending module 66 and a fourth processing module 68. The data transmission device is described in detail below.

[0074] A determination module 62 is used to determine the interaction data to be transmitted to the target client, and store the determined interaction data in a target buffer area allocated to the target client according to the correspondence between the client and the interaction data, wherein the target client is any one of the multiple clients, the buffer areas allocated to different clients are not repeated, and the buffer areas corresponding to different clients are used independently by each client;

[0075] A third processing module 64, connected to the determination module 62, is used for suspending the operation of storing the determined interaction data in the target buffer area allocated to the target client if the first space occupied by the stored data in the target buffer area is greater than the first threshold;

[0076] A second sending module 66, connected to the third processing module 64, for sending the stored data in the target buffer area to the target client;

[0077] The fourth processing module 68 is connected to the above-mentioned second sending module 66, and is used to resume the operation of storing the determined interaction data in the target cache area allocated to the target client if the second space occupancy of the remaining data in the target cache area is less than the second threshold, wherein the second threshold is less than the first threshold, and the remaining data in the target cache area refers to the data in the stored data in the target cache area that has not been sent to the target client.

[0078] In an embodiment of the present invention, during data interaction between a first device and multiple clients, the data transmission device stores the determined interaction data to be transmitted to the target client in a target cache area allocated for the target client, and sends the stored data in the target cache area to the target client. When the first space occupancy of the stored data in the target cache area is greater than a first threshold, the first device is controlled to suspend the operation of storing the determined interaction data in the target cache area allocated for the target client; and when the second space occupancy of the remaining data in the target cache area is less than a second threshold, the first device is controlled to resume the operation of storing the determined interaction data in the target cache area allocated for the target client. This can provide data interaction services for multiple clients at the same time, thereby solving the technical problem in the related art that when the first device interacts with multiple clients, the cache area storing the interaction data exceeds the load and directly discards the data and refuses the service, thereby achieving the technical effect of effectively controlling the space occupancy of the cache areas corresponding to different clients and improving the concurrent performance of data interaction.

[0079] It should be noted here that the above-mentioned determination module 62, the third processing module 64, the second sending module 66 and the fourth processing module 68 correspond to steps S402 to S408 in the method embodiment, and the examples and application scenarios implemented by the above-mentioned modules are the same as the corresponding steps, but are not limited to the contents disclosed in the above-mentioned method embodiment.

[0080] According to another aspect of an embodiment of the present invention, there is also provided an electronic device, comprising: a processor; and a memory storing instructions executable by the processor; wherein the processor is configured to execute the steps of any one of the above methods.

[0081] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium including a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the steps of any one of the above methods.

[0082] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0083] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0084] In the several embodiments provided by the present invention, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the modules can be a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the modules can be electrical or other forms.

[0085] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed on multiple modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment.

[0086] In addition, each functional module in each embodiment of the present invention may be integrated into one processing module, or each module may exist physically separately, or two or more modules may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of software functional modules.

[0087] If the integrated module is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned computer-readable storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk, etc., various media that can store program codes.

[0088] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A data transmission method, characterized in that: Applied to a second device, the second device is used to forward data between a first device and a client, the first device supports data interaction with multiple clients, and the method includes: receiving the interaction data to be transmitted to the target client sent by the first device, and storing the interaction data in a target buffer area allocated to the target client according to the correspondence between the client and the interaction data, wherein the target client is any one of the multiple clients, the buffer areas allocated to different clients are not repeated, and the buffer areas corresponding to different clients are used independently by each client; If the first space occupied by the data stored in the target buffer area is greater than a first threshold, sending a first notification message to the first device, wherein the first notification message is used to instruct the first device to suspend sending the interaction data to be transmitted to the target client to the second device; Sending the stored data in the target buffer area to the target client; If the second space occupied by the remaining data in the target cache area is less than a second threshold, a second notification message is sent to the first device, and the second notification message is used to instruct the first device to continue sending the interactive data to be transmitted to the target client to the second device. The second threshold is less than the first threshold. The remaining data in the target cache area refers to the data stored in the target cache area that has not been sent to the target client.

2. The method according to claim 1, characterized in that The method further comprises: In response to a connection establishment request of the target client, establish a first connection with the target client for data transmission, wherein different clients respectively perform data transmission with the second device through the connections established with the second device; receiving a data request sent by the target client through a first connection established with the target client, and forwarding the data request to the first device through a second connection with the first device, so that the first device determines the interaction data to be transmitted to the target client in response to the data request; Sending the stored data in the target buffer area to the target client includes: Sending the stored data in the target buffer area to the target client through a first connection established with the target client; Receiving the interaction data sent by the first device to be transmitted to the target client includes: The interactive data to be transmitted to the target client and sent by the first device is received through the second connection with the first device.

3. The method according to claim 2, characterized in that For different clients, the second connection for data transmission between the first device and the second device is a shared data transmission connection; or, For different clients, second connections corresponding to respective clients are established between the first device and the second device for data transmission.

4. The method according to claim 3, characterized in that In the case where, for different clients, the first device and the second device respectively establish second connections corresponding to respective clients, the method further includes: Receiving an initialization request sent by the target client through a first connection established with the target client; The initialization request is forwarded to the first device via a third connection with the first device, wherein the initialization request is used to instruct the first device to establish a second connection with the second device, wherein the third connection is a TCP long connection and the second connection is a TCP short connection.

5. The method according to claim 4, characterized in that The method further comprises: Allocating unique identification information to a second connection established between the first device and the second device, wherein the unique identification information corresponds to the target client; According to the correspondence between the client and the interaction data, the interaction data is stored in a target buffer area allocated for the target client, including: The interaction data is distinguished according to the unique identifier, and the interaction data is stored in a target cache area allocated to the target client.

6. The method according to claim 3, characterized in that If the data request sent by the target client is a signaling request, the interaction data sent by the first device to the second device is response data in response to the signaling request, and the second connection belonging to the shared data transmission connection between the first device and the second device is a TCP long connection; or, If the data request sent by the target client is a file transfer request, the interactive data sent by the first device to the second device is file data or file processing result data, and the second connection corresponding to the target client established between the first device and the second device is a TCP short connection.

7. The method according to claim 1, characterized in that The method further comprises: If the first space occupied by the stored data in the target cache area is greater than a third threshold, the first connection established with the target client is disconnected, the stored data in the target cache area is cleared, and the first device is notified to discard the unsent interaction data, wherein the third threshold is greater than the first threshold.

8. A data transmission method, characterized in that: Applied to a first device, the first device supports data interaction with multiple clients, and the method includes: Determine the interaction data to be transmitted to the target client, and store the determined interaction data in a target buffer area allocated to the target client according to the correspondence between the client and the interaction data, wherein the target client is any one of the multiple clients, the buffer areas allocated to different clients are not repeated, and the buffer areas corresponding to different clients are used independently by each client; If the first space occupied by the stored data in the target cache area is greater than the first threshold, suspending the operation of storing the determined interaction data in the target cache area allocated to the target client; Sending the stored data in the target buffer area to the target client; If the second space occupancy of the remaining data in the target cache area is less than a second threshold, the operation of storing the determined interaction data in the target cache area allocated to the target client is resumed, wherein the second threshold is less than the first threshold, and the remaining data in the target cache area refers to data in the stored data in the target cache area that has not been sent to the target client.

9. A data transmission device, characterized in that: Applied to a second device, the second device is used to forward data between a first device and a client, the first device supports data interaction with multiple clients, and the apparatus includes: a receiving module, configured to receive the interaction data to be transmitted to the target client sent by the first device, and store the interaction data in a target buffer area allocated to the target client according to the correspondence between the client and the interaction data, wherein the target client is any one of the multiple clients, the buffer areas allocated to different clients are not repeated, and the buffer areas corresponding to different clients are used independently by each client; A first processing module, configured to send a first notification message to the first device if a first space occupied by the data stored in the target cache area is greater than a first threshold, wherein the first notification message is used to instruct the first device to suspend sending the interaction data to be transmitted to the target client to the second device; A first sending module, used for sending the stored data in the target buffer area to the target client; A second processing module is used to send a second notification message to the first device if the second space occupied by the remaining data in the target cache area is less than a second threshold, and the second notification message is used to instruct the first device to continue sending the interactive data to be transmitted to the target client to the second device, and the second threshold is less than the first threshold. The remaining data in the target cache area refers to the data stored in the target cache area that has not been sent to the target client.

10. A data transmission device, characterized in that: Applied to a first device, the first device supports data interaction with multiple clients, and the apparatus includes: A determination module, used to determine the interaction data to be transmitted to the target client, and store the determined interaction data in a target buffer area allocated to the target client according to the correspondence between the client and the interaction data, wherein the target client is any one of the multiple clients, the buffer areas allocated to different clients are not repeated, and the buffer areas corresponding to different clients are used independently by each client; a third processing module, configured to suspend the operation of storing the determined interaction data in the target buffer area allocated to the target client if the first space occupied by the stored data in the target buffer area is greater than a first threshold; A second sending module, used for sending the stored data in the target buffer area to the target client; A fourth processing module is used to resume the operation of storing the determined interaction data in the target cache area allocated to the target client if the second space occupancy of the remaining data in the target cache area is less than a second threshold, wherein the second threshold is less than the first threshold, and the remaining data in the target cache area refers to data in the stored data in the target cache area that has not been sent to the target client.

11. An electronic device, characterized in that: include: processor; A memory storing processor executable instructions; wherein the processor is configured to perform the steps of the method according to any one of claims 1 to 8.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the steps of any one of the methods of claims 1 to 8.