A method, system, device, and medium for migrating a client TCP connection
By introducing proxy servers into the IoT server cluster, the client's insensitive TCP connection migration is realized, which solves the problem of loss of reconnection data and high reconnection costs during server offline maintenance, and improves migration efficiency and data integrity.
Patent Information
- Application Number
- CN202510174550.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-18
- Publication Date
- 2025-07-01
- Estimated Expiration
- 2045-02-18
AI Technical Summary
In the IoT server cluster, since the server needs to be temporarily offline maintenance, there are problems such as loss of reconnection data and high reconnection costs during the client TCP connection migration process.
By introducing a proxy server between the server and the client, the proxy server can be controlled to migrate a specified TCP connection from one server to another server, realizing client-insensitive TCP connection migration. The specific steps include the old server electrically connecting to the new server through a proxy server, obtaining downstream data and upstream data, determining the transmission status, and migrating unsent and unprocessed data to the new server.
It realizes client-insensitive TCP connection migration, solves the problem of loss of reconnection data and high reconnection costs, and improves migration efficiency and data integrity.
Smart Images

Figure CN119652953B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technologies, and in particular, to a method, system, device, and medium for migrating a client TCP connection. Background Art
[0002] Due to the particularity of the Internet of Things, the Internet of Things server (cluster) needs to maintain a large number (in the millions or billions) of TCP long connections with a large number (in the millions or billions) of devices. A TCP long connection refers to a long-existing connection established between a client and a server, during which the client and the server can continuously perform multiple data interactions without having to re-establish the connection each time.
[0003] However, in the actual production environment, the server needs to be taken offline for maintenance briefly due to various reasons (service function upgrade, patch repair, security patch, server physical migration, server scale-out / scale-in). Therefore, there is an urgent need for a method, system, device, and medium for migrating a client TCP connection to migrate server users to other clusters or other servers in the same cluster to achieve a seamless migration of the client TCP connection. Summary of the Invention
[0004] Embodiments of this application provide a method, system, and medium for migrating a client TCP connection to at least solve the above problems.
[0005] In a first aspect, embodiments of this application provide a method for migrating a client TCP connection, including an old server and a new server, where the old server is electrically connected to the new server through a proxy server; the method includes:
[0006] In response to the proxy server receiving a migration instruction, obtaining downstream data from the old server, where the downstream data is data sent from the old server to the proxy server;
[0007] The proxy server sends the migration point of the downstream data and the initial migration point of the upstream data as a stream header to the new server;
[0008] The new server remotely invokes the old server, and the old server obtains upstream data according to the upstream data migration point;
[0009] Based on the downstream data and the upstream data, determining the transmission status of the downstream and upstream streams, and based on the transmission status, the old server migrates the downstream data that has not been sent to the client and the upstream data uploaded by the client that has not been processed to the new server.
[0010] In an embodiment, obtaining downstream data from the old server includes:
[0011] The old server obtains the unsent data of the downstream stream from the buffer, where the unsent data of the downstream stream includes the data in the send buffer, the data in flight, and the data that has been determined not to be received;
[0012] Record the sent data according to the counter, and based on the unsent data of the downstream stream, determine the initial data migration point of the downstream stream confirmed by the proxy server to be received;
[0013] The old server informs the proxy server of receiving the initial data migration point of the downstream stream through an out-of-band control channel;
[0014] The proxy server obtains the target data migration point of the downstream stream and informs the old server through an out-of-band control channel;
[0015] Confirm the unsent data and the sent data of the target downstream stream through the target data migration point of the downstream stream, and use the unsent data of the target downstream stream as the downstream stream data.
[0016] In one embodiment, the new server remotely calls the old server, and the old server obtains the upstream stream data according to the upstream stream data migration point, including:
[0017] After the new server processes the stream header, it makes a remote call to the old server;
[0018] Obtain the unprocessed data of the unsent upstream stream from the buffer of the proxy server, where the unprocessed data of the unsent upstream stream includes the data in the send buffer, the data in flight, and the data that has been determined not to be received;
[0019] Record the sent data according to the counter, and based on the unprocessed data of the upstream stream, determine the initial data migration point of the upstream stream confirmed by the proxy server to be received;
[0020] The old server informs the proxy server of receiving the initial data migration point of the upstream stream through an out-of-band control channel;
[0021] The proxy server obtains the target data migration point of the upstream stream and informs the old server through an out-of-band control channel;
[0022] Confirm the unprocessed data of the unsent target upstream stream and the unprocessed data that has been sent through the target data migration point of the upstream stream, and use the unprocessed data of the unsent target upstream stream as the upstream stream data.
[0023] In one embodiment, the step of recording the sent data according to the counter and determining the initial data migration point of the downstream stream confirmed by the proxy server to be received based on the unsent data of the downstream stream includes:
[0024] Determine the initial data migration point of the downlink stream confirmed to be received by the proxy server according to the difference between the transmitted data recorded by the counter and the untransmitted data of the downlink stream.
[0025] In one embodiment, the proxy server obtains the target data migration point of the downlink stream, including:
[0026] When the offset of the received migration point by the proxy server is greater than or equal to the initial offset, obtain the target data migration point of the downlink stream; wherein,
[0027] When the offset of the received migration point by the proxy server is less than the initial offset, pull the untransmitted data of the downlink stream from the receive buffer until the offset is greater than or equal to the initial offset.
[0028] In one embodiment, confirming the untransmitted data of the target downlink stream through the target data migration point of the downlink stream includes:
[0029] Confirm the untransmitted data of the target downlink stream according to the difference between the transmitted data recorded by the counter and the target data migration point of the downlink stream; wherein,
[0030] The transmitted data recorded by the counter is the total byte data transmitted, and the target data migration point of the downlink stream is the byte data that has been confirmed to be received.
[0031] In one embodiment, before obtaining the downlink stream data from the old server in response to the proxy server receiving a migration instruction, the method further includes:
[0032] In response to migrating data from the old server to the new server, the old server sends a migration instruction to the proxy server through a remote call channel and sends the address information of the new server to the proxy server.
[0033] In a second aspect, an embodiment of the present application provides a migration system for a client TCP connection, including an old server and a new server, and the old server is electrically connected to the new server through a proxy server; the system includes a downlink stream data acquisition module, a flow header sending module, an uplink stream data acquisition module, and a migration module, wherein:
[0034] The downlink stream data acquisition module is configured to obtain downlink stream data from the old server in response to the proxy server receiving a migration instruction, and the downlink stream data is data sent from the old server to the proxy server;
[0035] The flow header sending module is configured to send the migration point of the downlink stream data and the initial data migration point of the uplink stream as a flow header to the new server by the proxy server;
[0036] The module for obtaining uplink data is used for the new server to remotely call the old server, and the old server obtains uplink data according to the uplink data migration point.
[0037] The migration module is used to determine the transmission status of the downlink and uplink based on the downlink data and the uplink data. Based on the transmission status, the old server migrates the downlink data that has not been sent to the client and the uplink data uploaded by the client that has not been processed to the new server.
[0038] In a third aspect, an embodiment of the present application provides a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, it implements a method for migrating a client TCP connection as described in the first aspect above.
[0039] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, it implements a method for migrating a client TCP connection as described in the first aspect above.
[0040] The method, system, and medium for migrating a client TCP connection provided by the embodiments of the present application at least have the following technical effects.
[0041] By responding to the proxy server receiving a migration instruction, the downlink data is obtained from the old server. The downlink data is the data sent from the old server to the proxy server. The proxy server sends the migration point of the downlink data and the initial migration point of the uplink data to the new server as a flow header. The new server remotely calls the old server, and the old server obtains the uplink data according to the uplink data migration point. The old server sends the unsent data and the unprocessed data to the proxy server, and the proxy server sends the unsent data and the unprocessed data to the new server. By adding a special proxy server layer between the server and the client in the present application, the proxy server can be controlled to migrate a specified TCP connection from one server to another server, realizing a TCP connection migration without the client being aware. This solves the problems of reconnection data loss and high reconnection cost in the migration of client TCP connections in the related art.
[0042] The details of one or more embodiments of the present application are set forth in the following drawings and description, so that the other features, objects, and advantages of the present application become more concise and understandable. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] The drawings described herein are used to provide a further understanding of the present application, and constitute a part of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application, and do not constitute an improper limitation of the present application. In the drawings:
[0044] Figure 1 It is a flowchart of a method for migrating a client TCP connection;
[0045] Figure 2 It is a flowchart of obtaining downlink data shown according to an exemplary embodiment;
[0046] Figure 3 It is a specific flowchart of the first part of obtaining downlink data shown according to an exemplary embodiment;
[0047] Figure 4 It is a specific flowchart of the second part of obtaining downlink data shown according to an exemplary embodiment;
[0048] Figure 5 It is a schematic diagram of a migration result shown according to an exemplary embodiment;
[0049] Figure 6 It is a flowchart of obtaining uplink data shown according to an exemplary embodiment;
[0050] Figure 7 It is a block diagram of the structure of a client TCP connection migration system shown according to an exemplary embodiment;
[0051] Figure 8 The figure is a block diagram of an electronic device shown according to an exemplary embodiment. Detailed implementation manners
[0052] In order to make the objectives, technical solutions and advantages of the present application clearer and more understandable, the present application will be described and explained below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application. Based on the embodiments provided by the present application, all other embodiments obtained by those of ordinary skill in the art without making creative efforts belong to the scope of protection of the present application.
[0053] Obviously, the accompanying drawings in the following description are only some examples or embodiments of the present application. For those of ordinary skill in the art, without making creative efforts, the present application can also be applied to other similar scenarios based on these drawings. In addition, it can also be understood that although the efforts made in this development process may be complex and time-consuming, for those of ordinary skill in the art related to the content disclosed in the present application, some design, manufacturing or production changes based on the technical content disclosed in the present application are only conventional technical means and should not be understood as the content disclosed in the present application being insufficient.
[0054] References to "embodiments" in this application mean that the specific features, structures, or characteristics described in connection with the embodiments can be included in at least one embodiment of this application. The phrase appears in various places in the specification and does not necessarily refer to the same embodiment each time, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. It is explicitly and implicitly understood by those of ordinary skill in the art that the embodiments described in this application can be combined with other embodiments without conflict.
[0055] Unless otherwise defined, the technical terms or scientific terms involved in this application shall have the ordinary meanings understood by those of ordinary skill in the technical field to which this application pertains. The words such as "a", "an", "one kind", "the" and the like involved in this application do not indicate a limitation in quantity and can represent a singular or plural number. The terms "include", "comprise", "have" and any variations thereof involved in this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may further include steps or units not listed, or may further include other steps or units inherent to these processes, methods, products or devices. The terms "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The term "plurality" involved in this application means two or more. "And / or" describes the association relationship of associated objects and indicates that three relationships may exist. For example, "A and / or B" may represent: A exists alone, A and B exist simultaneously, and B exists alone. The character " / " generally represents an "or" relationship between the front and rear associated objects. The terms "first", "second", "third" and the like involved in this application are only used to distinguish similar objects and do not represent a specific order for the objects.
[0056] In this context, it should be understood that the terms involved may be technical means for implementing a part of the present invention or other summary technical terms. For example, the terms may include:
[0057] TCP connection: In this application, there are two connections. That is, the old connection between the proxy server and the old server; the new connection between the proxy server and the new server.
[0058] Downstream data and upstream data: There are two data streams in the TCP connection between the proxy server and the server. They are respectively the downstream data, the data stream from the server to the proxy server; and the upstream data, the data stream from the proxy server to the server.
[0059] Initial data migration point: When the sender sends data to the receiver, it is the data migration point where the receiver receives the data. At this time, the data sent by the sender and the data received by the receiver are mutually indeterminable because the network is fluid and there is a buffer within the system. The fluid data sent by the sender may not reach, and the data in the buffer may reach the application layer at any time. Therefore, the initial data migration point at this time is indeterminate and only serves as the initial data migration point. Among them, the initial data migration point includes the downstream initial data migration point and the upstream initial data migration point.
[0060] Target data migration point: When the sender sends data to the receiver, it is the data migration point where the receiver actually receives the data. At this time, the data sent by the sender and the data received by the receiver are determinate. Therefore, the target data migration point at this time is determinate and serves as the target data migration point. Among them, the target data migration point includes the downstream target data migration point and the upstream target data migration point.
[0061] Out-of-Band Control Channel (OOB): This channel is independent of the TCP connection migrated in this application. This channel can be point-to-point or multi-hop. In this application, there are two OOB channels: one is from the old server to the proxy server, and the other is from the proxy server to the new server.
[0062] Low-level-stack: The levels below the application layer save the original TCP data in queues or buffers. In the PoC (Proof of Concept) of this application, there are two levels: 1. BEAM virtual machine, which is used for the erlang port queue of the sending queue and the erlang port buffer of the receiving buffer; 2. Linux TCP stack, the Linux socket send / receive buffer.
[0063] Unprocessed data: Unprocessed data only comes from the old connection between the proxy server and the old server. Unprocessed data is the data extracted from the low-level stack of the application behavior. Therefore, these data are the raw data received from the client without being processed. To ensure reliable application data transmission, these data cannot be discarded because the peer will not resend these data. For the server, the unprocessed data should be sent from the old server to the new server for resumption of processing on the new server.
[0064] Unsent Data: Unsent data is the data buffer that the application sends to the lower-layer stack. The peer may or may not receive it, or may receive only part of it. When migration is triggered, the sender extracts the unsent data buffer from the lower-layer stack and reconstructs it. However, the reception status of the data in the extracted unsent data buffer is uncertain because it contains in-flight data that the peer may or may not have received. For a specific data stream, when the initial data migration point is determined but the target data migration point is not, the unsent data is undetermined. When both the initial data migration point and the target data migration point are determined, the unsent data is then determined, and thus resending is safe. When migrating a TCP connection, there is one unsent data for each data stream. The unsent data is transferred from the old server to the new server, and the new server must send it on the new connection according to the migrated stream header. Among them, the actual unsent data includes unsent data of the upstream stream and unsent data of the downstream stream.
[0065] Stream Header: The first few data bytes after a TCP connection is established between the proxy server and the new server. They are not application data. They contain key information for successful migration. In the PoC, a header for each stream is set for the new connection between the proxy server and the new server. Since the server needs to distinguish between the migration header and the application data, the first few bytes of the migration header contain reserved differentiating bytes for differentiating the application data.
[0066] The following is a specific embodiment of a method, system, device, and medium for migrating a client TCP connection:
[0067] In an actual production environment, due to various reasons (service function upgrade, patch repair, security patch, physical migration of the server, server scaling up / down), the server needs to be taken offline for maintenance briefly. Therefore, the server needs to migrate users to other clusters or other servers in the same cluster. Generally, this server needs to interrupt communication with the clients connected to it. When interrupting communication and then reconnecting, there are the following problems:
[0068] 1. Application data transmission is interrupted, increasing the data arrival delay.
[0069] 2. The client needs to handle exceptions and restore the connection to another available server.
[0070] 3. Due to the location of the client, the client may take longer to restore the connection.
[0071] 4. On some clients with resource constraints, application data may be actively discarded due to insufficient buffering capacity.
[0072] 5. Some clients with strong authentication mode enabled may take longer to resume data transmission.
[0073] 6. A large number of client reconnections increase the overhead of the egress network bandwidth, especially handshake reconnections with certificate verification.
[0074] 7. After reconnection, retransmission is required according to the upper-layer application protocol of TCP. The entire upper-layer message may need to be retransmitted, and in some cases, more data may need to be retransmitted. For example, in the MQTT protocol, when a 128MB MQTT control message migrates after being transmitted to 107M, the first 107M message or even more needs to be retransmitted after reconnection, depending on how much data the application layer has received and the QoS level.
[0075] To address the above problems, the present application proposes a method, system, device, and medium for migrating a client TCP connection.
[0076] In a first aspect, an embodiment of the present application provides a method for migrating a client TCP connection. Figure 1 It is a flowchart of a method for migrating a client TCP connection, as Figure 1 shown. A method for migrating a client TCP connection includes an old server and a new server. The old server is electrically connected to the new server through a proxy server. Specifically, the old server is electrically connected to the proxy server, the proxy server is electrically connected to the new server, and the new server is electrically connected to the client through the proxy server. The method includes the following steps:
[0077] Step S101: In response to the proxy server receiving a migration instruction, obtain downstream flow data from the old server. The downstream flow data is data sent from the old server to the proxy server.
[0078] Step S102: The proxy server sends the migration point of the downstream flow data and the initial migration point of the upstream flow data as a flow header to the new server.
[0079] Step S103: The new server remotely invokes the old server, and the old server obtains upstream flow data according to the upstream flow data migration point.
[0080] Step S104: Based on the downstream flow data and the upstream flow data, determine the transmission status of the downstream flow and the upstream flow. Based on the transmission status, the old server migrates the downstream flow data that has not been sent to the client and the upstream flow data uploaded by the client that has not been processed to the new server.
[0081] In summary, the method, system, and medium for migrating a client TCP connection provided by the embodiments of the present application at least have the following technical effects. By responding to the proxy server receiving a migration instruction, the downstream flow data is obtained from the old server, and the downstream flow data is the data sent from the old server to the proxy server. The proxy server sends the migration point of the downstream flow data and the initial migration point of the upstream flow data as a flow header to the new server. The new server remotely calls the old server, and the old server obtains the upstream flow data according to the upstream flow data migration point. The old server sends the unsent data and unprocessed data to the proxy server, and the proxy server sends the unsent data and unprocessed data to the new server. In the present application, a special proxy server is added between the server and the client. The proxy server can be controlled to migrate a specified TCP connection from one server to another server, realizing a TCP connection migration without the client being aware. This solves the problems of reconnection data loss and high reconnection cost in the migration of the client TCP connection in the related art.
[0082] It should be noted that the proxy server is a single entity with specific functions, such as monitoring the data flow status, processing data migration, etc. The proxy cluster is a collection composed of multiple proxy servers, which jointly complete complex tasks, improve system performance and availability. The proxy server described in the embodiments of the present application can be a proxy server or a proxy cluster.
[0083] In one embodiment, before responding to the proxy server receiving a migration instruction and obtaining the downstream flow data from the old server, the method further includes:
[0084] When migrating data from the old server to the new server, the old server sends a migration instruction to the proxy server through a remote call channel and sends the address information of the new server to the proxy server.
[0085] The old server uses a remote call channel (Remote Procedure Call, abbreviated as RPC) to send a migration instruction to the proxy server. The remote call channel is a dedicated communication path, independent of the data transmission channel, for sending control information and instructions. This design ensures the safe and reliable transmission of control instructions, unaffected by the data flow. The migration instruction contains the initial downstream flow data migration point and the address information of the new server. The address information of the new server includes the IP address and port number, etc., to guide the proxy server to establish a new connection with the new server.
[0086] The advantages of using the remote call channel RPC instead of the original TCP connection are:
[0087] First, it is independent. It will not contaminate the data transmitted by the original application layer.
[0088] Second. Low usage cost. The proxy server only needs to listen to the out-of-band RPC port and respond to calculations only when a request occurs. When no migration is needed, the proxy does not need to monitor or analyze the TCP connection for data transmission between the proxy and the server. Low computing cost.
[0089] Third. No blocking problem. The out-of-band RPC is a short connection with good controllability, flexible and retryable.
[0090] Fourth. High efficiency. The same RPC can trigger the migration of multiple TCP connections instead of one.
[0091] Figure 2 is a flowchart for obtaining downlink data shown according to an exemplary embodiment, as Figure 2 shown. Step S101, in response to the proxy server receiving a migration instruction, obtain downlink data from the old server. Specifically, it includes the following steps:
[0092] Step S1011, the old server obtains the unsent downlink data from the buffer. Among them, the unsent downlink data includes the data in the send buffer, the data in the flight state, and the data that has been determined not to be received.
[0093] The old server obtains the unsent downlink data from the buffer. Among them, the unsent downlink data includes the data in the send buffer, the data in the flight state, and the data that has been determined not to be received. Among them, the send buffer includes the virtual machine send buffer and the operating system send buffer. The data in the flight state is the data that has been sent but not yet confirmed. The data that has been determined not to be received: the data that has been sent and confirmed by the receiver but not yet received, located in the operating system receive buffer, may be reported to the application layer after 0.001 seconds, confirmed and received, that is, the data that has been received by the receiving end transport layer but not yet sent to the application layer. Ensure that all unfinished data transmission tasks are taken into account to avoid data loss. Ensure data consistency and avoid data incompleteness caused by some data not being sent.
[0094] Step S1012, record the sent data according to the counter, and based on the unsent downlink data, determine the initial data migration point of the downlink confirmed by the proxy server for reception.
[0095] Use the counter to record the amount of data that has been sent. According to the unsent downlink data obtained from the buffer, determine the initial data migration point of the downlink confirmed by the proxy server for reception. Specifically, according to the difference between the data recorded by the counter for sending and the unsent downlink data, determine the initial data migration point of the downlink confirmed by the proxy server for reception.
[0096] Step S1013, the old server notifies the proxy server of receiving the initial data migration point of the downlink through the out-of-band control channel.
[0097] Step S1014: The proxy server obtains the downlink target data migration point and notifies the old server through the out-of-band control channel.
[0098] Obtaining the actually received downlink target data migration point includes calculating the actually received downlink target data migration point when the offset of the migration point received by the proxy server is greater than or equal to the initial offset; wherein, when the offset of the migration point received by the proxy server is less than the initial offset, the untransmitted downlink data is pulled from the receive buffer until the offset is greater than or equal to the initial offset.
[0099] Step S1015: Through the downlink target data migration point, confirm the untransmitted data and the transmitted data of the target downlink, and use the untransmitted data of the target downlink as the downlink data.
[0100] For example, FIG. 3 is a first specific flowchart of obtaining downlink data shown according to an exemplary embodiment, wherein part (a) is a schematic flowchart, and part (b) is the information corresponding to each data segment. Figure 4 is a second specific flowchart of obtaining downlink data shown according to an exemplary embodiment, wherein part (a) is a schematic flowchart, and part (b) is the information corresponding to each data segment. As Figure 3 shown, the counter records that 6 bytes of data have been transmitted. The application layer data is fragmented into segments [A, B, C, D, E, F] (Segs). For the convenience of description, it is assumed that the length of each seg is 1 byte. A has been received by the application layer of the receiver. B is in the operating system receive buffer. C and D are in the flight state data, that is, they have been sent by the sender but not acknowledged by the transport layer of the receiver. The proxy server has received the confirmation from the old server that 2 bytes have been received. Therefore, A has been removed. The operating system send buffer of the old server still retains B, C, D, E, F because C and D are still in the flight state. And B has not been removed due to batch processing (efficiency) and is in the operating system receive buffer.
[0101] When the migration is triggered, as Figure 3 shown, the following steps are executed:
[0102] First step: The old server migration program pulls the untransmitted data from the virtual machine send buffer and the operating system send buffer, and reconstructs the untransmitted buffer, with a total of 5 bytes and an offset of 1.
[0103] Second step: The old server migration program calculates the downlink initial data migration point (6 - 5 = 1), noting that the status that the proxy server has received the confirmation from the old server that 2 bytes have been received is invisible to the upper layer.
[0104] Third step: The old server notifies the proxy server through the out-of-band control channel that at least 1 byte of offset has been received.
[0105] At this time, at the application layer, the states of the old server and the proxy server cannot be determined from each other because there is in-flight status data on the network and buffer data inside the system. Among them, the in-flight status data may not be reachable, and the data in the receive buffer may be reported to the application layer at any time.
[0106] As Figure 4 shown, in the fourth step, the proxy server receives an offset of 1 for A. If the local receive counter < 1, it continues to pull data from the receive buffer until the counter ≥ 1, then point B is determined, that is, the downlink target data migration point is determined. The proxy server notifies the old server through the out-of-band control channel that the offset of point B is 2. According to the offset of A received by the proxy server ≥ 1, point B is determined. Therefore, it can be known that any value greater than 1 of the offset is determined by the transmission state at that time. However, for the convenience of description, it is assumed here that the offset is "2".
[0107] In the fifth step, based on the B = 2 offset, the old server can remove 1 (2 - 1) byte from the data not yet sent in the downlink, that is, seg B is removed.
[0108] At this time, the data not yet sent by the old server is determined and known (C, D, E, F), and the data already received by the receiving end is also known (A, B).
[0109] Figure 5 is a schematic diagram of the migration result shown according to an exemplary embodiment. As Figure 5 shown, when the data not yet sent is determined and known (C, D, E, F), and the data already received by the receiving end is also known (A, B), the new receiver receives the data (A, B) of the old receiver, and receives data (C, D, E, F) from the sender, and the sender only needs to send subsequent new data to the new receiver.
[0110] It should be noted that: the states of both parties here are confirmed, there is no uncertain buffer data or in-flight status data, and the data is all at the application layer.
[0111] Figure 3 , Figure 4 and Figure 5 The sender in
[0112] The technical effects of step S101 include the following points:
[0113] First. Connections in transfer-blocking that can be migrated. When the client has limited bandwidth or insufficient consumption capacity, there will be downstream data piling up at the old server, in a blocked state. In this embodiment, without waiting for the old server to complete the transmission of the blocked data, step S101 accurately calculates to migrate the blocked data to the new server, ensuring the integrity and continuity of the migrated data. And it greatly improves the efficiency of large-scale connection migration and shortens the operation migration time.
[0114] Second. Saving bandwidth overhead during migration. Because it is at the data stream level, not the application data packet level. There is no need to consider the application layer packet boundary, and it can be directly truncated and migrated during the transmission of the application layer packet, without waiting for the complete transmission of the application layer packet or retransmitting the entire application layer packet.
[0115] Third. Low computing cost. Because it is at the data stream level, not the application data packet level. Therefore, the proxy does not need to monitor and parse the data stream during normal times when there is no migration. There is no need to maintain the data packet status.
[0116] In one embodiment, in step S102, the proxy server sends the migration point of the downstream stream data and the initial migration point of the upstream stream data to the new server as a stream header. Specifically, it includes:
[0117] The proxy server encapsulates the migration point of the downstream stream data and the migration point of the upstream stream data as a stream header and sends it to the new server through a new connection. By sending the migration point of the downstream stream data and the migration point of the upstream stream data as a stream header, it can ensure that the new server can quickly identify the migrated data and be ready to receive the subsequent data stream.
[0118] The technical effects of step S102 include the following points.
[0119] First. Using the stream header makes it easier for the server side to distinguish new connections and migrated connections, reducing the implementation cost and being easy to troubleshoot.
[0120] Second. The migrated application data is transmitted after the stream header, so this channel is reused. It improves the utilization rate of the connection between the proxy and the server and reduces duplicate new connections. Especially in the case of large-scale migration, it greatly reduces the pressure on the new server side, improving the migration success rate and efficiency.
[0121] Figure 6 It is a flowchart of obtaining upstream stream data shown according to an exemplary embodiment, as Figure 6 shown. In step S103, the new server remotely calls the old server, and the old server obtains the upstream stream data according to the upstream stream data migration point. Specifically, it includes the following steps:
[0122] In step S1031, after the new server processes the stream header, it makes a remote call to the old server.
[0123] After the new server processes the stream header, it can effectively make a remote call to the old server. Through the remote call, it can ensure that the new server can obtain the necessary information from the old server, ensuring the smooth progress of data migration.
[0124] Step S1032: Obtain the unprocessed data of the upstream stream that has not been sent from the buffer of the old server. Among them, the unprocessed data of the upstream stream that has not been sent includes the unprocessed data in the send buffer, the unprocessed data in the flight state, and the unprocessed data that has been determined not to be received.
[0125] The old server obtains the unprocessed data of the upstream stream that has not been sent from the buffer. Among them, the unprocessed data of the upstream stream that has not been sent includes the unprocessed data in the send buffer, the data in the flight state, and the data that has been determined not to be received. Among them, the send buffer includes the send buffer of the virtual machine and the send buffer of the operating system. The unprocessed data in the flight state is the data that has been sent but has not been confirmed by the peer end. The unprocessed data that has been determined not to be received: the data that has been sent and confirmed by the receiving party but has not been received yet, located in the receive buffer of the operating system, may be reported to the application layer after 0.001 seconds, confirmed and received, that is, the data that has been sent but not processed by the server. Ensure that all unfinished data transmission tasks are taken into account to avoid data loss. Ensure data consistency and avoid data incompleteness caused by some data not being sent.
[0126] Step S1033: Record the sent data according to the counter, and determine the initial data migration point of the upstream stream confirmed to be received by the proxy server based on the unprocessed data of the upstream stream.
[0127] Step S1034: The old server notifies the proxy server of receiving the initial data migration point of the upstream stream through the out-of-band control channel.
[0128] Obtaining the target data migration point of the actually received upstream stream includes: when the offset of the migration point received by the proxy server is greater than or equal to the initial offset, obtaining the target data migration point of the actually received upstream stream; among them, when the offset of the migration point received by the proxy server is less than the initial offset, pull the unprocessed data of the upstream stream that has not been sent from the receive buffer until the offset is greater than or equal to the initial offset. It should be noted that the initial offset is determined according to the actual situation. According to the execution operation triggered by the above migration, and as Figure 4 shown, the proxy server notifies the old server through the out-of-band control channel that the offset of point B is 2. According to the offset of point A received by the proxy server ≥ 1 (that is, "1" is the initial offset), then point B (the offset of point B is 2) is determined.
[0129] Step S1035: The proxy server obtains the target data migration point of the upstream stream and notifies the old server through the out-of-band control channel.
[0130] Step S1036: Confirm the unprocessed data that has not been sent and the unprocessed data that has been sent in the target upstream flow through the target data migration point for the upstream flow, and use the unprocessed data that has not been sent in the target upstream flow as the upstream flow data.
[0131] The process of obtaining the upstream flow data in Step S103 ensures the integrity and consistency of the data, and improves the reliability and efficiency of data transmission. Specifically, it avoids data loss and ensures the continuity and integrity of the data.
[0132] The technical effects of Step S103 include the following points:
[0133] First, independent RPC. For communication between the old and new servers, an independent QoS can be set to ensure priority.
[0134] Second, high efficiency. The same RPC can trigger the migration of multiple TCP connections instead of one.
[0135] Third, it can directly migrate the unprocessed data. When the processing capacity of the old server is limited, there will be upstream data piling up on the old server waiting to be processed. In the embodiment of the present application, the offset is accurately calculated to migrate the unprocessed data to the new server for processing, ensuring the integrity and continuity of the migrated unprocessed data. Greatly improve the efficiency of large-scale connection migration and shorten the migration waiting time.
[0136] Fourth, save the bandwidth overhead during migration. Because it is at the data stream level, not the application data packet level. There is no need to consider the application layer packet boundary, and it can be directly truncated and migrated during the transmission of the application layer packet without waiting for the complete transmission of the application layer packet or retransmitting the entire application layer packet.
[0137] In one embodiment, Step S104: Based on the downstream flow data and the upstream flow data, determine the transmission status of the downstream flow and the upstream flow. Based on the transmission status, the old server migrates the downstream flow data that has not been sent to the client and the upstream flow data that has not been processed by the client to the new server.
[0138] Specifically, it includes: The old server sends the downstream flow data (unsent data) and the upstream flow data (unprocessed data) to the proxy server, and the proxy server sends the downstream flow data and the upstream flow data to the new server. The new server receives and processes the unprocessed data to ensure the integrity and consistency of the data. The new server receives the unsent data and the unprocessed data through the proxy server, and subsequent new data is sent to the new server to complete the data migration.
[0139] By sending unsent data and unprocessed data and processing the unprocessed data on the new server, a seamless TCP connection migration for the client can be achieved, ensuring data consistency and integrity during the migration process, while reducing data retransmission and solving the problems of lost reconnection data and high reconnection cost in the migration of the client TCP connection in the related art.
[0140] The technical effects in this embodiment also include: 1. Seamless migration of the client. 2. No redundant retransmission of upper-layer application messages. 3. Fast migration speed without waiting for data on the network to arrive or for the buffer to be emptied. 4. Low network bandwidth occupancy. 5. No additional egress network traffic. 6. Controllable throughout the process. 7. Low normal occupancy of proxy resources, with only additional overhead required during migration. 8. Capable of migrating blocked connections.
[0141] In summary, a method for migrating a client TCP connection provided by an embodiment of the present application, in response to a proxy server receiving a migration instruction, obtains the received and confirmed downstream flow data from the old server. The proxy server sends the downstream flow data and the upstream flow data migration point to the new server as a flow header. The new server remotely calls the old server, and the old server obtains the upstream flow data based on the upstream flow data migration point. Based on the downstream flow data, the unsent data of the downstream flow data is determined, and based on the upstream flow data, the unprocessed data of the upstream flow data is determined. The old server sends the downstream flow data and the upstream flow data to the proxy server, and the proxy server sends the downstream flow data and the upstream flow data to the new server. The new server processes the unprocessed data and sends the processed data and the unsent data to the client to complete the client TCP migration. The present application adds a special proxy server layer between the server and the client. The proxy server can be controlled to migrate a specified TCP connection from one server to another server, realizing a seamless TCP connection migration for the client, and solving the problems of lost reconnection data and high reconnection cost in the migration of the client TCP connection in the related art.
[0142] In a second aspect, an embodiment of the present application provides a system for migrating a client TCP connection. Figure 7 It is a block diagram of a system for migrating a client TCP connection shown according to an exemplary embodiment. As Figure 7 shown, it includes an old server and a new server, and the old server is electrically connected to the new server through a proxy server; the system includes a downstream flow data acquisition module 710, a flow header sending module 720, an upstream flow data acquisition module 730, and a migration module 740, where:
[0143] The downstream flow data acquisition module 710 is configured to obtain the downstream flow data from the old server in response to the proxy server receiving a migration instruction, and the downstream flow data is the data sent from the old server to the proxy server;
[0144] The bid - failure header sending module 720 is used for the proxy server to send the migration point of the downstream flow data and the initial migration point of the upstream flow data as a bid - failure header to the new server;
[0145] The upstream flow data acquisition module 730 is used for the new server to remotely call the old server, and the old server acquires the upstream flow data according to the upstream flow data migration point;
[0146] The migration module 740 is used to determine the transmission status of the downstream flow and the upstream flow based on the downstream flow data and the upstream flow data. Based on the transmission status, the old server migrates the downstream flow data that has not been sent to the client and the upstream flow data uploaded by the client that has not been processed to the new server.
[0147] In summary, a migration system for the client TCP connection provided by this application. Through the downstream flow data acquisition module, the bid - failure header sending module, the upstream flow data acquisition module, and the migration module, a special proxy server is added between the server and the client. The proxy server can be controlled to migrate a specified TCP connection from one server to another server, realizing a TCP connection migration without the client noticing. It solves the problems of lost re - connection data and high re - connection cost in the migration of the client TCP connection in the related art.
[0148] It should be noted that the migration system for the client TCP connection provided in this embodiment is used to implement the above - mentioned implementation manners, and those that have been described will not be repeated. As used above, terms such as "module", "unit", "sub - unit", etc. can be a combination of software and / or hardware that can achieve a predetermined function. Although the devices described in the above embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and contemplated.
[0149] In a third aspect, an embodiment of this application provides an electronic device, Figure 8 which is a block diagram of an electronic device shown according to an exemplary embodiment. As Figure 8 shown, the electronic device may include a processor 81 and a memory 82 storing computer program instructions.
[0150] Specifically, the above - mentioned processor 81 may include a central processing unit (CPU), or an application - specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application.
[0151] Among them, the memory 82 may include a mass memory for data or instructions. By way of example and not limitation, the memory 82 may include a hard disk drive (HDD), a floppy disk drive, a solid state drive (SSD), a flash memory, an optical disc, a magneto-optical disc, a magnetic tape, or a universal serial bus (USB) drive, or a combination of two or more of these. In a suitable case, the memory 82 may include a removable or non-removable (or fixed) medium. In a suitable case, the memory 82 may be internal or external to the data processing device. In a particular embodiment, the memory 82 is a non-volatile memory. In a particular embodiment, the memory 82 includes a read-only memory (ROM) and a random access memory (RAM). In a suitable case, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically alterable read-only memory (EAROM), or a flash memory (FLASH), or a combination of two or more of these. In a suitable case, the RAM may be a static random access memory (SRAM) or a dynamic random access memory (DRAM), where the DRAM may be a fast page mode dynamic random access memory (FPMDRAM), an extended date out dynamic random access memory (EDODRAM), a synchronous dynamic random access memory (SDRAM), etc.
[0152] The memory 82 can be used to store or cache various data files required for processing and / or communication, as well as possible computer program instructions executed by the processor 81.
[0153] The processor 81 reads and executes the computer program instructions stored in the memory 82 to implement any one of the client TCP connection migration methods in the above embodiments.
[0154] In one embodiment, a client TCP connection migration device may further include a communication interface 83 and a bus 80. Among them, as Figure 8 shown, the processor 81, the memory 82, and the communication interface 83 are connected through the bus 80 and complete communication with each other.
[0155] The communication interface 83 is used to implement communication between the modules, devices, units, and / or devices in the embodiments of the present application. The communication interface 83 can also implement data communication with other components such as external devices, image / data acquisition devices, databases, external storage, and image / data processing workstations.
[0156] Bus 80 includes hardware, software, or both, and couples components of a migration device for a client TCP connection to each other. Bus 80 includes, but is not limited to, at least one of the following: Data Bus, Address Bus, Control Bus, Expansion Bus, Local Bus. By way of example and not limitation, Bus 80 may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infini Band interconnect, a Low Pin Count (LPC) bus, a memory bus, a Micro Channel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable bus or a combination of two or more of these. In a suitable case, Bus 80 may include one or more buses. Although the embodiments of the present application describe and illustrate specific buses, the present application contemplates any suitable bus or interconnect.
[0157] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a program is stored. When the program is executed by a processor, a method for migrating a client TCP connection provided in the first aspect is implemented.
[0158] Among them, the more specific forms that the readable storage medium may adopt may include, but are not limited to: portable disks, hard disks, random access memories, read-only memories, erasable programmable read-only memories, optical storage devices, magnetic storage devices, or any suitable combination of the above.
[0159] In a possible implementation manner, the present invention can also be implemented in the form of a program product, which includes program code. When the program product runs on a terminal device, the program code is used to cause the terminal device to execute the steps of implementing a method for migrating a client TCP connection provided in the first aspect.
[0160] Among them, the program code for executing the present invention can be written in any combination of one or more programming languages. The program code can be executed completely on the user device, partially on the user device, executed as an independent software package, partially on the user device and partially on a remote device, or completely on a remote device.
[0161] The technical features of the above embodiments can be combined arbitrarily. For the sake of concise description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope recorded in this specification.
[0162] The above embodiments only represent several implementation manners of the present application. The description is relatively specific and detailed, but it should not be construed as a limitation on the scope of the invention patent. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several deformations and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application should be subject to the appended claims.
Claims
1. A method for migrating a client TCP connection, characterized in that: The method comprises an old server and a new server, wherein the old server is electrically connected to the new server via a proxy server; and the method comprises: In response to the proxy server receiving the migration instruction, acquiring downstream data from the old server, the downstream data being data sent from the old server to the proxy server; The proxy server sends the migration point of the downstream data and the initial data migration point of the upstream data as a stream header to the new server; wherein the migration point of the downstream data includes the initial data migration point of the downstream and the target data migration point of the downstream, the initial data migration point of the downstream is a data migration point at which the receiver receives an undetermined data when the sender sends data to the receiver in the downstream, the target data migration point of the downstream is a data migration point at which the receiver actually receives the data when the sender sends data to the receiver in the downstream, and the initial data migration point of the upstream is a data migration point at which the receiver receives an undetermined data when the sender sends data to the receiver in the upstream; The new server remotely calls the old server, and the old server obtains the upstream data according to the upstream initial data migration point; Based on the downstream data and the upstream data, the transmission status of the downstream and the upstream is determined. Based on the transmission status, the old server migrates the downstream data and the unprocessed upstream data uploaded by the client to the new server.
2. The method according to claim 1, characterized in that Obtaining downstream data from the old server, including: The old server obtains the unsent downstream data from the buffer, wherein the unsent downstream data includes data in the sending buffer, data in flight, and data that has been determined not to be received; Determining a migration point of the initial data of the downstream flow that the proxy server confirms receipt of, based on the counter recording the sent data and based on the fact that the downstream flow has not sent data; The old server notifies the proxy server through an out-of-band control channel that the initial data migration point of the downstream flow has been received; The proxy server obtains the downstream target data migration point and informs the old server through an out-of-band control channel; The target downstream unsent data and sent data are confirmed through the downstream target data migration point, and the target downstream unsent data is used as downstream data.
3. The method according to claim 1, characterized in that The new server remotely calls the old server, and the old server obtains the upstream data according to the upstream initial data migration point, including: After processing the stream header, the new server remotely calls the old server; Acquire unsent upstream unprocessed data from the buffer of the proxy server, wherein the unsent upstream unprocessed data includes data in a sending buffer, data in flight, and data that has been determined not to be received; According to the counter record sending data, based on the upstream unprocessed data, determining the upstream initial data migration point that the proxy server confirms receipt; The old server notifies the proxy server through an out-of-band control channel that the upstream initial data migration point has been received; The proxy server obtains the upstream target data migration point and informs the old server through an out-of-band control channel; The unprocessed data that has not been sent and the unprocessed data that has been sent of the target upstream are confirmed through the upstream target data migration point, and the unprocessed data that has not been sent of the target upstream is used as the upstream data.
4. The method according to claim 2, characterized in that: The step of recording the sent data according to the counter and determining the initial data migration point of the downstream flow that the proxy server confirms receipt based on the fact that the downstream flow has not sent data comprises: The initial data migration point of the downstream flow that the proxy server confirms to receive is determined according to the difference between the sent data recorded by the counter and the unsent data of the downstream flow.
5. The method according to claim 2, characterized in that: The proxy server obtains the downstream target data migration point, including: When the offset of the migration point received by the proxy server is greater than or equal to the initial offset, the downstream target data migration point is obtained; wherein, When the offset of the migration point received by the proxy server is less than the initial offset, unsent data of the downstream flow is pulled from the receiving buffer until the offset is greater than or equal to the initial offset.
6. The method according to claim 2, characterized in that The step of confirming, through the downstream target data migration point, that the target downstream stream has not sent data includes: According to the difference between the sent data recorded by the counter and the downstream target data migration point, confirm that the target downstream has not sent data; wherein, The counter records the sent data as the total byte data sent, and the downstream target data migration point is the byte data that has been confirmed to be received.
7. The method according to claim 1, characterized in that Before obtaining the downstream flow data from the old server in response to the proxy server receiving the migration instruction, the method further includes: In response to migrating data from the old server to the new server, the old server sends a migration instruction to the proxy server through a remote call channel, and sends address information of the new server to the proxy server.
8. A client TCP connection migration system, characterized in that: The system comprises an old server and a new server, wherein the old server is electrically connected to the new server via a proxy server; the system comprises a module for acquiring downstream data, a module for sending stream headers, a module for acquiring upstream data, and a migration module, wherein: The downstream data acquisition module is used to acquire downstream data from the old server in response to the proxy server receiving the migration instruction, wherein the downstream data is data sent from the old server to the proxy server; The stream header sending module is used for the proxy server to send the migration point of the downstream data and the upstream initial data migration point as a stream header to the new server; wherein the migration point of the downstream data includes a downstream initial data migration point and a downstream target data migration point, the downstream initial data migration point is a data migration point at which the receiver receives undetermined data when the sender sends data to the receiver in the downstream, the downstream target data migration point is a data migration point actually received by the receiver when the sender sends data to the receiver in the downstream, and the upstream initial data migration point is a data migration point at which the receiver receives undetermined data when the sender sends data to the receiver in the upstream; The module for obtaining upstream data is used for the new server to remotely call the old server, and the old server obtains the upstream data according to the upstream initial data migration point; The migration module is used to determine the transmission status of the downstream and upstream based on the downstream data and the upstream data. Based on the transmission status, the old server migrates the downstream data and the unprocessed upstream data uploaded by the client to the new server.
9. An electronic device, characterized in that: The invention comprises a memory and a processor, a computer program stored in the memory and executable on the processor, and the processor implements a method for migrating a client TCP connection as claimed in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, a method for migrating a client TCP connection is implemented as claimed in any one of claims 1 to 7.
Citation Information
Patent Citations
Stored data migration method
CN104683476A
Telephone conference seamless switching method
CN106341409A