-
Notifications
You must be signed in to change notification settings - Fork 414
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
File Descriptor leak #75
Comments
same problem here, request in goroutine caused fd count increasing |
This was happening to me as well. I wrote a pass through service using echo that posted data to a partner API. Eventually I got this: Set("Connection", "close") solves my issue though. The other open connections look like this: These timed out on my box, TBH I need to look more into this to figure out whether these matter. Thanks for your post. |
@slava-vishnyakov |
Well, I got the same problem here |
My solution was to go back the the net/http library. The growing file descriptor count issue can be fixed by disabling keep-alives, but the panic on connection reset makes this otherwise useful lib unstable imo. |
@dustinevan agreed,
work for me |
@dustinevan |
Say you have 100k requests to send, all scheduled in different goroutines, any library based on net/http will attempt to open connections and send the requests independently. This means--depending on how long it takes to establish a connection, and depending on how long it takes for the request to get a response, and depending how long it takes to schedule the goroutines--that in worse case you'll attempt to open 100k connections with a single server. If you overwhelm a server in this way, some well written servers will start resetting your connections--essentially hanging up the phone on you. If you receive a connection reset, the proper thing to do as a client is to wait, and then resend the request. net/http properly recovers from this situation to retry your requests, but this gorequest library panics instead. I guess you could write some recovery code to deal with this situation, but my solution was to not use the library. That being said, none of this matters if you're sending a request here and there. This is only important in high traffic situations. |
@dustinevan |
@dustinevan This is the code:
|
Nice! Looks like I need to look deeper into my error then. Good to know! |
I recently ran into this issue while making requests with the stdlib. The problem arises from initialising a new From the doc:
|
Is there any decision has been made. What is the best way to do concurrent request by reusing same TCP connection ? |
Does this problem also occur if you reuse |
I can confirm that the example reported by @roxma does not exhibit the error when using a fixed http.Client and http.Transport. Should we introduce a |
I have a code like this:
The real code is a bit more complicated, but anyways..
It seems to be in line with what docs recommend, but it actually leaks file descriptors:
the output that I get is:
Ok, let's change it a bit (which is not documented, but ok):
This time it's better:
Request done, open files = 14 Request done, open files = 15 Request done, open files = 16 Request done, open files = 17 Request done, open files = 18 Request done, open files = 19 Request done, open files = 20
But it still leaks.
.Set("Connection", "close")
The full code is here: https://git.io/vaDBp
The text was updated successfully, but these errors were encountered: