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

Persistent connections to volume servers through FUSE #1802

Closed
Woellchen opened this issue Feb 12, 2021 · 11 comments
Closed

Persistent connections to volume servers through FUSE #1802

Woellchen opened this issue Feb 12, 2021 · 11 comments

Comments

@Woellchen
Copy link
Contributor

Woellchen commented Feb 12, 2021

I've got one question regarding FUSE mounts and connections to volume servers.
As far as I could see on my server/s and from the code, retrieving or saving files to volume servers happens in dedicated HTTP requests. This is probably the case for all volume server operations.
Would it not be possible to keep the connections alive all the time? Or have some kind of connection pooler that keeps a bunch of idle connections that can be reused?
Making a new request each and every time is very expensive and adds a lot of overhead. It degrades the overall performance. Especially when the connections are also encrypted (TLS handshake..).
Did I miss something or could this be a nice feature for SeaweedFS?

@kmlebedev
Copy link
Contributor

kmlebedev commented Feb 12, 2021

@chrislusf It seems enough to enable the reuse connection by means of tcp
See
https://github.com/zalando/skipper/pull/1511/files

How does curl

curl -sv -o /dev/null http://www.google.com http://www.google.com  2>&1| grep -i 'connection'
* Connection #0 to host www.google.com left intact
* Re-using existing connection! (#0) with host www.google.com
* Connection #0 to host www.google.com left intact

@chrislusf
Copy link
Collaborator

Current code does try to exhaust the responses https://github.com/chrislusf/seaweedfs/blob/master/weed/util/http_util.go#L373

Maybe the per host connection count is too high? https://github.com/chrislusf/seaweedfs/blob/master/weed/util/http_util.go#L24

@kmlebedev
Copy link
Contributor

kmlebedev commented Feb 12, 2021

Current code does try to exhaust the responses https://github.com/chrislusf/seaweedfs/blob/master/weed/util/http_util.go#L373

Maybe the per host connection count is too high? https://github.com/chrislusf/seaweedfs/blob/master/weed/util/http_util.go#L24

Need to test
OJ/gobuster#127
MaxIdleConnsPerHost == number of goroutines/'threads'
and
http://tleyden.github.io/blog/2016/11/21/tuning-the-go-http-client-library-for-load-testing/

@kmlebedev
Copy link
Contributor

kmlebedev commented Feb 12, 2021

try set MaxIdleConns = MaxIdleConnsPerHost

	Transport = &http.Transport{
		MaxIdleConns: 1024,
		MaxIdleConnsPerHost: 1024,
	}

For example you have 10 volume server, then there are 10 connections per server

chrislusf added a commit that referenced this issue Feb 12, 2021
@chrislusf
Copy link
Collaborator

adjusted with 487e435

but how to verify the fix?

@Woellchen
Copy link
Contributor Author

Shall I test something? I can build a new binary and run it.
Meanwhile I did some tcpdumping. It turns out that it is always the volume server that closes the connection. It sends FINACK and mount returns with FINACK as well, followed by a last ACK from the volume server. So a normal connection close.
Maybe there is something on the volume server side that we can do?

@kmlebedev
Copy link
Contributor

Shall I test something? I can build a new binary and run it.
Meanwhile I did some tcpdumping. It turns out that it is always the volume server that closes the connection. It sends FINACK and mount returns with FINACK as well, followed by a last ACK from the volume server. So a normal connection close.
Maybe there is something on the volume server side that we can do?

You incorrectly mean FastOpen for Socket but I have not found how to enable it for net/http
But I found https://github.com/valyala/fasthttp

@Woellchen
Copy link
Contributor Author

Hm, what I really mean is how can we keep connections up without dying? At least for some configurable amount of time.
I just see that connections are closed after a few seconds (2 rounds of 15sec TCP keepalive?) and I want to keep them open for at least a few minutes.
Can we maybe use this: https://golang.org/pkg/net/#TCPConn.SetKeepAlive and https://golang.org/pkg/net/#TCPConn.SetKeepAlivePeriod?

@chrislusf
Copy link
Collaborator

@Woellchen try to adjust weed volume -idleTimeout=30

Existing code also disconnects if there are no data traffic. https://github.com/chrislusf/seaweedfs/blob/master/weed/util/net_timeout.go#L58

@Woellchen
Copy link
Contributor Author

@chrislusf thanks! That actually helped. I still see degraded performance when loading files from time to time, so the root cause were not the kept-alive TCP connection.
I will try to do some debugging and find out what is wrong in my case.

@chrislusf
Copy link
Collaborator

Do you configure concurrent writers? Make sure it does not create too many goroutines.

weed mount -concurrentWriters=128

  -concurrentWriters int
    	limit concurrent goroutine writers if not 0 (default 128)

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

3 participants