Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proxy: enable tcp keepalive #324

Closed
2 tasks done
sgotti opened this issue Jul 27, 2017 · 2 comments
Closed
2 tasks done

proxy: enable tcp keepalive #324

sgotti opened this issue Jul 27, 2017 · 2 comments

Comments

@sgotti
Copy link
Member

sgotti commented Jul 27, 2017

We should add some tcp keeperalive options to the stolon proxy:

  • Enable tcpkeepalive by default (like done by postgres) on incoming connections
  • Add some options to tune tcp keepalive. I'd like to support linux settings at first being able to tune all three settings (time, probe number and interval).

For the latter: using the golang stdlib ttps://golang.org/pkg/net/#TCPConn.SetKeepAlivePeriod doesn't permit a fine grained setting since it's a common function between different OSes where you can only define an interval that will have different effects depending on the OS. On Linux this will leave the probe value untouched and set time and interval to the same value.

So we need to directly call a setsockopt syscall to the fd owned by a TCPConn, for doing this we have to access the private fd. These could be done with 2 tricks both having different problems:

  1. Get a cloned fd using conn.File(), apply the socket options and then put it back in nonblocking mode like done by https://github.com/felixge/tcpkeepalive . I don't like this way since it's not the right use of File().
  2. Access the TCPConn fd with reflection since we are not changing it like done in https://github.com/aristanetworks/goarista/blob/master/dscp/listen_unix.go and https://github.com/golang/net/
  3. Test if the new https://tip.golang.org/pkg/syscall/#RawConn go 1.9 features works since it should be the right way for doing such things.

We could implement both 2 and 3 depending on the go version.

@sgotti
Copy link
Member Author

sgotti commented Jul 27, 2017

/cc @Dirbaio

@sgotti
Copy link
Member Author

sgotti commented Oct 9, 2017

Fixed for golang >= 1.9 in #357

@sgotti sgotti closed this as completed Oct 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant