0

Context: Say I have a global cloud service. In each datacenter, I have numerous persistent TCP connections to various client devices. The TCP connections are distributed across various nodes in the datacenter.

Question: In this theoretical scenario, say each node has N persistent TCP connections (where N is a low number). Is it possible to essentially "move" TCP connections to another node so I can have more TCP connections per node, and thus need less nodes?

To provide a little more context, I'm unsure if a service can re-establish a TCP connection on a different node, which implies it could be moved. My overarching desire is to allow horizontal scalability for my nodes that maintain persistent TCP connections so I can reduce nodes when possible.

3
  • 1
    A TCP connection is identified by both the source and destination IP and TCP addresses. Changing any one of those four addresses will break the connection.
    – Ron Maupin
    Jul 5, 2021 at 19:16
  • 1
    Moving a TCP socket also requires synchronizing the application-level server state between hosts which is quite a feat. However, host configurations and protocols above the transport layer are explicitly off-topic here, see the help center.
    – Zac67
    Jul 5, 2021 at 20:28
  • 1
    rather than move connection after the facts, the correct way to do it is to balance the incoming connection upon establishment. This is what load-balancer are made for.
    – JFL
    Jul 6, 2021 at 10:22

1 Answer 1

5

Yes, it is possible, but requires support from the operating system. You've also got to ensure packets for the affected TCP connection are directed to the right host post-connection-migration.

This topic is a bit outside the scope of the Network Engineering Stack Exchange. However, I didn't find any other good-quality posts on other SXes, either.

I recommend you read about Linux TCP Connection Repair (TCP_REPAIR) feature, which is intended to do what you want.

The use-cases for this are limited, so unfortunately, there aren't a lot of publicly available resources. A search of github yielded only a few hits on TCP_REPAIR as well. However, there are some examples to get you started.

Note that moving application state is another topic you'll need to look into. For example, if your persistent TCP connections include SSL, it is possible to save & restore SSL session state (and therefore, to move it) but it is non-trivial to implement. The same may be true of your top-layer application, whatever that may be.

Sometimes, the savings of auto-scaling are not outweighed by the complexity of doing it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.