Ask HN: What are the best practices for opening a single outbound connection?

4 points by millisecond ↗ HN
In a world where most systems are architected to redundantly handle tons of inbound connections sometimes you need to start a single long-lived highly available outbound one.

For inbound, it's pretty easy, run redundant load balancing processes/servers in front of redundant web front-ends.

When you need to open a single outbound connection, i.e. WebSocket to a remote service, how do you architect it on the standard cloud platforms to always have a single one open? Need to both catch closes on the remote side and re-open and failures of the code / instance / hardware on the listening side.

Thinking something about locking a DB row or using atomic DB operations to claim the resource every N seconds and have a cluster of instances all contending for the resource, but feel like there must be a better way.

2 comments

[ 3.6 ms ] story [ 14.3 ms ] thread
To be highly available the services certainly need to be aware of the status of the connection. It seems like a normal election leader algorithm would handle this just find.